Converting a PDF to PNG

前端 未结 12 1877
一个人的身影
一个人的身影 2020-11-27 09:58

I\'m trying to convert a PDF to a PNG image (at least the cover of one). I\'m successfully extracting the first page of the PDF with pdftk. I\'m using imagemagick to do the

12条回答
  •  春和景丽
    2020-11-27 10:24

    I'll add my solution, even thought his thread is old. Maybe this will help someone anyway.

    First, I need to generate the PDF. I use XeLaTeX for that:

    xelatex test.tex
    

    Now, ImageMagick and GraphicMagic both parse parameters from left to right, so the leftmost parameter, will be executed first. I ended up using this sequence for optimal processing:

    gm convert -trim -transparent white -background transparent -density 1200x1200 -resize 25% test.pdf test.png
    

    It gives nice graphics on transparent background, trimmed to what is actually on the page. The -density and -resize parameters, give a better granularity, and increase overall resolution.

    I suggest checking if the density can be decreased for you. It'll cut down converting time.

提交回复
热议问题