Get Image Preview or Thumbnail of PDF or Office File with Simple API Call

April 27th, 2021 / by api2pdf /

We continue to enhance our V2 API which is loaded with features now. Check out our REST API documentation here.

A major annoyance for developers is having to generate a thumbnail or image preview of an uploaded Office file or PDF file. We have now added a new endpoint located at /libreoffice/thumbnail that will ingest a URL to your PDF or Office file. Behind the scenes, we actually use LibreOffice to first convert the file to PDF format (even if it’s already a PDF, that’s okay). We then use another LibreOffice command to pull the 1st page of the resulting PDF and convert that to a JPG file. Unfortunately there is no support to convert the entire file to an image at this time. But that’s fine. For most thumbnail use cases, you are just interested in showing the first page anyway.

In short, to convert PDF to JPG or Office File to JPG (first page only), you will want to make a simple POST call to our api (grab your API key) with the following details:

Type: POST

Endpoint: https://v2.api2pdf.com/libreoffice/thumbnail

Header:

Authorization: YOUR-API-KEY

content-type: appliation/json

JSON Payload:

{ “url”: “https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-power-point.pptx” }

That’s it. Don’t forget to replace the url in the payload with the actual url to your asset you need to convert.

Tags: , , , , , , , , , , , , , , , , , , , , ,

Comments are closed.