alexmorozov / templated-docs

Generate PDF, MS Word and Excel documents from templates in Django
MIT License
114 stars 57 forks source link

where is TEMPLATED_DOCS_LIBREOFFICE_PATH for MAC? #9

Open Kopei opened 7 years ago

Kopei commented 7 years ago

Hi, I am trying to test this package on local mac machine. I found that it needs pylokit from pylokit import Office But it seems pylokit only support linux. [https://github.com/xrmx/pylokit/blob/master/pylokit/lokit.py]

What I Did

I am trying add:
`/Applications/OpenOffice.app/Contents/program` in TEMPLATED_DOCS_LIBREOFFICE_PATH,
but there are no `TARGET_LIB = ("libsofficeapp.so", "libmergedlo.so")`,
in mac, there is only  `libsofficeapp.dylib`.
I do not know how to set TEMPLATED_DOCS_LIBREOFFICE_PATH for environment var.
Any suggestions?
alexmorozov commented 7 years ago

Hi! As far as I know, LibreOfficeKit (the LibreOffice bridge to interface it from within other programs) works only on Linux. If you have some evidence LibreOfficeKit works on Macs too, please let me know. I think, we could ask pylokit's author then to incorporate the OSX support into the library.

alexmorozov commented 7 years ago

A relevant ticket to track: https://github.com/xrmx/pylokit/issues/10

zontarian commented 7 years ago

Please note that LibreOfficeKit is needed only to convert from one format to another, i.e. from odt to docx/pdf or such. If you don't need this, the template engine works. Then, if you are on mac OSX, as a workaround, you can use either UNO or simply invoke

/Applications/MACOSXpath/soffice --invisible --headless --convert-to pdf --outdir /tmp/spool <FILENAME>

with a dirty system call :)

alexmorozov commented 7 years ago

@zontarian thanks for a tip! You're absolutely right. If there's no need to convert a document to another format, we don't even try to mess with that LOKit stuff.

As a side note - we have a project running against an UNO-based solution. It mostly works, though it's much slower and crashes randomly several times a month, so we have to have a sentinel in place. Command-line approach works great for ad-hoc operations, since the cold LibreOffice startup takes too much time for a web-based solution.

Just my two cents.

zontarian commented 7 years ago

@alexmorozov you are right. We too experimented with UNO for performance issues, but in the end, for one off requests, the difference in time was not noticeable, and the stability of a direct invokation is greater.

But in the end we will deploy to Linux, so we are just using this kludge to be able to develop and test on MacOSX. Great work, thanks!