I’m using python uno to develop a docoument covert program. I want to add multiple images to a draw(.odg), but I failed to save it.
Create :doucument = … loadComponentFromURL(“private:factory/sdraw”, ‘_default’, 0, ())
Store: document.storeAsURL(uno.fileUrlToSystemPath(out_path),())
Error:ErrorCodeIOException: SfxBaseModel::impl_store <.\x.odg> failed: 0x81a(Error Area:Io Class:Parameter Code:26)
I would suggest:
from pathlib import Path
…
…
document.storeAsURL( Path("./x.odg").absolute().as_uri() , ())
You are calling a function that clearly indicates, that it needs a URL; and pass there a system path that you explicitly created from a URL?
So great !Why such code works?
I know, it needs a absolute path and add prefix- file:///
thank u, it’s my problem.
I know, it needs a absolute path and add prefix- file:///
partially, there is also the need to escape whitespace:
ppp = Path("./file with whitespace.txt")
print(ppp.absolute().as_uri())
'file:///home/wertie/.config/libreoffice/4/user/ipython/file%20with%20whitespace.txt'
The Real Purpose is to convert docx to pdf(each page is image)
I try in this way:
Step 1: Export docx to png
Step 2: Create a draw (add those png images) and save
Now I want to convert draw(.odg) to pdf using the code:
document.storeToURL(self._to_file_url('./x.pdf'),
(PropertyValue(Name='FilterName', Value='draw_pdf_Export'),))
but It seems that that pdf’s each image displayed partly, how to use FilterData to control the odg image size
Please ask a new question, maybe with more context to help others to reproduce the issue!