我正在使用 iTextSharp 更新 PDF 的文件属性:

FileStream fs = File.Open(@"C:\Developer\C#Projects\BylawSearch\0001.pdf", FileMode.Open);
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, fs);
document.Open();
document.AddSubject("Blah");
document.AddTitle("Blah blah");
document.AddKeywords("Blah blah blah");
document.Close();

我收到“文档没有页面”的提示。来自 iTextSharp 的错误。任何帮助表示赞赏。

最佳答案

你还没有添加任何信息放在页面上......!

document.Add(new Paragraph("Hello World!"));

... 例如。

您的标题等是文档属性的一部分(而不是“打印”到 pdf 的内容)。

看看这个 introductory example ,它似乎涵盖了你所追求的。

关于c# - iTextSharp "The document has no pages.",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19278623/

10-16 04:42