Posted on 2009-02-12 08:29:49-08 by benat
How to join (merge) sereral ODT files into one document
Hello,

I'm trying to join several ODT files (one page each) into a single document containing all of them, one per page. After spending some time on the documentation I ended with the following code, which at a first glance does what I need:
$oodoc1->appendElement( '//office:body', 0, $oodoc2->exportXMLElement( '//office:text' ) );

This code exports the <office:text> node from $oodoc2 and appends it, as a new child, into node <office:body> of $oodoc1. This way, the generated document gets two <office:text> nodes.

Well, it works and I can open the merged document (~60 files joined) in an OpenOffice application, but the point is that I'm not sure it conforms to the ODF schema: shouldn't the <office:text> node be unique? Moreover, I would need the whole document be somewhat "reorganized" (styles and alike), but the "reorganize" method throws an error message saying it's no longer implemented.

Please does anybody know a cleaner way to do such document joins? Google didn't help. Thanks a lot.
Direct Responses: 9944 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.