I ve been using PHPWord for docx files generation. And it s been working great. But now I have the need to also make available some of those files on a pdf version.
After a few research I found PyODConverter which use OOo. Seemed quite a good option since I don t want to depend on third party web services. I tried it out on my machine and it works fined, so I ve applied it on my server as well. It took a little longer but I ve managed to get it working on there too.
There is however an (bad) issue. On the server this takes about 21 seconds to get it done, while on my machine it doesn t take longer than 2. :( This is way too much time for my needs so I ve been trying to spot what might be causing this delay. Starting openoffice in healess mode with socket creation is okay. So I ve been looking at the python script trying to find out which instruction might be causing to slow down. I ve narrowed it down to this line:
context = resolver.resolve("uno:socket,host=127.0.0.1,port=8100;urp;StarOffice.ComponentContext")
This is the action that s taking about 20secs to execute. The code where it is inserted:
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
try:
context = resolver.resolve("uno:socket,host=127.0.0.1,port=8100;urp;StarOffice.ComponentContext")
except NoConnectException:
raise DocumentConversionException, "failed to connect to OpenOffice.org on port %s" % port
self.desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
Any clues on what might be causing this delay? I ve ruled out the document that I m trying to convert since this operations occur before that. Could it be a problem with uno ? Or maybe another missing library that might be causing useless testing on during the resolve() operation?
欢迎任何想法。
最佳做法 无