Free Support Forum -

Aspose.PDF NullPointer in pdf.close


I am getting a null pointer while calling pdf.close()

at aspose.pdf.xml.Abt.a(SourceFile:895)
at aspose.pdf.Pdf.close(SourceFile:688)
at pdf.aspose.AsposeTest.main(

The source is attached.
What am I doing wrong? Or is this a bug?


Hello Praveen,

Thanks for using our products.

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFJAVA-28257. We will investigate this issue in details and will keep you updated on the status of a correction.

In fact there have been some issues in the code which I corrected but still the problem is occurring. Please note that during Direct to File save method, instead of using sec.getParagraphs().add(table); please try using sec.getParagraphs().addPara(table); and instead of row = table.getRows().add(); please try using table.getRows().addRow(row);

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have tried the scenario after updating the code but still the problem is occurring. We are really sorry for your inconvenience.

Hi Shahbaz,

Any update on this. I see the issue you logged (28257) has been marked as not a bug. If so, what is it that is wrong in the code?

thanks & regards

Hello Praveen,

Thanks for your patience.

We have further analyzed this problem and have observed that the problem was occurring because of invalid code snippet. Please try using the following code snippet as I am unable to notice any problem when using Aspose.Pdf for Java 2.9.0.

In case you still face any problem or you have any further query, please feel free to contact. We apologize for this inconvenience.


long end = 0;
long start = 0;

try {
System.out.println("Running with Aspose.PDF-2.9.0\n------------------------------------------------");
start = Calendar.getInstance().getTimeInMillis();
long MAX = 400;
System.out.println("Number of records: " + MAX);
BinaryFileStream bfs = new BinaryFileStream();

Pdf pdf = new Pdf(bfs);
Section sec = pdf.getSections().add();
Table table = new Table();
Row row = null;
Cell cell = null;

for (long i = 1; i <= MAX; i++)

System.out.print("Row " + i + " of " + MAX + " [" +((i*100)/MAX) + "%]\r");
row = new Row(table);
cell = row.getCells().add("cell - " + i);
cell.setBorder(new BorderInfo(BorderSide.All.getValue(), 0.5F));

// bfs.flush();
end = Calendar.getInstance().getTimeInMillis();
System.out.println("Time taken : " + ((end - start)/1000) + " sec - " + ((end - start)/60000) + " min");
System.out.println("Doucment generated....");

} catch (Exception e) {