# Convert Pdf to multi images (png,jpg)

i use Texmarker 5.0.3 Can i convert main.pdf to multi images (each page = one image)?

Example code:

\documentclass[11pt]{article}
\usepackage{blindtext}
%\usepackage{tikz}
\usepackage{tcolorbox}

\begin{document}

\blindtext

\begin{tcolorbox}[width=\textwidth,height=5cm]

ABC DEF

\end{tcolorbox}

\blindtext

\newpage
\clearpage
\blindtext

\begin{tcolorbox}[width=\textwidth,height=5cm]

XXX YYY

\end{tcolorbox}
\blindtext

\end{document}


In the (complete) TeXLive distribution there is an interesting utility called pdftoppm that can convert PDF to PNG whith some options (e.g., on my Windows machine C:\texlive\2018\bin\win32\pdftoppm.exe). The undeniable advantage is that there is no need to install anything.

Running cmd with pdftoppm -help, you get the following output that informs how the utility works:

Therefore, it suffices to write, e.g.,

C:\path\to\my\PDFfile pdftoppm -f 1 -l 2 -r 300 -png Name_Of_My.pdf My_Images

to convert your two pages PDF-output generated by LaTeX (Name_Of_My.pdf) to separate image files My_Images-1.png and My_Images-2.png, where the prefix name (My_Images) of generated PNG files comes from the last part of the command line above.

The PNG output from your MWE above follows...

If I understand correctly, the PDF->image step is not done by LaTeX, but by an external call to convert (part of ImageMagick suite). So maybe this is off-topic, but...

Basically, once you have installed it, you should be able to use this command (at least in Linux, I think it will be the same in other OSs):

 convert -density 300 -background white -alpha remove -alpha off pdf-file.pdf page.png


and you'll have your pages at 300 dpi, named page-0.png, page-1.png and so on.

Notice that the latest convert can have problems. Be sure to read https://stackoverflow.com/questions/42928765/convertnot-authorized-aaaa-error-constitute-c-readimage-453 and https://github.com/ImageMagick/ImageMagick/issues/396 and then if you have errors edit your /etc/ImageMagick-6/policy.xml to say:

  <policy domain="resource" name="memory" value="4GiB"/>
<policy domain="resource" name="map" value="4GiB"/>
<policy domain="resource" name="width" value="128KP"/>
<policy domain="resource" name="height" value="128KP"/>
<policy domain="resource" name="area" value="1.28GP"/>
<policy domain="resource" name="disk" value="8GiB"/>


(In the original files, the rights were none and the limits much lower, which will hinder execution for a medium-size PDF file.