It is simple. I will describe the graphical way.
My code in Python download all *.DOC files from one of the websites. Then I need them to be converted to something called DocBook (*.xml). It is a Word document converted to XML so it contains e.g. a table in the form of <row><entry><para>content</para></entry></row>
To perform a conversion, I use the following Python code:
Code: Select all
command = 'libreoffice --headless --convert-to xml:"DocBook File" "%s/%s"' % (os.getcwd(),filename)
os.system(command)
But I can't convert DOC files that contain passwords for opening. The command for the command line to give the password as a parameter is an element of the wish list. So I found out that there is a possibility - by using LibreOffice API - to open a file with a password given as a parameter.
Here is the code from the Polish version of this forum:
Code: Select all
sub test()
dim properties(0) as new com.sun.star.beans.PropertyValue
url = convertToURL("<file_path>")
properties(0).Name = "Password"
properties(0).Value = "<file_password>"
doc = StarDesktop.loadComponentFromUrl(url, "_blank", 0, properties())
end sub
In addition to this code, I was told to use something like "doc.storeAsURL" and an appropriate filter to save this as DocBook
But I need to perform this task in Python so I will need to use py-UNO.