Search code examples
javams-officeopenxmlxsl-fo

Is there a library capable of generating XSL-FO from Office XML documents like DOCX, XLSX?


Does anyone know of a library that is capable of generating XSL-FO from a Microsoft Office Open XML file, such as a Word DOCX or an Excel XLSX?

Given that these Office files are basically XML in a ZIP file, I figure it would be pretty straightforward to generate XSL-FO from them by applying appropriate XSLT transformations — though writing the XSLT would take some time. But if it is a straightforward as I suspect, then maybe someone has written a library that does it, or released XSLT transformations that do it.

This Microsoft MSDN library article contains an example of creating XSL-FO with Word 2003 WordprocessingML files, but I haven't seen anything for the newer Open XML format.

Does anyone have suggestions? A Java library would be preferable, but anything would be considered.


Solution

  • docx4j has support for this, for docx; since v3.3.0 it is in a separate project https://github.com/plutext/docx4j-export-FO

    It uses XSLT to create the XSL-FO. The XSLT uses Java extension functions to invoke docx4j methods to do much of the work, keeping the XSLT itself relatively simple.

    docx4j uses FOP to convert XSL FO to PDF.

    docx4j has support for xlsx, but no built in export from XLSX to XSL FO.