【问题标题】:Split PDF by page with itextsharp in powershell在powershell中使用itextsharp按页拆分PDF
【发布时间】:2019-01-26 02:06:43
【问题描述】:

我一直在使用 itextsharp 和 ghostscript 处理一些 PDF。到目前为止,我已经设法让它在 ghostscript 拆分 pdf 的地方工作,然后 itextsharp 读取文件,以便 powershell 可以根据在 pdf 中找到的单词重命名它们,然后使用 ghostscript 将它们转换为 tiff。凉爽的。但我想结合一些步骤,特别是我想使用 itextsharp 来拆分,也许可以同时读取。

但是我还没有找到任何我能真正理解的关于在 powershell 中使用 itextsharp 按页面拆分的注释。我已经在 C 中看到了一些步骤,例如 Split PDF into multiple PDFs using iTextsharp 来执行此操作,但我不确定如何将其转换为在 powershell 中工作。另外我不认为powershell有splitandsave功能。

【问题讨论】:

  • 您没有说出或展示您尝试过的内容以及遇到的错误。

标签: powershell pdf itext


【解决方案1】:

您必须将 itextsharp 添加到您的脚本/函数中才能使用它,就像使用其他 dll/C#/C/C++ 代码块一样,使用 Add-Type cmdlet....

# Load itextsharp
Add-Type -Path .\itextsharp.dll

# Instantiate the PDF object
$reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList "$pwd\test.pdf"

# Your parsing / splitting code goes here

【讨论】:

    猜你喜欢
    • 2013-09-16
    • 2016-05-20
    • 1970-01-01
    • 2011-10-23
    • 2017-02-13
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多