PDF Rendering now in the OneNote API

Hi, I'm Chris, a PM on the OneNote API team and I'm happy to announce that we're keeping up on our promise to deliver from our backlog as frequently as possible. Just a few weeks after releasing the initial API, we're making PDF Rendering available to you and your users. As of today, the API can render the pages of a PDF file and place the images on a user's OneNote page in addition to embedding it. We think this will be helpful for scanner apps, but there are many other possibilities.

We're leveraging the data-render-src attribute to the <img> tag again, paired with a pdf type MIME part. When you try it you will see that the API accepts page orientation & dimensions from the PDF but you can also specify dimensions for the <img> tag.

Here's what a sample request looks like:

 Content-Type:multipart/form-data; boundary=MyAppPartBoundary
Authorization:bearer tokenString

--MyAppPartBoundary
Content-Disposition:form-data; name="Presentation"
Content-type:text/html

<!DOCTYPE html>
<html>
 <head>
 <title>A page with an embedded and displayed PDF file</title>
 </head>
 <body>
 <object 
 data-attachment="PDF Chewy's DNA.pdf" 
 data="name:MyAppFileBlockName " 
 type="application/pdf" />
 <img data-render-src="name:MyAppFileBlockName " width="1024"/>
 </body>
</html>

--MyAppPartBoundary
Content-Disposition:form-data; name="MyAppFileBlockName"
Content-type:application/pdf
... embedded PDF file binary data ...
--MyAppPartBoundary--

Here's a what a simple OneNote page with rendered pages from a PDF looks like. (It's my dog's DNA test results… he didn't get his name saving the stars, but because he chewed everything up as a puppy)

PDF's rendered on a page will appear as images for easy viewing in OneNote anywhere.

Have you ever opened up a tiny little PDF file to find 100's of pages within? So have we, and rendering all those images out is expensive and can blow past a page size limit, so we'll render as many pages as possible. If we cannot get the entire job done we'll also embed the original file onto the page to prevent data loss. Kudos if your request already has the file embedded as an object. :-)

There are a few details you should know: The API needs the PDF to be provided in a MIME part, and only 1 can be rendered per request for now. All the usual page create details apply.

That's it for now as we go back to our backlog to get more functionality out to you as soon as possible. Please let us know what you think on our API feedback page.

Thanks!