0

I want to convert an word docx file to a pdf file via XSL FO (using Apache FOP)

Here is my code:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.docx4j.Docx4J;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;

public class WordToPDF {
     public static void main(String[] args) {
         FileOutputStream os = null;
    try {
       InputStream templateInputStream = new FileInputStream("D:\\Downloads\\convert.docx");
       WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(templateInputStream);
       String outputfilepath = "D:\\Downloads\\convert.pdf";
       os = new FileOutputStream(outputfilepath);
       Docx4J.toPDF(wordMLPackage,os);
       os.flush();
       os.close();
       System.out.println("Convert DONE!!!!");
    } catch (Exception e) {
        e.printStackTrace();   
    }finally{
          try {
            os.flush();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
          try {
            os.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
     }
}

I'm getting stacktrace :

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
    at org.docx4j.Docx4J.toPDF(Docx4J.java:748)
    at WordToPDF.main(WordToPDF.java:24)
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
    at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:108)
    at org.docx4j.Docx4J.toFO(Docx4J.java:711)
    at org.docx4j.Docx4J.toPDF(Docx4J.java:744)
    ... 1 more
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Exception writing Document to OutputStream: null
    at org.docx4j.utils.XmlSerializerUtil.serialize(XmlSerializerUtil.java:56)
    at org.docx4j.utils.XmlSerializerUtil.serialize(XmlSerializerUtil.java:18)
    at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:209)
    at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:165)
    at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:168)
    at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)
    at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:83)
    ... 3 more
Caused by: java.lang.IllegalStateException
    at org.apache.fop.layoutmgr.AbstractBreaker.handleFloatLayout(AbstractBreaker.java:783)
    at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:423)
    at org.apache.fop.layoutmgr.StaticContentLayoutManager.doLayout(StaticContentLayoutManager.java:140)
    at org.apache.fop.layoutmgr.PageSequenceLayoutManager.layoutSideRegion(PageSequenceLayoutManager.java:232)
    at org.apache.fop.layoutmgr.PageSequenceLayoutManager.finishPage(PageSequenceLayoutManager.java:238)
    at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.makeNewPage(AbstractPageSequenceLayoutManager.java:287)
    at org.apache.fop.layoutmgr.PageSequenceLayoutManager.makeNewPage(PageSequenceLayoutManager.java:192)
    at org.apache.fop.layoutmgr.PageBreaker.handleBreakTrait(PageBreaker.java:634)
    at org.apache.fop.layoutmgr.PageBreaker.startPart(PageBreaker.java:512)
    at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:564)
    at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:509)
    at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:504)
    at org.apache.fop.layoutmgr.PageBreaker.doPhase3(PageBreaker.java:339)
    at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:458)
    at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:113)
    at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:143)
    at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
    at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:140)
    at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:390)
    at org.apache.fop.fo.FOTreeBuilder$3.run(FOTreeBuilder.java:207)
    at org.apache.fop.fo.FOTreeBuilder$3.run(FOTreeBuilder.java:204)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:203)
    at org.docx4j.org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1148)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:610)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1716)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2881)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216)
    at org.docx4j.org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:518)
    at org.docx4j.utils.XmlSerializerUtil.serialize(XmlSerializerUtil.java:51)
    ... 9 more

https://github.com/apache/xmlgraphics-fop/blob/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractBreaker.java#L783

protected int handleFloatLayout(PageBreakingAlgorithm alg, int optimalPageCount, BlockSequence blockList,
        LayoutContext childLC) {
    throw new IllegalStateException();
}

Can't handle float during page breaking?

Here is the resulting FO:

