Thread

Posted on Sat Dec 23 17:08:23 2006 by kjlassoc
combining or merging documents together?
I'm happily opening a template, manipulating the contents and saving it out as a number of new documents (odt). Now I want to combine a number of the resulting odt files into one single odt. The answer is probably staring me in the face but it isn't obvious how to do this. Any hints? Thanks Ken
Direct Responses: 3886 | Write a response
Posted on Sat Dec 23 19:54:56 2006 by jmgdoc in response to 3885
Re: combining or merging documents together?
It's possible to include one or more documents as sub-documents through sections. See appendSection() in the OpenOffice::OODoc::Text manual page.
Direct Responses: 3974 | Write a response
Posted on Thu Jan 4 17:05:25 2007 by kjlassoc in response to 3886
Re: combining or merging documents together?
Thanks for your kind reply. I'm able to add sub-documents as you indicated with AppendSection and links. One more question...is there a way to do this by actually inserting the content of the sub-document into the master document (i.e. not as a link)?
Direct Responses: 3975 | Write a response
Posted on Thu Jan 4 19:21:56 2007 by jmgdoc in response to 3974
Re: combining or merging documents together?
For example, one can extract all the children from the body of the source document and copy them somewhere into the body of the target (master) document. The result is not always very clean but it can work. Example:
foreach my $element ($sourceDoc->getBody->children) { $targetDoc->appendBodyElement($element->copy); }

Note that children() is an element method (not a document method) and it comes from XML::Twig, so it's not quoted in the OpenOffice::OODoc manual. This method returns all the children of the calling element in the same order as in the document. Beware: copying the body element itself could not work, because a document can't contain more than one document body.
Write a response