【问题标题】:Quickly append (merge) a PDF document onto 50,000 other documents快速将 PDF 文档附加(合并)到 50,000 个其他文档中
【发布时间】:2019-04-17 14:48:39
【问题描述】:

我们每月有 50,000 份文档,需要在文档末尾附加一个不同的 pdf。

我有一个 powershell 脚本,它遍历 50,000 个列表并调用 PDFtk 来合并它们。但即使在具有高 RAM 的机器上,这也需要很多小时。

代码的核心是这样的:

foreach ($pdf in $filelist){
  <#Get all variables#>
  ...
  $merge = '"' + $TKPath + '" "' + $FirstPDFPath + '" "' + $SecondPDFPath + '" cat output "' + $OutputPDFPath + '"'
  cmd.exe /c $merge
}

这是 PDFtk 的问题吗?还是我在循环内调用cmd.exe /c 引起了问题?我可以不以某种方式调用 PDFtk 吗?我从来没有让它工作过。

【问题讨论】:

    标签: powershell pdf cmd merge pdftk


    【解决方案1】:

    启动 50K cmd.exe 进程肯定会带来一些开销。

    您可以尝试使用 &amp; 调用运算符直接从 powershell 调用 pdftk

    & $TKPath $FirstPDFPath $SecondPDFPath cat output $OutputPDFPath
    

    【讨论】:

    • 这稍微加快了速度,但它仍然多次打开 PDFtk。看来我们需要一个新的软件解决方案。
    猜你喜欢
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 2018-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-28
    • 1970-01-01
    相关资源
    最近更新 更多