Page 1 of 1

Question about merging docx files - MergeDocx

PostPosted: Wed Jun 10, 2015 8:18 pm
by Florian
Hi

I would like to create docx template files by merging 3 source docx files into one output file. One of the source documents shall contain the header, one the footer and one all the content.
What would you recommend is the best way to realize this?

I read about the MergeDocx plugin which apparently is able to do this. I tried the online webapp with 3 differente files, one contained the header, one the footer and one the content but I never got an output file that contained everything in the right way. Best I got from trying all the different settings was a document with the header and content on the first page but the footer just started on page two... am I doing something wrong or is this simply not possible? Hope I explained it well enough to understand the problem...

If it's possible to realize merging separate header, content and footer docx files with MergeDocx, the company I work for is happy to purchase it.

Cheers
Florian

Re: Question about merging docx files - MergeDocx

PostPosted: Wed Jun 10, 2015 9:53 pm
by jason
That's not how MergeDocx is intended to be used.

Do you want the same header and footer on each page?

Is the content source all in a single section?

If yes to both questions, you just have a sectPr element at the end of the content which specifies the header and footer parts.

Copying in the header and footer parts are simple (using plain vanilla docx4j), unless they refer to other parts (ie contain images, hyperlinks or the like). If they refer to other parts, you'll need to copy those in as well.

Also, if the header or footer uses styles or numbering, those definitions will need to be present.

At some point, it starts to get complicated, and then some of the machinery in MergeDocx is helpful...

Re: Question about merging docx files - MergeDocx

PostPosted: Thu Jun 11, 2015 1:25 am
by Florian
Thanks a lot for your answer Jason!

Yes I would like to have the same header and footer on each page in the output document. The content for both should just be taken from the two independent source files.
The header and footer both contain a table with information, the header a company logo image and the footer the Page numbers. I want to be able to change the content easily therefore my idea was to put them both in separate docx file so I can change the content independent from one another.

The main content will have several sections and chapters, including a table of content.

So I guess MergeDocx could be quite helpful for some cases?

Once again the idea I would like to implement in Java in case I didn't explain it well enough:
We have several docx source files, a header.docx, a footer.docx and one or more content.docx files and we would like to generate dynamically a template docx file out of these sources.
All the contents of the source files change quite often and we don't always want to create a whole new document manually but generate them dynamically

Do you think this is possible with docx4java?


Thanks for your help!
Florian

Re: Question about merging docx files - MergeDocx

PostPosted: Thu Jun 11, 2015 7:04 pm
by jason
If you want to use MergeDocx, the way to do that would be:

- first docx: contains both your header and footer; no other content

- second (and any subsequent documents): contain your contents, and use the header/footer from the first docx

If you don't want to use MergeDocx, then what you want to achieve is still quite do-able. When you add the header part, you'll have to add its image part as well.

Please note when I said "section" I meant sectPr. Headers/footers are declared in that element, and you can have multiple sections (in which case things get trickier).

Re: Question about merging docx files - MergeDocx

PostPosted: Wed Jun 17, 2015 9:42 pm
by Florian
Awesome, thanks for your help Jason!

One last question, is it possible to buy only the MergeDocx and not the whole Enterprise Version?
We would only need MergeDocx out of the Enterprise Version.

Thanks!

Florian

Re: Question about merging docx files - MergeDocx

PostPosted: Wed Jun 17, 2015 10:24 pm
by jason
Hi Florian

Sorry, not possible, I'm afraid.

cheers .. Jason