0

I'm using docx4j 6.1.2 with docx4j export fo 8.1.3. Actually after convert I have only first page of .docx document. How can I do it page by page?

Can I do the same with docx4j to convert .doc and .rtf?

WordprocessingMLPackage wordMLP = Docx4J.load(new File(filepath));
    OutputStream os = new FileOutputStream(new File(fileName + ".png"));
    FOSettings settings = Docx4J.createFOSettings();
    settings.setWmlPackage(wordMLP);
    settings.setApacheFopMime(MimeConstants.MIME_PNG);
    Docx4J.toFO(settings, os, Docx4J.FLAG_NONE);
    os.close();
Kreer
  • 3
  • 1

1 Answers1

1

you can achieve it by converting the docx to pdf and then getting png, page by page

you can use pdfbox for this purpose. pdfbox is a library that can be used to read/manipulate pdf file. more on pdfbox https://pdfbox.apache.org/

sample code for converting pdf to png page by page - https://stackoverflow.com/a/23327024/5202960

using pdf box library you can determine the quality of image as well.

regarding .rtf and .doc conversion, I don’t this you will achieve that using docx4j. http://www.docx4java.org/forums/docx-java-f6/open-rtf-with-docx4j-t2067.html

Vinujan.S
  • 660
  • 7
  • 22