Force repair on a file from CLI

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
pakt
Posts: 1
Joined: Fri Dec 21, 2018 2:53 am

Force repair on a file from CLI

Post by pakt »

Hi,

I'm not sure if I'm in the right place for this question, so apologies if I'm not. I'm working on an old bunch of code that's been handed off to me. The code generates an odt file (from a template) that is then converted to a pdf.
It does this with a call to:

python pyodconverter/DocumentConverter.py infile.odt outfile.pdf

However, for reasons currently unknown, this occasionally fails on certain generated odt files. When I attempt to open the offending odt file it says it's corrupt and needs to be repaired. When I repair it I can view it and it looks fine.

As a quick and dirty fix, I would like to force a repair from the CLI on any odt file that fails conversion. Is there a way to do this?

Unfortunately they're currently limited to using openoffice3.4 and upgrading is not an option at the moment.

Thanks for any guidance with this,

Pakt.
openoffice 3.4
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Force repair on a file from CLI

Post by RoryOF »

Does it give any error message when it announces the file is corrupt?

If the message is about a SaxParse error, the file needs repair by careful inspection of its internals.

If the message is merely that the file is corrupt, try opening it with an archiver (winzip, perhaps). In that case it may be possible to repair it from command line using archive repair techniques (check details for the archiver you use), although best to do this on a copy of the file.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply