unoconv / unoconv

Universal Office Converter - Convert between any document format supported by LibreOffice/OpenOffice.
http://dag.wieers.com/home-made/unoconv/
GNU General Public License v2.0
2.55k stars 373 forks source link

Converting file to file with same name fails #567

Closed augustjanse closed 3 years ago

augustjanse commented 3 years ago

I'm trying to convert a standard PDF into a PDF/A with unoconv-0.9.0. However, it turns out that it fails when it tries to overwrite the file it's working on:

august@DESKTOP:~$ unoconv -f pdf test.pdf
unoconv: UnoException during export phase:
Unable to store document to file:///home/august/test.pdf (Error (com.sun.star.io.IOException){ (com.sun.star.uno.Exception){ Message = (string)"SfxBaseModel::impl_store <file:///home/august/test.pdf> failed: 0x4c0c(Error Area:Sfx Class:Write Code:12)", Context = (com.sun.star.uno.XInterface)0x0{} } })

Properties: ((com.sun.star.beans.PropertyValue){ Name = (string)"FilterName", Handle = (long)0x0, Value = (any){ (string)"writer_pdf_Export" }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){ Name = (string)"OutputStream", Handle = (long)0x0, Value = (any){ (com.sun.star.uno.XInterface)0x1d75858{, supportedInterfaces={com.sun.star.io.XOutputStream,com.sun.star.lang.XTypeProvider}} }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){ Name = (string)"Overwrite", Handle = (long)0x0, Value = (any){ (boolean)true }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE })

(PDF attributes I would actually use not used for this example)

Outputting to a different location works fine:

august@DESKTOP:~$ unoconv -f pdf -o test2.pdf test.pdf

I tried using soffice myself, but it appears that it simply exits because it's satisfied that the file has the correct extension already.

Workarounds for replacing the original files with the files from an output directory automatically welcome!

regebro commented 3 years ago

Convert it first, rename it second.