Hi,
I am trying to set the page size and height of a pdf document but aspose always create the pdf document with same size. Here is the code.
com.aspose.pdf.Document pdfDocument = new Document();
pdfDocument.getPages().add();
pdfDocument.getPageInfo().setHeight(50);
pdfDocument.getPageInfo().setWidth(50);
pdfDocument.save(“c:/documents/testdata/size.pdf”);
Can you please let me know if there is any way through which I can set the page size in aspose.
Thanks
Rajeev Mathur
Hi Rajeev,
com.aspose.pdf.Document pdfDocument = new Document();<o:p></o:p>
Page page=pdfDocument.getPages().add();
pdfDocument.getPageInfo().setHeight(200);
pdfDocument.getPageInfo().setWidth(200);
TextFragment text= new TextFragment("test");
page.getParagraphs().add(text);
pdfDocument.save(myDir+"size_java.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
Hi,
I am creating a pdf from an existing document and I need to change the size of the pdf document. I tried the below code and it does not work.
com.aspose.pdf.Document pdfDocument = new Document(“C:/test.pdf”);
pdfDocument.getPageInfo().setHeight(200);
pdfDocument.getPageInfo().setWidth(200);
pdfDocument.save(myDir+“size_java.pdf”);
Can you please let me know if I am doing anything wrong or if there is an alternative for this.
Thanks
Rajeev Mathur
Hi Rajeev,
com.aspose.pdf.Document pdfDocument =
new Document(“test.pdf”);<o:p></o:p>
//pdfDocument.getPageInfo().setHeight(200);
//pdfDocument.getPageInfo().setWidth(200);
Page page=pdfDocument.getPages().get_Item(1);
page.setPageSize(200, 200);
pdfDocument.save("size_java.pdf");