将Ghostscript PDF转换为PNG:输出始终为595x842(A4) [英] Ghostscript PDF to PNG: output is always 595x842 (A4)

查看:183
本文介绍了将Ghostscript PDF转换为PNG:输出始终为595x842(A4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将PDF转换为PNG,但是输出图像始终为A4,但是源PDF很大.这是我的命令:

I try to convert PDF to PNG, but ouput image is always A4, however the source PDF is very huge. Here are my commands:

-dNOPAUSE ^
-dBATCH ^
-dSAFER ^
-sDEVICE=png16m ^
-dFirstPage=1 ^
-sOutputFile="D:\PDF.png" ^
 "D:\PDF.pdf" ^
-sPAPERSIZE=a1

我尝试了几个选项(-r,-g,-sDEFAULTPAPERSIZE),但没有一个起作用.

I tried several options (-r, -g, -sDEFAULTPAPERSIZE), but none worked.

如何强制输出图像尺寸?

How can I force the output image dimensions?

P.S:我的 PDF文件

推荐答案

您链接到的PDF文件只有一页.这意味着您的命令行参数-dFirstPage=1没有任何影响.

Your linked-to PDF file has only 1 page. That means your commandline parameter -dFirstPage=1 doesn't have any influence.

此外,您的-sPAPERSIZE=a1参数不应排在最后(此处没有任何影响-因此Ghostscript从输入PDF的页面大小(即A4)中获取默认大小).相反,它应该出现在"D:\PDF.pdf"之前(必须在最后).

Also, your -sPAPERSIZE=a1 parameter should not be last (it doesn't have any influence here -- so Ghostscript takes the default size from the pagesize of the input PDF, which is A4). Instead it should appear somewhere before the "D:\PDF.pdf" (which must be last).

您似乎想要一个A1大小的PNG,而您的操作系统是Windows(从您提供的部分命令行进行猜测)?

It looks like you want a PNG with the size of A1, and your OS is Windows (guessing from the partial commandline you provided)?

试试看(它在命令行中添加了-dPDFFitPage=true并将参数设置为正确的顺序,同时还使用了-o技巧将其缩短了一点):

Try this instead (it adds -dPDFFitPage=true to the commandline and puts the arguments into a correct order, while also shortening it a bit using the -o trick):

gswin32c.exe ^
  -o "D:\PDF.png ^
  -sDEVICE=png16m ^
  -sPAPERSIZE=a1 ^
  -dPDFFitPage=true ^
   "D:\PDF.pdf"

这应为您提供72dpi时尺寸为1684x2384像素的PNG(这是所有Ghostscript图像输出的内置默认值,如果未指定其他分辨率,则使用该默认值).对于分辨率和页面大小的不同组合,请添加您的-rXXX-gNNNxMMM的变体(而不是-sPAPERSIZE=a1),但请务必保留-dPDFFitPage=true ....

This should give you a PNG with the size of 1684x2384 pixel at 72dpi (which is the builtin default for all Ghostscript image output, used if no other resolution is specified). For different combinations of resolution and pagesize add your variation of -rXXX and -gNNNxMMM (instead of -sPAPERSIZE=a1) but by all means keep the -dPDFFitPage=true....

如果只想使用其他分辨率,也可以保留-sPAPERSIZE=a1并添加-r100-r36-r200.请注意,与默认输出72dpi相比,提高分辨率可能不会改善图像质量.这取决于嵌入在PDF页面中的图像的分辨率.但这肯定会增加文件大小...

You can also keep the -sPAPERSIZE=a1 and add -r100 or -r36 or -r200 if you want a different resolution only. Be aware that increasing resolution may not improve the image quality compared to the default output of 72dpi. That depends on the resolution of the images that were embedded in the PDF page. But it surely increases the file size...

这篇关于将Ghostscript PDF转换为PNG:输出始终为595x842(A4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