iTextSharp的"该文件有没有页" [英] iTextSharp "The document has no pages."

查看:456
本文介绍了iTextSharp的"该文件有没有页"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using iTextSharp to update A PDF's file properties:

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的。任何帮助表示赞赏。

I'm getting a "The document has no pages." error from iTextSharp. Any help appreciated.

推荐答案

您还没有添加任何的信息,将在页面上... !!

You haven't added any information to put on a page ... !!

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



...例如。

... for example.

你的标题等是文档属性(而不是东西是印到PDF)的一部分

Your title etc are part of the document properties (rather than something that's "printed" to the pdf).

看看这个的介绍性的例子,这似乎掩盖你以后。

Check out this introductory example, that seems to cover what you're after.

这篇关于iTextSharp的"该文件有没有页"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