首页 新闻 会员 周边 捐助

PDFBox对文档进行属性设置.

0
悬赏园豆:30 [已关闭问题]
<table style="height: 100%;" border="0" cellspacing="0"> <tbody> <tr> <td id="Topic_Body" class="content">各位coder, <br /><br />最近几日,我一直忙于使用一款PDF类库进行PDF的API编程,当我最终把目标锁定在了PDFBox上的时候,(原因是其它几个iTextSharp,ShartPDF都不具有相应的或足够全的方法)终于发现它有我需要的东西.可是当代码测试过程发现,它对PDF的操作也只是样子货,难道是空方法?完全不起任何作用,到底是代码有问题还是PDF设置有问题抑或是我对PDF不了解?代码如下,望各位指点: <br /><br /><br />public PDDocumentInformation&nbsp; SetProper(string Author, string Title, string Keyword) <br />&nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Author = ""; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Title = ""; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Keyword = ""; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PDDocumentInformation Info = new PDDocumentInformation(); <br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Info.setAuthor(Author); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Info.setTitle(Title); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Info.setKeywords(Keyword); <br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return Info; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; } <br /><br />public void OpenPDF(string pdfFile) <br />&nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PDDocument myPdf = PDDocument.load(pdfFile); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myPdf.setDocumentInformation(SetProper("wr","df","fsd")); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myPdf.close(); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; } <br />string[] filename; <br />private void button1_Click(object sender, EventArgs e) <br />&nbsp; &nbsp; &nbsp; &nbsp; { <br />if (openFileDialog1.ShowDialog() == DialogResult.OK) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filename = openFileDialog1.FileNames; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; filename.Length ; i++) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; filename[i] = openFileDialog1.FileNames[i]; <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; method.OpenPDF(filename[i]); <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; } <br /></td> </tr> <tr> <td class="modify">&nbsp;</td> </tr> <tr> <td class="file">&nbsp;</td> </tr> </tbody> </table>
问题补充: PDFBox或是iTextSharp也类库也行,主要是考虑PDFBox对中文的支持可能好一些.
稻草人的主页 稻草人 | 初学一级 | 园豆:83
提问于:2008-12-09 17:56
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册