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

Free Support Forum - aspose.com

Setting Page Size and Orientation

Hi, I am using the script below to convert an HTML file to a .DOC document. I would like to ensure that the .DOC page is size A3 (11.7" x 16.5") and that the orientation is set to Landscape. Could you please tell me exactly what lines I need to add to achieve this. Sorry for the simple question but the online documentation only seems to cover how to do this when using the builder method.

------------------------------------------Test.java----------------------------------------

import com.aspose.words.Document;

public class Test
{
public static void main(String args[])
{

try
{
com.aspose.words.License license = new com.aspose.words.License();
license.setLicense("Aspose.Words.lic");

Document doc = new Document("C:\\JavaTest\\Test.html");
doc.save("C:\\JavaTest\\Test.doc");
}
catch (Exception e)
{
e.printStackTrace();
}

}
}
------------------------------------------Test.java----------------------------------------

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

Thanks for your inquiry. Please try using the following code:

Document doc = new Document("C:\\JavaTest\\Test.html");

for (int sectIndex = 0; sectIndex < doc.getSections().getCount(); sectIndex++)

{

PageSetup ps = doc.getSections().get(sectIndex).getPageSetup();

ps.setPaperSize(PaperSize.A3);

ps.setOrientation(Orientation.LANDSCAPE);

}

doc.save("C:\\JavaTest\\Test.doc");

Hope this helps.

Best regards.

Hi Alexey, thanks heaps! That did the trick.

But just a note for people following this forum, I did have to change the line:

import com.aspose.words.Document;

to

import com.aspose.words.*;

Thanks again