Page 1 of 1

To get the html page orientation using docx4j

PostPosted: Fri Mar 20, 2015 1:09 am
by Raghavendra jammi
Hi all iam trying to convert html to docx using Docx4j. I want to set the docx page orientation depending on the html page orientation, i.e if html is in landscape mode i want the converted docx to be landscape mode. Can any one help me how i can achieve this.
Iam able to set the converted docx orientation to landscape by using the below code:

PageDimensions page = new PageDimensions();
page.setPgSize(PageSizePaper.valueOf(ActorsConstants.PAGE_SIZE), true);

Re: To get the html page orientation using docx4j

PostPosted: Fri Mar 20, 2015 6:09 pm
by jason
Apparently xhtmlrenderer parses the relevant information:

${fs} supports the @@page@
rule, which means that page size, page margins and page break controls are
all supported for PDF output.


However docx4j-ImportXHTML doesn't attempt to use it.

If we were to add this, you'd compare the XHTML page to the current docx page, and if different, insert suitable sectPr before (cloning existing sectPr setting) and after (based on the XHTML page values) the converted XHTML.

Re: To get the html page orientation using docx4j

PostPosted: Fri Mar 20, 2015 10:44 pm
by Raghavendra jammi
Hi Jason, thanks for your valuable time. All i want is to use some property to get the page orientation(i.e. portrait or landscape) of HTML file. Sorry to say this but i couldn't understand the solution give by you. Kindly elaborate a bit more please.

Thanks,
Raghav