Saturday, October 8, 2022

[SOLVED] How to convert a folder of images from .pdf to .png?

Issue

I have a folder of pdf files(~ 1600 images). I want to convert all .pdf images into .png images. How can I do it?

I tried:

find . -maxdepth 1 -type f -name '*.pdf' -exec pdftoppm -r 300 -png {} {} ;

But have errors like:

Syntax Error: non-embedded font using identity encoding: Arial
Syntax Error: non-embedded font using identity encoding: Arial,Bold
Syntax Error: Can't get Fields array<0a>
Syntax Warning: Mismatch between font type and embedded font file
Syntax Error: Expected the optional content group list, but wasn't able to find it, or it isn't an Array

Is there any other solution for conversion?


Solution

You can use ImageMagick to convert a png to a pdf

convert input.pdf -density 300 -alpha remove output.png        

Here:

  • the -density 300 sets the DPI resolution to 300
  • the -alpha remove makes it so the PDF file is not see through (an issue that can often, but not always happen)

You can use this to do something like this

find . -maxdepth 1 -type f -name '*.pdf' -exec convert {} -density 300 -alpha remove {}.png \;  

Notice that the output filename will be somefile.pdf.png this way thou.



Answered By - Christina Sørensen
Answer Checked By - Willingham (WPSolving Volunteer)