cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SlavaS1
Helper II
Helper II

PDF to JPG converts the first page only

I need to insert PDF on OneNote page as printout using Power Automate. To do that I convert a PDF file to JPG using standard OneDrive connector "Convert File" and then insert the result image on the OneNote page. It works but with one limitation: only 1st page of the PDF file is converted to JPG.

 

Is it convertor's limitation? If yes, then Is there any other way to insert PDF printout version on OneNote page?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @SlavaS1 ,

 

I found this document.

https://docs.microsoft.com/en-us/graph/onenote-images-files#add-images-of-pdf-file-contents

Does it help?

 

Edit:

You can try to use graph api to insert PDF printout.

Sample:

vxiaochenmsft_0-1658193145398.png

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "body": "<!DOCTYPE html><html> <head><title>A page with images of the pages of a PDF file</title></head><body>   <p>The pages of this PDF file render as images.</p>  <img data-render-src=\"name:file-part\" alt=\"PDF file as images\" width=\"500\"/>  </body></html>",
      "headers": {
        "Content-Disposition": "form-data; name=\"Presentation\"",
        "Content-Type": "text/html"
      }
    },
    {
      "body": @{body('Get_file_content_using_path')},
      "headers": {
        "Content-Disposition": "form-data; name=\"file-part\""
      }
    }
  ]
}

For your information:

https://willpage.dev/2019/12/20/using-the-http-action-to-post-multipart-form-data-in-power-automate-...

 

Best Regards,

Wearsky

View solution in original post

3 REPLIES 3
v-xiaochen-msft
Community Support
Community Support

Hi @SlavaS1 ,

 

I found this document.

https://docs.microsoft.com/en-us/graph/onenote-images-files#add-images-of-pdf-file-contents

Does it help?

 

Edit:

You can try to use graph api to insert PDF printout.

Sample:

vxiaochenmsft_0-1658193145398.png

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "body": "<!DOCTYPE html><html> <head><title>A page with images of the pages of a PDF file</title></head><body>   <p>The pages of this PDF file render as images.</p>  <img data-render-src=\"name:file-part\" alt=\"PDF file as images\" width=\"500\"/>  </body></html>",
      "headers": {
        "Content-Disposition": "form-data; name=\"Presentation\"",
        "Content-Type": "text/html"
      }
    },
    {
      "body": @{body('Get_file_content_using_path')},
      "headers": {
        "Content-Disposition": "form-data; name=\"file-part\""
      }
    }
  ]
}

For your information:

https://willpage.dev/2019/12/20/using-the-http-action-to-post-multipart-form-data-in-power-automate-...

 

Best Regards,

Wearsky

Thank you @v-xiaochen-msft  this is exactly what I need.

I would add for others that to run that HTTP call we have prior

- register an App in Azure,

- get permissions with scope Notes.ReadWriteAll

- get token on the flow

- use that bearer token to create OneNote page

Hi @v-xiaochen-msft I was able to insert PDF printout when I create a OneNote page, thank you for your detailed reply, it helped me a lot.

 

Now I'd like to update the page and insert another printout. I wrote a HTTP call body base on the article but something wrong, perhaps I use names "Presentation" and "Commands" wrongfully.

 

Could you please look how is correctly compose the request to insert another printout on existed page.

 

Thanks in advance.

 

SlavaS1_0-1659293259017.png

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,829)