mathinvalidnik
mathinvalidnik

Reputation: 1600

How can I create document from byte[] in iTextSharp

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

Upvotes: 1

Views: 2735

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

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.

Upvotes: 1

Related Questions