How can I create document from byte[] in iTextSharp

折月煮酒 提交于 2019-12-11 08:06:24

问题


I'm looking for way to load an iTextSharp document from byte[] representing a PDF.


回答1:


If b is a byte[] that represents a valid PDF file, then you can load the PDF into iTextSharp like this:

PdfReader reader = new PdfReader(b);

Now you can do all sorts of things with the reader object, such as copy pages using the PdfCopy class, stamp content on the PDF using PdfStamper, and so on.

Read Chapter 6 of my book to find out what you can (or can't) do with the PdfReader object. You'll need the full book if you want to extract text from the PDF. You should abandon hope if you assume that PDF is a format that is similar to Word.

All in all, your question is very broad. It isn't clear what you are asking. What do you mean by "load into an iTextSharp document"? If you are referring to the Document object, your question may be wrong as you typically won't use the Document object when manipulating existing PDFs, but you'll read all about that in the free chapter of my book.



来源:https://stackoverflow.com/questions/29127938/how-can-i-create-document-from-byte-in-itextsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!