NullPointerException on your mailing label examples

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for Java (v4.x)  /  Display Thread

DynamicPDF Merger for Java (v4.x) Forum

Hi there,

I found you guys today and want to try our your JAR file for DynamicPDF example and code.  I follow this to about 90%.

http://java.cete.com/DynamicPDFv60/SourceView?class=MailingLabels

The only thing that's different is that I'm not using SQL Server to pull in the data.  I basically took out line 72-93 and line 99 from your example and added my own to generated "page".  (I replaced Line 72-93 with my own Java code to populate the data).  In debug mode, I see all the data are being generated all nicely in "page". but I'm getting a NullPointerException when it came to line 98. Here's the error I'm getting:

java.lang.NullPointerException
        at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:109)
        at com.cete.dynamicpdf.Document.a(Unknown Source)
        at com.cete.dynamicpdf.Document.drawToWeb(Unknown Source)
        
Any ideas on why this might be?  I got your JAR file/package today from your website.
By the way, I added this line above document.drawToWeb(req, rep, sOut, "MailingLabels.pdf");

int pages_num=document.getPages().size();

I wanted to see if perhaps "document" isn't getting any data but pages_num gives me 42.  So it isn't that the document is null.  It is something else.  I don't know what.  Any ideas?  Thank you for your assistance!
Posted by a ceTe Software moderator
Hello,

Can you please send over the code you are using and the input PDF document if you are using any to our support team at: support@cete.com? Also tell us the exact product version of DynamicPDF for Java product which you are using in your application. This information will help our support team to look into it further.

Thanks,
ceTe Software Support Team.
Posted by a ceTe Software moderator
Hello,

This error could be caused if the output stream is not retrieved before passing it as a parameter to drawToWeb method.

sOut = res.getOutputStream();
document.drawToWeb(req, res, sOut, "MailingLabels.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 9:40 AM.