Ghostscript PDF combine file limit?

huangapple go评论47阅读模式
英文:

Ghostscript PDF combine file limit?

问题

在上面的示例中,我正在合并3个文件。是否有可以同时合并的文件数量限制?

英文:

If I have a bat file on windows to drive ghostscript PDF combine like:

C:\Program Files (x86)\GPLGS>gswin32c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=c:\copyfolder\combine.pdf -dBATCH c:\copyfolder\AgentLetter.pdf c:\copyfolder\iso.pdf c:\copyfolder\disclosure.pdf

In the above example I am combining 3 files. Is there a limit to the number of files I can list to be combined ?

Thanks

I just tried a test combining 3 files and it works. Wondering if there is a limit on number of files I can combine at once ?

答案1

得分: 0

CLI编程的使用有时受到批评,但它是所有顶级机器操作系统代码的基础,就像运行Pythonic Wheels或PowerShell指令或抓取网页一样,目的是在一条指令中尽可能多地以编程方式执行,以便在计算机应用程序中实现模块化。

[Edit]
如KenS在评论中提到,可以使用@filelist(太长不读的内容在末尾),或者对于单个命令行用法,可以缩短总字符串长度。

在Windows上,CMD控制台的字符串长度是限制因素,因此尽量缩写编程命令。

传统上,你可以将可执行文件的名称重命名为与Unix相同,并使用新的-o选项进行输出,而不包括路径,可以进一步帮助缩短名称。

>gs -q -sDEVICE=pdfwrite -ocombine.pdf 01.pdf 02.pdf 03.pdf

示例

>gs.exe -q -sDEVICE=pdfwrite -ocombine.pdf 01.pdf 02.pdf 03.pdf

C:\Apps\PDF\GS\gs1000w64\bin>dir 0*.pdf
C:\Apps\PDF\GS\gs1000w64\bin目录
01/02/2023  19:23         2,821,328 01.pdf
01/02/2023  19:23         2,821,328 02.pdf
01/02/2023  19:23         2,821,328 03.pdf
               3个文件          8,463,984字节

C:\Apps\PDF\GS\gs1000w64\bin>dir co*.pdf
C:\Apps\PDF\GS\gs1000w64\bin目录
17/02/2023  16:32         2,831,780 combine.pdf

令人惊讶的是,27页的文件与9页中的任何一个文件几乎一样大,但我欺骗了,它们是相同的文件,因此使用相同的字体。

如果字符串长度真的是个问题,GS不需要.pdf,只需要.p,但为了Windows的缘故,请至少使用一个字母作为扩展名。

C:\bin>gs -q -sDEVICE=pdfwrite -oALL.pdf 01.p 02.p 03.p

使用

"path\gswin##c.exe" "path to\@filesmerge.txt"

将命令作为程序指令垂直串联在一起,但任何带有空格的文件名都需要用引号括起来。

filesmerge.txt

-sDEVICE=pdfwrite
-oALL.pdf
"C:\Any where with\a long name.pdf"
C:\Data\somewhere\blank.pdf
"C:\Data\some where\c me c you.pdf"
"C:\Data\some where else\done.pdf"

你可以混合和匹配,所以如果只列出要合并的文件名,你可以运行

"C:\Apps\PDF\GS\gs1000w64\bin\gswin64c.exe" -sDEVICE=pdfwrite -o"c:\data\all my.pdf" "@C:\source folder\filenames.txt"
英文:

The use of CLI programming is sometimes discouraged but is the basis of all top level machine OS code just same as running Pythonic Wheels or powershell instructions or scraping web pages, the aim is to do as much programatically in one line of instruction so as to be modular in computer applications.

[Edit]
As mentioned by KenS in comment use a @filelist (TL;DR its at the end) or for single command line usage you can shorten the total string length.

You will find on Windows it is the string length of a CMD console is the limit so abbreviate the programming commands as much as possible

traditionally you could rename the exe to same as Unix and use newer -o for output and keep names short without paths would go further to help

>gs -q -sDEVICE=pdfwrite -ocombine.pdf 01.pdf 02.pdf 03.pdf

example

>gs.exe -q -sDEVICE=pdfwrite -ocombine.pdf 01.pdf 02.pdf 03.pdf

C:\Apps\PDF\GS\gs1000w64\bin>dir 0*.pdf
 Directory of C:\Apps\PDF\GS\gs1000w64\bin
01/02/2023  19:23         2,821,328 01.pdf
01/02/2023  19:23         2,821,328 02.pdf
01/02/2023  19:23         2,821,328 03.pdf
               3 File(s)      8,463,984 bytes

C:\Apps\PDF\GS\gs1000w64\bin>dir co*.pdf
 Directory of C:\Apps\PDF\GS\gs1000w64\bin
17/02/2023  16:32         2,831,780 combine.pdf

amazing the 27 page file is not much bigger than 1 of 9 pages, but I cheated they are the same file, thus same fonts.

if really string is an issue GS does not need .pdf simply .p will do but for windows sake use at least one letter as extension.

C:\bin>gs -q -sDEVICE=pdfwrite -oALL.pdf 01.p 02.p 03.p

using

"path\gswin##c.exe" "path to\@filesmerge.txt"

commands as program instructions are strung out vertically but any filename with spaces needs "quot ing"

filesmerge.txt

-sDEVICE=pdfwrite
-oALL.pdf
"C:\Any where with\a long name.pdf"
C:\Data\somewhere\blank.pdf
"C:\Data\some where\c me c you.pdf"
"C:\Data\some where else\done.pdf"

You can mix and match so if just the filesnames to merge are listed you can run

"C:\Apps\PDF\GS\gs1000w64\bin\gswin64c.exe" -sDEVICE=pdfwrite -o"c:\data\all my.pdf" "@C:\source folder\filenames.txt"

huangapple
  • 本文由 发表于 2023年2月17日 23:54:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486513.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定