Page 1 of 1

how to gernerate word document from html

PostPosted: Sun Aug 14, 2011 8:42 pm
by ykumarreddy
Hi I am kumar and new docx4j. I need to generate document from html content. html my contain image tags also. Is it possible to generate document using docx4j libraries. I tried CreateWordprocessingMLDocument class, but is asking customparts.xml file. Could you please provide the path of this xml file or suggest me how write the xml.

I have generated sample document using docx "helloworld" but I am not able to open the same in word 2003. It is saying file is courted.

Could you please suggest me steps which I need to follow.

Thanks for your help.

Kumar

Re: how to gernerate word document from html

PostPosted: Sun Aug 14, 2011 8:56 pm
by jason
ykumarreddy wrote:I need to generate document from html content. html my contain image tags also. Is it possible to generate document using docx4j libraries.


docx4j currently can't do this for you automatically.

If your users will always be opening the docx with Word 2007 or 2010, you can "cheat" by using an AlternativeFormatInputPart aka altChunk. CreateWordprocessingMLDocument in svn shows you how to do this.

If not, you've got some work to do ... start by learning to add paragraphs and images to a docx using docx4j.

ykumarreddy wrote:I tried CreateWordprocessingMLDocument class, but is asking customparts.xml file. Could you please provide the path of this xml file or suggest me how write the xml.


CreateWordprocessingMLDocument current svn head has an injectDocPropsCustomPart method, but it isn't called.

ykumarreddy wrote:I have generated sample document using docx "helloworld" but I am not able to open the same in word 2003. It is saying file is courted.


Word 2003 doesn't support the docx format unless you install the Compatibility Pack. See http://office.microsoft.com/en-us/word- ... 44473.aspx

Re: how to gernerate word document from html

PostPosted: Mon Aug 15, 2011 3:46 am
by ykumarreddy
HI Jason,

i tried CreateWordprocessingMLDocument, but it is looking "/tmp/custompart.xml". I didn't know where it is located. Could you please let me know from where I need to download xml file or suggest me what content I need write in this xml file.

Thasnk for your help.

Regards,
Kumar

Re: how to gernerate word document from html

PostPosted: Mon Aug 15, 2011 10:13 am
by jason
Suggest you read the source code for CreateWordprocessingMLDocument, and understand it to the extent necessary to comment that bit out. It is just a demonstration of how you inject a DocPropsCustomPart into your document, and the class ought to work perfectly well without it.