我想在VB6/VB.NET程序中打开并查看受密码保护的PDF文件。我尝试过使用Acrobat PDF库,但无法做到。
我想创建一个受密码保护的PDF文件的原因是,我不希望在没有密码的情况下打开PDF文件,即在程序之外。
要打开受密码保护的PDF,您至少需要开发一个PDF解析器、解密器和生成器。不过我不建议你那样做。这绝非易事。
在PDF库的帮助下,一切都变得简单多了。您可能需要尝试使用Docotic.Pdf库来执行此任务。
这里有一个任务示例:
public static void unprotectPdf(string input, string output)
{
bool passwordProtected = PdfDocument.IsPasswordProtected(input);
if (passwordProtected)
{
string password = null; // retrieve the password somehow
using (PdfDocument doc = new PdfDocument(input, password))
{
// clear both passwords in order
// to produce unprotected document
doc.OwnerPassword = "";
doc.UserPassword = "";
doc.Save(output);
}
}
else
{
// no decryption is required
File.Copy(input, output, true);
}
}
Docotic.Pdf还可以从Pdf中提取文本(格式化或不格式化)。它可能对索引有用(我想这就是你所做的,因为你提到了Adobe IFilter)
您可以通过互联网将代码转换为vb