我试图插入一个图像到一个新创build的pdf文档使用iTextSharp – 虽然我不知道我正在去正确的方式。 我已经创build了一个图像对象,然后尝试将其添加到页面 – 但没有图像显示 – 虽然我插入的文本确实出现在pdf文档中。
有没有人有任何想法?
public bool createpdf(string batchNumber,string username,string path) { // step 1: creation of a document-object document mydocument = new document(PageSize.A4.Rotate()); try { // step 2: // Now create a writer that Listens to this doucment and writes the document to desired Stream. pdfWriter.GetInstance(mydocument,new fileStream(path,fileMode.Create)); // step 3: Open the document Now using mydocument.open(); // step 4: Now add some contents to the document // batch header eg Batch Sheet mydocument.Add(new Paragraph("Number: " + batchNumber)); mydocument.Add(new Paragraph("Created By: " + username)); iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("code39-barcode.png"); pdfPCell cell = new pdfPCell(logo); mydocument.Add(cell); } catch (documentException de) { Console.Error.Writeline(de.Message); } catch (IOException ioe) { Console.Error.Writeline(ioe.Message); } // step 5: Remember to close the document mydocument.Close(); return true; }
InvisibleOperationException隐藏窗口时
与SystemParametersInfo和布尔值pvParam参数混合
StringCollection编辑器不存储用户input的值
任何工具来分析wmv文件格式?
什么是程序终止自己的进程的正确方法(windows)
WPF RibbonWindow + Ribbon =标题外屏?
SSL支持Rabbit + .Net + windows
PrincipalContext.ValIDateCredentials在XP上始终使用Machine ContextType返回False
最好的C#桌面应用程序的安全框架?
STRING TO HEX如何添加一个向量ob字节?
阅读这个知道如何添加图像
不过,我想你错过了一些表。
你应该有一个表,并使用table.addCell添加单元格
pdfPtable table = new pdfPtable(3); pdfPCell cell = new pdfPCell(new Phrase("header spanning 3 columns"));
阅读这个知道如何使用表
删除这个:
pdfPCell cell = new pdfPCell(logo); mydocument.Add(cell);
并使用这个:
mydocument.Add(logo);
它的工作:)
总结以上是内存溢出为你收集整理的使用iTextSharp将图像插入到PDF中全部内容,希望文章能够帮你解决使用iTextSharp将图像插入到PDF中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)