Skip to content

Instantly share code, notes, and snippets.

@symisc
Created March 14, 2021 01:29
Show Gist options
  • Save symisc/889f90b8f5c6df6e3232308f9a1006f8 to your computer and use it in GitHub Desktop.
Save symisc/889f90b8f5c6df6e3232308f9a1006f8 to your computer and use it in GitHub Desktop.
Convert a PDF document to a high resolution JPEG/PNG image via the PixLab API - https://pixlab.io/cmd?id=pdftoimg.
import requests
import json
# Convert a PDF document to JPEG/PNG image via /pdftoimg endpoint - https://pixlab.io/cmd?id=pdftoimg
req = requests.get('https://api.pixlab.io/pdftoimg',params={
'src':'https://www.getharvest.com/downloads/Invoice_Template.pdf',
'export': 'jpeg',
'key':'PIXLAB_API_KEY' # Grab your API Key from https://pixlab.io/dashboard
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
print ("Link to the image output (Converted PDF page): "+ reply['link'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment