5

I read link: https://www.overleaf.com/blog/613-tip-of-the-week-how-to-convert-typeset-pdf-pages-into-raster-image-formats

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}

Thank in advance

3 Answers 3

10

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:

enter image description here

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...

enter image description here

8

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"/>

  <policy domain="coder" rights="read|write" pattern="PS" />
  <policy domain="coder" rights="read|write" pattern="EPS" />
  <policy domain="coder" rights="read|write" pattern="PDF" />
  <policy domain="coder" rights="read|write" pattern="XPS" />

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

1
0

I find pdftoppm (poppler tool) to be much more efficient than imagemagick/convert, with a better quality (when I set a too high quality with convert, it crashes). For instance, you can do:

pdftoppm -jpeg -r 300 -scale-to-x 1920 -scale-to-y 1080 yourfile.pdf output-prefix

and it will create many images like output-prefix-01.jpg, output-prefix-02.jpg… (the number of 0 is determined depending on the number of files)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .