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?
CodePudding user response:
You can use ImageMagick to convert a png to a pdf
convert input.pdf -density 300 -alpha remove output.png
Here:
- the
-density 300sets the DPI resolution to 300 - the
-alpha removemakes 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.
CodePudding user response:
You can create PNG versions of all PDFs in the current directory with ImageMagick like this:
magick mogrify -density 300 -format PNG *.pdf
If you want the output files in a sub-directory called OUTPUT, use:
mkdir OUTPUT
magick mogrify -path OUTPUT -density 300 -format PNG *.pdf
As you have 1600 PDFs, you might consider using GNU Parallel to do them in parallel for you:
parallel magick {} -density 300 {.}.png ::: *.pdf
