Converting a PDF to PNG

前端 未结 12 1881
一个人的身影
一个人的身影 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

    To convert pdf to image files use following commands:

    For PNG gs -sDEVICE=png16m -dTextAlphaBits=4 -r300 -o a.png a.pdf

    For JPG gs -sDEVICE=jpeg -dTextAlphaBits=4 -r300 -o a.jpg a.pdf

    If you have multiple pages add to name %03d gs -o a%03d.jpg a.pdf

    What each option means:

    • sDEVICE={jpeg,pngalpha,png16m...} - filetype
    • -o - output file (%stdout to stdout)
    • -dTextAlphaBits=4 - font antialiasing.
    • -r300 - 300 dpi

提交回复
热议问题