0

I am converting HTML Document into word document using Docx4j jar. finally i got the word document but i could not change the default properties. I have facing the following problems in Docx4j jar

How to set the custom page size of document using Docx4j properties other than default page size A4,A3, B4JIS?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118

1 Answers1

0

The constructor

XHTMLImporterImpl(WordprocessingMLPackage wordMLPackage)

specifies the docx into which your content will be imported. (I assume you're doing it that way; if you are using altChunk, what follows would still apply, unless Word adds a sectPr!)

It takes on the page size defined in that docx.

Page size is defined in the sectPr element, so more precisely, it takes on the page size of the applicable sectPr.

So, you can either change that, or add a new sectPr. Note: since a sectPr applies to the content before it, you should add a sectPr with the existing sectPr properties (or move the existing one), then your content, then a sectPr with the page size you want.

To generate relevant code, use the docx4j code generation tool, available via the docx4j webapp, or the code gen Word AddIn.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
  • Thanks for your answer. Please see my code [link](http://stackoverflow.com/questions/27356235/how-to-set-font-size-and-font-family-in-word-document-using-docx4j/27356387#27356387). In this code shall i set the font size or family? i am new to this so i have no clear idea about this. – Vijay Marudhachalam Dec 08 '14 at 11:14
  • one more issue i have piece of code in HTML In my location machine logo image is embedded in Word document but in Server machine image is not embedded in word pls help me... – Vijay Marudhachalam Dec 24 '14 at 12:44
  • Again, you should ask this new/different question as a new question. – JasonPlutext Dec 24 '14 at 20:47