How can I make a screenshot from every page of PDF file and save result as images in PHP? Is it possible?
Press the Print Screen button (usually between the letter and numeric keys) on the page you want to take a screenshot. Then open Microsoft Paint or other image editing program and press Ctrl + V (paste). Proceed similarly with other pages.
Convert Screenshot to PDF with Wondershare PDF Converter Launch Wondershare PDF Converter Pro, go to the "File to PDF" tab, and you will be able to add a screenshot into this converter using the "Add" button. Click the "Add" button, browse screenshots in your local folder, and click "Open" to add screenshot files.
Maybe the "make a screenshot" can be replaced for your purpose by "create a raster image" for each PDF page?
In this case you could use ImageMagick and/or one of its PHP-enabled libraries. Here is a command line representation:
convert some.pdf[15-19] some.png
This will convert not all pages, but the page range 16--20 (page counting here is zero-based (not intuitive, I know...). To convert all pages, just skip the [15-19]
part.
The output PNG names will be some-0.png
, some-1.png
, ... some-4.png
.
To create JPEG or GIF instead of PNG, simply use one of these:
convert some.pdf[15-19] some.jpg
convert some.pdf[15-19] some.gif
By default ImageMagick will use a resolution of 72 PPI. This will indirectly determine the image dimensions of the PNG/JPEG/GIF output. Should you need other output dimensions than the defaults, you have different options, for example:
-density
-resize
to the command line:
convert -density 200 some.pdf some.png
convert some.pdf -resize 50% some.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With