[JAVA] To you who lament that the conversion of JODConverter + LibreOffice is slow


--A library that converts the format of Office files using Apache OpenOffice or LibreOffice --Various conversions such as Excel → PDF are possible

The sample code found in the streets has the following flow. However, when the following process is executed, LibreOffice is started and terminated as an external process, so the process takes time. For example, it is not appropriate as a process to be executed for each request of a Web application.

OfficeManager officeManager = LocalOfficeManager.make();
//・ ・ ・
//Format conversion (omitted)
//・ ・ ・

The officially recommended method is to start () a single Office Manager when the web app starts, share it with all requests, and stop () when the web app ends. https://github.com/sbraconnier/jodconverter/wiki/Web-Application

ExternalOfficeManager may be effective as it is.

ExternalOfficeManager (JODConverter Local 4.3.0 API) https://www.javadoc.io/static/org.jodconverter/jodconverter-local/4.3.0/org/jodconverter/local/office/ExternalOfficeManager.html

[1] Start LibreOffice with the arguments specified as follows.

soffice.exe -accept="socket,host=,port=2002;urp;"

[2] When converting the format, use ExternalOfficeManager to connect to the started LibreOffice. This process can be done reasonably fast.

OfficeManager officeManager = ExternalOfficeManager.make();

However, as described in Javadoc, JOD Converter does not restart LibreOffice even if LibreOffice terminates abnormally.

Since this implementation does not manage the Office process, it does not support auto-restarting the process if it exits unexpectedly.

Recommended Posts

To you who lament that the conversion of JODConverter + LibreOffice is slow
A memo of the program that allows you to realize that the probability of dice rolling is about 1/6
Rails The concept of view componentization of Rails that I want to convey to those who want to quit
To you who will become the leader of the development team from now on-Minimum standardization-
When the hover of Eclipse is hard to see
Completely delete the migration file that you failed to delete
Since the reading of JdbcCodeList of TERASOLUNA is slow, I tried to register multiple at once.
[Rails] How to temporarily save the request URL of a user who is not logged in and return to that URL after logging in
Review the basic knowledge of ruby that is often forgotten
Determine that the value is a multiple of 〇 in Ruby
When you want to change the MySQL password of docker-compose
[Java] Code that is hard to notice but terribly slow
[PostgreSQL] The story that you have to cut the session properly
A collection of patterns that you want to be aware of so as not to complicate the code
The story of making a binding for libui, a GUI library for Ruby that is easy to install
About the solution to the problem that the log of logback is not output when the web application is stopped
[Java beginner] Conversion from character string to numerical value-What is the parseInt method of the Integer class? ~
The story of Collectors.groupingBy that I want to keep for posterity
Want to know what Ruby n is the power of 2? (Power judgment of 2)
The milliseconds to set in /lib/calendars.properties of Java jre is UTC
How to identify the path that is easy to make a mistake
Extension that asynchronously executes closures passed to the initializer of Combine.Future
Is the version of Elasticsearch you are using compatible with Java 11?
Creating an ArrayList that allows you to throw in and retrieve the coordinates of a two-dimensional plane
[RSpec] When you want to use the instance variable of the controller in the test [assigns is not recommended]
About the matter that tends to be confused with ARG of Dockerfile which is a multi-stage build
Summary of tips (Rails) that you can use all the way because you understand that it is jQuery discount