Page 1 of 1

question about attaching template

PostPosted: Sun Sep 28, 2014 9:06 pm
by pengppp11
Hi

I'm newly into docx4j and want to create docx from a existing word template like dotx , I want to ask maybe some stupid questions : )

I'm starting to follow the example "TemplateAttach.java". After excuting, the output "OUT_TemplateAttach.docx" is created. But if I have added some additional information like header or footer in the original dotx, those informations will be missed in the output docx, so what can I do, if i want to convert a dotx completely into a docx and also remain all the styles ?

Thank you very much

Re: question about attaching template

PostPosted: Sat Oct 04, 2014 1:41 pm
by jason
That sample:

1. creates a rel to a dotx file at some external physical path (assumed available when the docx is opened in Word)

2. sets corresponding w:attachedTemplate setting; see further http://webapp.docx4java.org/OnlineDemo/ ... plate.html

Copying any text from the template would be an extra step. Basically, you'd need to copy the content (part tree) across.

An easier approach is to load the dotx (clone if necessary), and change its content type. I've updated the sample to do that:

https://github.com/plutext/docx4j/blob/ ... ttach.java

Re: question about attaching template

PostPosted: Mon Oct 13, 2014 6:49 am
by pengppp11
jason wrote:That sample:

1. creates a rel to a dotx file at some external physical path (assumed available when the docx is opened in Word)

2. sets corresponding w:attachedTemplate setting; see further http://webapp.docx4java.org/OnlineDemo/ ... plate.html

Copying any text from the template would be an extra step. Basically, you'd need to copy the content (part tree) across.

An easier approach is to load the dotx (clone if necessary), and change its content type. I've updated the sample to do that:

https://github.com/plutext/docx4j/blob/ ... ttach.java


Thanks, jason. :D I have noticed the difference in their content type.