Free Support Forum - aspose.com

Setting the dimension of the PDF page to be generated

Hi

Can iset the dimensions of the PDF page to be generated from doc,docx,rtf etc via the Document or the PDFOptions objects. If yes, how? My code snippet is as follows:

public boolean convert(String fileName){

Document doc;

outputFileName = fileName+".pdf";

try {

doc=new Document(fileName, format , null);

PdfOptions options = new PdfOptions();

options.setHeadingsOutlineLevels(3);

options.setExpandedOutlineLevels(1);

doc.saveToPdf(0, 1, outputFileName, options);

} catch (Exception e) {

System.out.println("Exception occurred while file conversion to pdf.");

e.printStackTrace();

}

return false;

}

I am getting the PDF page with a standard size of

Height= 792.0 Width= 612.0 for all formats(doc, docx).

Hi

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

Thanks for your request. Aspose.Words uses the same page size as specified in MS Word document. Please see PageSetup:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.pagesetup.html

So in order to change paper size in the output PDF, you should loop through all Sections in MS Word document and change paper size of each Section. But you should note, in this case, layout of the document can be changed.

Best regards.