使用powershell我需要循环一系列pdf文件并使用pdftk对它们进行一些操作。我想知道是否存在某种方法来检测 pdf 是否加密。这样,如果 pdf 被加密,我就不会对其进行处理,并且我的循环会跳到下一个文件。感谢您的关注。
编辑。当我等待答案时,我发现 itextsharp 有一个 isencrypted 方法。
加载程序集后
[System.Reflection.Assembly]::LoadFrom("c:\my_path\itextsharp.dll")
我需要做什么才能使用上述方法?
最佳答案
[System.Reflection.Assembly]::LoadFrom("c:\itext\itextsharp.dll")
$itext = new-object itextsharp.text.pdf.PdfReader("c:\itext\1.pdf")
$itext.isEncrypted()
结果应该是 true 或 false。
关于pdf - powershell - 检查pdf是否加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3742584/