<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
  <layout-master-set xmlns="http://www.w3.org/1999/XSL/Format" >
    <simple-page-master margin-bottom="0.5in" margin-left="1in" margin-right="0.5in" margin-top="0.5in" master-name="s1-firstpage" page-height="11in" page-width="8.5in">
      <region-body column-count="1" column-gap="0.5in" margin-bottom="396.0pt" margin-left="0mm" margin-right="0mm" margin-top="396.0pt"/>
      <region-before extent="396.0pt" region-name="xsl-region-before-firstpage"/>
      <region-after extent="396.0pt" region-name="xsl-region-after-firstpage"/>
    </simple-page-master>
    <simple-page-master margin-bottom="0.5in" margin-left="1in" margin-right="0.5in" margin-top="0.5in" master-name="s1-default" page-height="11in" page-width="8.5in">
      <region-body column-count="1" column-gap="0.5in" margin-bottom="396.0pt" margin-left="0mm" margin-right="0mm" margin-top="396.0pt"/>
      <region-before extent="396.0pt" region-name="xsl-region-before-default"/>
      <region-after extent="396.0pt" region-name="xsl-region-after-default"/>
    </simple-page-master>
    <page-sequence-master master-name="s1">
      <repeatable-page-master-alternatives>
        <conditional-page-master-reference master-reference="s1-firstpage" page-position="first"/>
        <conditional-page-master-reference master-reference="s1-default"/>
      </repeatable-page-master-alternatives>
    </page-sequence-master>
  </layout-master-set>
  <fo:page-sequence force-page-count="no-force" id="section_s1" format="" master-reference="s1">
    <fo:static-content flow-name="xsl-region-before-firstpage">
      <fo:table border-collapse="collapse" display-align="before" start-indent="-13mm" table-layout="fixed" width="192mm">
        <fo:table-column column-number="1" column-width="3.03in"/>
        <fo:table-column column-number="2" column-width="116mm"/>
        <fo:table-body start-indent="0in">
          <fo:table-row>
            <fo:table-cell background-color="#FFFFFF">
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="16.0pt" keep-with-next="always" language="en" line-height="100%" space-after="0.08in">
                <inline country="US" font-size="16.0pt" font-weight="bold" language="en" letter-spacing="0mm" text-decoration="underline">
                  <external-graphic content-height="147px" content-width="206px" src="file:/tmp/f2b8e514-08cd-4839-add2-4a0914b9144cimage1.png"/>
                </inline>
              </block>
            </fo:table-cell>
            <fo:table-cell background-color="#FFFFFF">
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="16.0pt" keep-with-next="always" language="en" line-height="100%" space-after="0.08in" text-align="center">
                <inline country="US" font-size="16.0pt" font-weight="bold" language="en" letter-spacing="0mm" text-decoration="underline">
                  <inline font-family="Liberation Sans">SOME HEADER TEXT</inline>
                </inline>
              </block>
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="17.0pt" language="en" line-height="120%" space-after="0in" text-align="center">
                <inline country="US" font-size="8.0pt" language="en">
                  <inline font-family="Liberation Sans">Some text</inline>
                </inline>
              </block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in" white-space-treatment="preserve"> </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="xsl-region-after-firstpage">
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in" white-space-treatment="preserve"> </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="xsl-region-before-default">
      <fo:block country="US" font-size="16.0pt" keep-with-next="always" language="en" line-height="100%" space-after="0.08in" text-align="center" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0.08in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <float border-bottom-style="solid" border-left-style="solid" border-right-style="solid" border-top-style="solid" float="start" height="76.5pt" width="80.25pt">
            <block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </block>
          </float>
        </inline>
      </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="xsl-region-after-default">
      <fo:block country="IT" font-size="8.0pt" language="it" line-height="100%" space-after="0in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="IT" font-size="8.0pt" language="it">
          <inline font-family="Liberation Sans">Footer text</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="IT" font-size="8.0pt" language="it">
          <inline font-family="Liberation Sans">  </inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="8.0pt" language="en">
          <inline font-family="Liberation Sans">31/08/2022</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="8.0pt" language="en">
          <block white-space-treatment="preserve"/>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" id="created_date"/>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="IT" font-size="8.0pt" language="it">
          <inline font-family="Liberation Sans">Footer text line 2</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="IT" font-size="8.0pt" language="it">
          <inline font-family="Liberation Sans">.</inline>
        </inline>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in" text-align="right">
        <page-number xmlns="http://www.w3.org/1999/XSL/Format"/>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <inline font-family="Liberation Sans">/</inline>
        </inline>
        <wrapper xmlns="http://www.w3.org/1999/XSL/Format">
          <page-number-citation-last ref-id="section_s1"/>​
        </wrapper>
      </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="xsl-footnote-separator">
      <fo:block>
        <fo:leader rule-thickness="0.5pt" rule-style="solid" leader-length="100%" leader-pattern="rule"/>
      </fo:block>
    </fo:static-content>
    <fo:flow flow-name="xsl-region-body">
      <fo:block break-before="auto" country="US" font-size="14.0pt" language="en" line-height="107%" space-after="0.11in" text-align="center">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans">Title</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans"> </inline>
          <inline font-family="Liberation Sans">n</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans">o</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans">. </inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <inline font-family="Liberation Sans">CM-00000018</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <block white-space-treatment="preserve"/>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" id="reg_number_formatted"/>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans"> </inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans">date</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en">
          <inline font-family="Liberation Sans"> </inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <inline font-family="Liberation Sans">31/08/2022</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <block white-space-treatment="preserve"/>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" id="reg_number_date"/>
      </fo:block>

      <fo:table border-bottom-color="#FFFFFF" border-bottom-style="solid" border-bottom-width="0.5pt" border-collapse="collapse" border-left-color="#FFFFFF" border-left-style="solid" border-left-width="0.5pt" border-right-color="#FFFFFF" border-right-style="solid" border-right-width="0.5pt" border-top-color="#FFFFFF" border-top-style="solid" border-top-width="0.5pt" display-align="before" start-indent="0in" table-layout="fixed" width="5.31in">
        <fo:table-column column-number="1" column-width="5.31in"/>
        <fo:table-body start-indent="0in">
          <fo:table-row>
            <fo:table-cell border-bottom-color="#FFFFFF" border-bottom-style="solid" border-bottom-width="0.5pt" border-left-color="#FFFFFF" border-left-style="solid" border-left-width="0.5pt" border-right-color="#FFFFFF" border-right-style="solid" border-right-width="0.5pt" border-top-color="#FFFFFF" border-top-style="solid" border-top-width="0.5pt" padding-bottom="0mm" padding-left="1.91mm" padding-right="1.91mm" padding-top="0mm">
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="14.0pt" language="en" line-height="107%" space-after="0.11in" text-align="center">
                <inline country="US" font-size="14.0pt" language="en">
                  <inline font-family="Liberation Sans">Title</inline>
                </inline>
                <inline id="branchName"/>
              </block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="15.0pt" language="en">
          <inline font-family="Liberation Sans">TEXT</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="15.0pt" language="en">
          <block white-space-treatment="preserve"/>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" id="slot1Title"/>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" id="slot1Body"/>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <inline font-family="Liberation Sans">MORE TEXT</inline>
        </inline>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in" white-space-treatment="preserve"> </fo:block>

      <fo:table border-collapse="collapse" display-align="before" table-layout="fixed" width="1.24in">
        <fo:table-column column-number="1" column-width="1.24in"/>
        <fo:table-body start-indent="0in">
          <fo:table-row>
            <fo:table-cell>
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in">
                <inline country="US" font-size="11.0pt" language="en">
                  <inline font-family="Liberation Sans">DESCRIPTION: </inline>
                </inline>
              </block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <inline font-family="Liberation Sans">PAGE 2</inline>
        </inline>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="15.0pt" language="en">
          <inline font-family="Liberation Sans">TEXT</inline>
        </inline>
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="15.0pt" language="en">
          <block white-space-treatment="preserve"/>
        </inline>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in">
        <inline xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en">
          <inline font-family="Liberation Sans">MORE TEXT</inline>
        </inline>
      </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="100%" space-after="0in" white-space-treatment="preserve"> </fo:block>

      <fo:table border-collapse="collapse" display-align="before" table-layout="fixed" width="0.96in">
        <fo:table-column column-number="1" column-width="0.96in"/>
        <fo:table-body start-indent="0in">
          <fo:table-row>
            <fo:table-cell>
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in">
                <inline country="US" font-size="11.0pt" language="en">
                  <inline font-family="Liberation Sans">Description</inline>
                </inline>
                <inline country="US" font-size="11.0pt" language="en">
                  <inline font-family="Liberation Sans">: </inline>
                </inline>
              </block>
            </fo:table-cell>
          </fo:table-row>
          <fo:table-row>
            <fo:table-cell>
              <block xmlns="http://www.w3.org/1999/XSL/Format" country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in">
                <inline color="#FFFFFF" country="US" font-size="11.0pt" language="en">
                  <inline font-family="Liberation Sans">.</inline>
                </inline>
              </block>
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
      <fo:block country="US" font-size="11.0pt" language="en" line-height="107%" space-after="0.11in" white-space-treatment="preserve"> </fo:block>
    </fo:flow>
  </fo:page-sequence>
