unoconv / unoserver

MIT License
496 stars 69 forks source link

REST API implementation #17

Closed amardeep2006 closed 2 years ago

amardeep2006 commented 2 years ago

I am planning to use unoserver with FAST API to create a document conversion service. I donot want to call unoconvert as shell command. Can I get an example on how to use unoconvert natively in Python since FAST API is written in python only.

Can i simply instantiate the UnoConverter class from converter.py ?

regebro commented 2 years ago

Yes.

But keep in mind you need to keep everything in the same python install, including LibreOffice. As long as you stay with the system LibreOffice on some Linux installation like for example Ubuntu, and use the system Python, this should work.

amardeep2006 commented 2 years ago

@regebro Highly appreciate the blazing fast response. I was able to achieve this for pdf conversion. Here is one example for future reference I someone want to try the same.

from unoserver import converter

myconverter = converter.UnoConverter()
myconverter.convert("input.pptx",None,"output.pdf","pdf")

I will optimize it like deleting from disk and returning response as in memory. Prerequisite : LibreOffice Python unoserver already started.

Additional query : Is unoserver tested for concurrency ? Can I convert multiple document in Parallel without any conflicts?

regebro commented 2 years ago

It's not tested for concurrency, but if there is a problem there it is likely to be LibreOffice, because unoserver itself is very simple, and there isn't really anything that could clash.

amardeep2006 commented 2 years ago

Thanks , closing the issue.