Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

modify odt file with perl OpenOffice::OODoc will corrupt the file

by ieeedino (Novice)
on Dec 17, 2015 at 04:15 UTC ( [id://1150577]=perlquestion: print w/replies, xml ) Need Help??

ieeedino has asked for the wisdom of the Perl Monks concerning the following question:

I want to modify odt file with perl OpenOffice::OODoc.

No matter using Text.pm, or XPath.pm

The file will corrupted when open with OpenOffice 3.3

Here is my code

use OpenOffice::OODoc; my $archive = ooFile("aaa.odt); $doc = ooDocument(archive => $archive, member => 'content'); .....processing $archive->save;

Actually the file will corrupt even I just open the file, and save back.

Please kindly help. OPenOffice version 2.125, OpenOffice version 3.3

Replies are listed 'Best First'.
Re: modify odt file with perl OpenOffice::OODoc will corrupt the file
by stefbv (Curate) on Dec 17, 2015 at 09:31 UTC

    You may have better luck with ODF::lpOD. It has a better API and it is the successor of the OpenOffice::OODoc module.

Re: modify odt file with perl OpenOffice::OODoc will corrupt the file
by kcott (Archbishop) on Dec 17, 2015 at 08:03 UTC

    G'day ieeedino,

    Welcome to the Monastery.

    I do use the OpenOffice application a lot but have never used OpenOffice::OODoc (so I just installed it).

    My system: Apache OpenOffice 4.1.1; OpenOffice::OODoc 2.125; Perl 5.22.0; Mac OS X 10.10.3

    To test, I fired up the OpenOffice application, started a new text document, typed "Just a test.", saved as pm_1150577_odt_corruption.odt, and closed. I opened and closed this a couple of times: no problems; none were expected.

    I then ran this code:

    #!/usr/bin/env perl use strict; use warnings; use autodie qw{:all}; use OpenOffice::OODoc; my $document = odfDocument(file => 'pm_1150577_odt_corruption.odt');

    Again, via the application, I opened and closed the file a couple of times. All good.

    I then added this line (to the end of the code shown above) and ran the script again:

    $document->save;

    No errors or warnings were emitted on the command line; however, when I then attempted to open the file from the application, I got a popup with a message which starts:

    The file 'pm_1150577_odt_corruption.odt' is corrupt and therefore cannot be opened. ...

    I can't see anything in "Active bugs for OpenOffice-OODoc" relating to file corruption. I suggest you raise a bug report.

    — Ken

      I will submit a bug report in Active bugs for OpenOffice-OODoc, Thanks for your advice.
Re: modify odt file with perl OpenOffice::OODoc will corrupt the file
by ieeedino (Novice) on Dec 17, 2015 at 07:20 UTC
    I found that OPenOffice::OODoc didn't escape ' as ' for example vg:font-family="'Times New Roman'" should be vg:font-family="'Times New Roman'" It seems a OpenOffice::OODoc bug

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1150577]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found