3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JODConverter+LibreOfficeの変換が遅いとお嘆きのあなたへ

Last updated at Posted at 2020-10-09

JODConverter


 巷で見かけるサンプルコードは、次のような流れが多数となっている。しかし下記の処理を実行すると、外部プロセスとしてLibreOfficeを起動・終了するため、処理に時間がかかる。例えばWebアプリケーションの1リクエストごとに実行する処理としては、適切でない。

OfficeManager officeManager = LocalOfficeManager.make();
officeManager.start();
// ・・・
// フォーマット変換(中略)
// ・・・
officeManager.stop();

 公式に推奨された方法としては、単一のOfficeManagerをWebアプリ起動時にstart()して、全リクエストで共有して、Webアプリ終了時にstop()する。
https://github.com/sbraconnier/jodconverter/wiki/Web-Application


 ExternalOfficeManagerもそれなりに有効かもしれない。

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] 次のように引数を指定してLibreOfficeを起動しておく。

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

[2] フォーマット変換時には ExternalOfficeManager を利用して、起動済みのLibreOfficeに接続する。この処理はそれなりに速く実行できる。

OfficeManager officeManager = ExternalOfficeManager.make();
officeManager.start();
// 中略
officeManager.stop();

 ただし、Javadocに書いてある通り、LibreOfficeが異常終了しても、JODConverterはLibreOfficeを再起動しない。

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

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?