[英]convert png to pdf using ghostscript
正如標題所說,我正在嘗試將 png 轉換為 pdf。 我在任何地方都找不到關於此的描述良好的示例。
我用過這個命令
gs sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=test.pdf test.png
但我得到的只是
Error: /syntaxerror in (binary token, type=137)
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1894 1 3 %oparray_pop 1893 1 3 %oparray_pop 1877 1 3 %oparray_pop 1771 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push
Dictionary stack:
--dict:1161/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1
這個錯誤信息。 現在我開始懷疑在 ghostscript 中是否可以使用這種功能。 我應該使用其他軟件嗎? ** 我運行的是最新的 9.07 版本
Ghostscript 可以輸出多種格式(包括 png),但我不相信它能夠將 png 作為輸入。 不過,您可以使用類似 imagemagick 的convert
實用程序來實現您的目標: convert test.png test.pdf
是的,image magick 可以做到這一點沒有問題 - 這是循環遍歷文件夾中所有 png 並轉換為 pdf 的 cmd 行:
cd 到包含 png 的文件夾
mogrify -format pdf -density 300 -units PixelsPerInch *png
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.