Here is my code to create the PDF (based on aspose sample) and PDF (1page) created no issue.
//Instantiate License class and call its SetLicense method to use the license
aspose.pdf.License lic = new aspose.pdf.License();
lic.setLicense(new FileInputStream(new File("C:/work2013/app/aspose/test/data/Aspose.Total.Java.lic")));
//Create PDF document
Pdf pdf1 = new Pdf();
//Add a section into the PDF document
Section sec1 = pdf1.getSections().add();
//Add a text paragraph into the section
sec1.getParagraphs().add(new Text("Hello World"));
pdf1.setPagesNumber(1);
//Save the document
pdf1.save("HelloWorld.pdf");
///////////////////////////////
Then to read the PDF (based on sample from ASPOSE)
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("HelloWorld.pdf");
com.aspose.pdf.DocumentInfo docInfo = pdfDocument.getInfo();
//show document information
System.out.printf("Author:-" + docInfo.getAuthor());
System.out.printf("\n Creation Date:-" + docInfo.getCreationDate());
System.out.printf("\n Keywords:-" + docInfo.getKeywords());
System.out.printf("\n Modify Date:-" + docInfo.getModDate());
System.out.printf("\n Subject:-" + docInfo.getSubject());
System.out.printf("\n Title:-" + docInfo.getTitle());
//get the page where image needs to be added
if(pdfDocument.getPages()!=null)
{
com.aspose.pdf.Page page = pdfDocument.getPages().get_Item(1);
// No issue until here with Java null exception
Exception in thread "main" java.lang.NullPointerException
at com.aspose.pdf.engine.d.a.e.a.a.a(Unknown Source)
at com.aspose.pdf.engine.d.a.e.a.c.b(Unknown Source)
at com.aspose.pdf.engine.d.a.e.a.d.a(Unknown Source)
at com.aspose.pdf.engine.d.a.e.a.c.a(Unknown Source)
at com.aspose.pdf.engine.d.a.e.a.f.b(Unknown Source)
at com.aspose.pdf.engine.d.a.e.a.k.a(Unknown Source)
at com.aspose.ms.System.d.c.a(Unknown Source)
at com.aspose.pdf.engine.d.a.e.a.a(Unknown Source)
at com.aspose.pdf.engine.data.types.PdfStreamAccessor.getDecodedData(Unknown Source)
at com.aspose.pdf.engine.commondata.d.a.o(Unknown Source)
at com.aspose.pdf.engine.commondata.d.a.(Unknown Source)
at com.aspose.pdf.engine.c.a.a(Unknown Source)
at com.aspose.pdf.engine.commondata.w.b(Unknown Source)
at com.aspose.pdf.Page.(Unknown Source)
at com.aspose.pdf.PageCollection.a(Unknown Source)
at com.aspose.pdf.PageCollection.get_Item(Unknown Source)
at BarcodeReaderTest.main(BarcodeReaderTest.java:98)
}
Why ASPOSE can't read the same PDF created by itself? Am I missing any setting to the call?
Tahnk you if anyone can answer my question. Thanks.