Page 1 of 1

Copying header from one docx to another

PostPosted: Tue Oct 28, 2014 7:16 am
by vtikariha
Hi,

I am a new user of docx4j and currently exploring it. I tried to copy header from a docx file to another docx file. The header in the source file contained image as well.
The header from source file was copied to target file but with following issues:
1) image was not copied to the target file. Although the header in target file displayed "image cannot be displayed" in the place of actual image.
2) The formatting of text within header in the target file was not exactly same as source file.

Please advise what i am missing or doing wrong?
i have attached the code along with the source and target files.

Re: Copying header from one docx to another

PostPosted: Tue Oct 28, 2014 6:59 pm
by jason
you'd need to copy the image part as well. in general, the tree of parts referenced from the header need to be copied.

if the formatting is different, it may be because the target document has different styles and/or settings (eg page size or margins)