Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

add page from a source PDF document

$
0
0
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)


Viewing all articles
Browse latest Browse all 3131

Trending Articles