Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ItextSharp PDFCopy throwing null reference exception

Tags:

itext

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!

like image 756
Bcbury Avatar asked Dec 15 '25 19:12

Bcbury


1 Answers

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.

like image 56
Exulted Avatar answered Dec 17 '25 23:12

Exulted



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!