</fo:root>

The word document contains a header (with image and text) some tables with text and some bookmarks. It has multiple pages, but I don't know how relevant it is. Can someone tell me what's wrong?
Thank you!

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
Adrian
  • 101
  • 8
  • I recall the same problem assembling dependencies for a NetBeans library; consult the _Component Map_ cited [there](https://stackoverflow.com/a/72839258/230513). – trashgod Sep 02 '22 at 12:00
  • I have added Maven Dependency for poi-ooxml-full verssion 5.2.2 but same error. Can you tell me what jar is missing? – Adrian Sep 02 '22 at 14:03
  • Hi, thank you for the reply. I have only poi-ooxml-full, and the error is the same. Did you use poi 5.2.2 and Java 11? – Adrian Sep 02 '22 at 15:46
  • Yes, I know that with java 1.8 it's working but it's about java 11. I've already seen the link and I've tried with poi-ooxml-5.2.2 + poi-ooxml-lite-5.2.2 and just with poi-ooxml-full-5.2.2 and also just with poi-ooxml-5.2.2 but the error is the same everytime. I haven't seen an working example for java 11 and poi 5.2.2 – Adrian Sep 02 '22 at 20:20
  • Looks like you are using docx4j PDF via XSL-FO. Nothing to do with poi. Post your docx somewhere? – JasonPlutext Sep 02 '22 at 21:05
  • Yes, you are wright, has nothing to do with poi. it is part of a bigger project, I've removed poi dependency. Docx file => https://github.com/oskarjr/files/blob/main/convert.docx?raw=true – Adrian Sep 02 '22 at 22:16
  • Hi K J, thank you for the reply but this is not the solution that I want. I need a free java11 api to transform docx to pdf. There is a problem with java 11 and docx4j transform to pdf and I wonder if someone has an working solution for that, a solution that works in java 11 – Adrian Sep 03 '22 at 19:34
  • Hi Jason, I saw you edited my question adding FO xml. It is a bug in Apache FOP? Any chance to fix this? Thank you! – Adrian Sep 06 '22 at 22:36

0 Answers0