We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Add page from a source PDF document

Am creating a new pdf.Document and adding a page from a second pdf document. Any suggestions? The code is using the evaluation version 4.5.1 aspose-pdf.jar. thanks

the following code works on Windows 8. It errors on Ubuntu 12.04 server.

InputStream fileinputStream = new FileInputStream(new File(pdfPath));
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(fileinputStream);
com.aspose.pdf.Page pdfPage = pdfDocument.getPages().get_Item(1);
com.aspose.pdf.Document newDocument = new com.aspose.pdf.Document();
newDocument.getPages().add(pdfPage);
newDocument.save(destinationPath);

on newDocument.save(destinationPath) getting this error:

Exception in thread "main" java.lang.NullPointerException
at com.aspose.g.h.a(Unknown Source)
at com.aspose.pdf.ADocument.preSave(Unknown Source)
at com.aspose.pdf.ADocument.saveInternal(Unknown Source)
at com.aspose.pdf.Document.saveInternal(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
at PDFConvert.main(PDFConvert.java:72)

Hi Michael,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for Java 4.5.1.0, We have noticed the exception is being raised if we do not implement a valid license. We have logged this issue in our bug tracking system as PDFNEWJAVA-34056 for further investigation and resolution.


Moreover, to avoid this issue you may request for 30 days temporary license to evaluate our product without any limitation and this exception. However, we will notify you via this thread as soon as exception issue is resolved.


Please feel free to contact us for any further assistance.

Best Regards,

ok, thanks for the prompt response.

The issues you have found earlier (filed as PDFNEWJAVA-34056) have been fixed in Aspose.Pdf for Java 11.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.