Page 1 of 1

Docx to Image(s)

PostPosted: Tue Sep 27, 2016 3:04 am
by smallcats
Hi All,

Currently using DOCX4J library to convert docx to PNG images.

How I achieve this is by converting the document to PDF first.
Then using another third party library(PDFBox) I create PNG images.

This works but it's not very efficient.

My question is I'd like to cut out the PDF conversion and create images directly from the DOCX4j Document object.

Is this possible and if so does anybody have resources they could point me to?


Re: Docx to Image(s)

PostPosted: Tue Sep 27, 2016 5:17 pm
by jason
You can use the FO based output to get anything FOP supports:

Code: Select all
      // Document format:
      // The default implementation of the FORenderer that uses Apache Fop will output
      // a PDF document if nothing is passed via
      // foSettings.setApacheFopMime(apacheFopMime)
      // apacheFopMime can be any of the output formats defined in org.apache.fop.apps.MimeConstants eg org.apache.fop.apps.MimeConstants.MIME_FOP_IF or
      // FOSettings.INTERNAL_FO_MIME if you want the fo document as the result.

See ...

Hmmm, that's changed since fop 0.93: ...

so some adjustment might be required.

Alternatively, this is a feature we're looking to add to the commercial PDF Converter, but we don't have it yet.

Re: Docx to Image(s)

PostPosted: Wed Sep 28, 2016 1:01 am
by smallcats
Thanks for the response Jason.
This is what I'm looking for.

It only renders the first page as image.
I know this is a FOP question as I have seen it in other posts.
I'll need to have a better understanding of FOP before fixing this.