简体   繁体   中英

How can I create document from byte[] in iTextSharp

我正在寻找从表示PDF的byte[]加载iTextSharp文档的方法。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM