You can use convert
( ImageMagick ) to parse PDF
files.
PNG output
Convert test.pdf
to numbered PNG
images:
convert -density 150 -trim test.pdf page%d.png
JPEG output
Convert test.pdf
to numered JPEG
images:
convert -density 150 -trim test.pdf -quality 100 -flatten -sharpen 0x1.0 page%d.jpg
As per @JBWhitmore's explanation from his great answer):
convert \
-verbose \
-density 150 \
-trim \
<your-PDF-file>.pdf \
-quality 100 \
-flatten \
-sharpen 0x1.0 \
page%d.{png,pdf}
It results in the left image. Compare this to the result of my original command (the image on the right):
(To really see and appreciate the differences between the two, right-click on each and select "Open Image in New Tab...".)
Also keep the following facts in mind:
- The worse, blurry image on the right has a file size of 1.941.702 Bytes (1.85 MByte). Its resolution is 3060x3960 pixels, using 16-bit RGB color space.
- The better, sharp image on the left has a file size of 337.879 Bytes (330 kByte). Its resolution is 758x996 pixels, using 8-bit Gray color space.
So, no need to resize; add the -density
flag. The density value 150 is weird -- trying a range of values results in a worse looking image in both directions!