Created
March 14, 2021 01:28
-
-
Save symisc/aea3b2366e4bea0e5d016bc06b32c0ea 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github | |
* https://github.com/symisc/pixlab-php | |
*/ | |
require_once "pixlab.php"; | |
# Convert a PDF document to a high resolution JPEG/PNG image via /pdftoimg. | |
# https://pixlab.io/cmd?id=pdftoimg for additional information. | |
# Target PDF to convert | |
$pdf = 'https://www.getharvest.com/downloads/Invoice_Template.pdf'; | |
# Invoke the endpoint | |
$pix = new Pixlab('PIXLAB_API_KEY'); # Grab your API key from https://pixlab.io/dashboard | |
if( !$pix->get('pdftoimg',[ | |
'src' => $pdf, | |
'export' => 'png' | |
]) ){ | |
echo $pix->get_error_message()."\n"; | |
die; | |
} | |
echo "Link to the image output (Converted PDF page): ".$pix->json->link."\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment