3
votes

I'm attempting to merge 2 pdfs, (I'm following the examples in the iText in Action 2nd edition book) and I'm getting a null reference exception error when attempting to run this code:

MemoryStream stream = new MemoryStream();
document = new Document();
PdfCopy copy = new PdfCopy(document, stream);
document.Open();                                     //breakpoint here

The copy object has a null reference exception every time. I've been unable to find a simple answer to this anywhere else on this site. Thanks in advance!

1
Can you provide a stack trace? And which iTextSharp version to you use? - mkl
This was a problem in iTextSharp 5.3.4; it was fixed in iTextSharp 5.3.5. - Bruno Lowagie

1 Answers

2
votes

According to this question, you have to ignore this exception. I am getting the same exception in iTextSharp 5.5.2. By simply ignoring it, I am able to proceed in my code and copy pages into a new pdf file alright.