Ask Your Question
0

Choosing export page for writer_jpg_Export

asked 2019-03-20 08:13:25 +0200

NicklasK gravatar image

I'm prototyping a REST-based service that uses LibreOffice as a background engine for document conversion to various outputs. I noticed that e.g. for a Word document, writer_jpg_Export exports the first page so I assume I would have to do the conversion a page at a time. Any pointers as to where I could set a parameter indicating which page I would like converted?

Thanks in advance, Nik

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-03-20 08:20:38 +0200

There is no parameter to define page to export to a raster image. LibreOffice only can export the first page using raster image filter parameters.

You could instead export to PDF, and use dedicated tools like ImageMagick to post-process as required.

edit flag offensive delete link more

Comments

Ouch. Thanks for the reply. There is no option if you would go deeper into the document, iterate over the pages and call conversion in some other way for each?

Thanks in advance, Nik

NicklasK gravatar imageNicklasK ( 2019-03-20 08:27:34 +0200 )edit

In any case, I would prefer to keep it within the JVM and avoid external programs, perhaps iText has something

NicklasK gravatar imageNicklasK ( 2019-03-20 08:32:58 +0200 )edit

You can use UNO to control LibreOffice, say, using Python or Java. This way you can do that directly from LibreOffice - you may check how Export As Images extension did that for Impress/Draw (extension is a ZIP; basic source code is inside; you may get the idea what to do out of that).

I don't get that "I would prefer to keep it within the JVM and avoid external programs" - that is impossible with LibreOffice anyway, since it is an external program.

Mike Kaganski gravatar imageMike Kaganski ( 2019-03-20 09:24:39 +0200 )edit

Thanks for the reply. Yes, I realize that LO is an external program and it's an necessary evil since there are no(?) java libraries that come close to handling as many formats as LO does. I'm just trying to avoid the need to installing and launching further external programs (without e.g. java Process).

I tried rendering to PDF and then use PDFBox to generate the page images and merging them, it appears to be working fine.

Thanks for the help, I love to see an active community - many places noob-questions just go unanswered ;-)

NicklasK gravatar imageNicklasK ( 2019-03-20 09:29:38 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-20 08:13:25 +0200

Seen: 20 times

Last updated: Mar 20