Page 1 of 1

xhtml to docx with customized styling and different headers

PostPosted: Fri Mar 11, 2022 9:00 pm
by mithilesh.jha
I Want to convert xhtml to docx . I want below customizations:
1 Default font size to set as 10.5pt
2 Default font family to be set as Frutiger 45 Light
3 Page size to be set as A4
Above points are are done from docx4j.properties file . But I want to put the docx4j.propties in some other directory(other than class path)
4. Set font family Frutiger 45 light(I have .ttf files)
4 Customized Margins--Done in the code
5 Header Spacing in Letter (different in 1st page and rest of the pages)
6 Advice No. in Header (2nd page onwards)
7 Footer(Footer text and page numbering(page x of y))---This is done
8 Reply form page number reset(separate html div is coming for reply form part)
9 Reply form Spacing (different in 1st page and rest of the pages)

@Jason Are above things possible using docx4j and xHTMLImporter ?

Re: xhtml to docx with customized styling and different head

PostPosted: Mon Mar 14, 2022 6:37 am
by jason
Everything is possible with docx4j, in the sense that if the file format can do it, docx4j can as well.

The trick is knowing how and where in your program flow to do it.

Skimming through your list, global font size/family (in the styles part - you can set this directly) will be effective provided it isn't overridden at the paragraph level. You'll have to look at the imported XHTML to see whether that is happening, and if it is, work around that.

Most of the other stuff seems to be header/footer related, which you can control with sectPr settings.

Please understand that it isn't realistic to expect a detailed response to a list of 10 questions like this at someone else's expense. It is always better to post separate questions, and include what you have tried and where it didn't work. And please don't cross post to StackOverflow. Post either here or there, but not both. I'll see the question whichever you choose...

Re: xhtml to docx with customized styling and different head

PostPosted: Mon Mar 14, 2022 2:40 pm
by mithilesh.jha
OK Thanks Jason . I will post here only with separate topics and whatever I have tried .