Search code examples
apache-fopdocx4j

unwanted indent after line wrap


I'm converting some worddocuments (docx) with docx4j 6.1.2 and docx4j-export-fo 8.1.2 (apache FOP 2.3) to PDF with Java 11 like this:

// Load File
var wordMLPackage = WordprocessingMLPackage.load(wordDocument.getInputStream());

// Convert to PDF
var out = new FastByteArrayOutputStream();
Docx4J.toPDF(wordMLPackage, out);
return new ByteArrayResource(out.toByteArray());

In all paragraphs in the generated PDF there is a formatting issue I can't get a grip on. The following image shows a section from the docx in word.

enter image description here

The next image shows the section from the pdf file.

  1. Each wrapped line starts with some extra indent on the left side.
  2. Long lines are not wrapped.

enter image description here

Any ideas?

Edit 1:

The docx File is here: https://filebin.net/cux9s1p5ufm1vgul.


Solution

  •     <dependency>
            <groupId>org.docx4j</groupId>
            <artifactId>docx4j-export-fo</artifactId>
            <version>6.1.0</version>
        </dependency>
    

    works ok.

    It seems the problem is white-space-collapse="false" white-space-treatment="preserve" introduced by https://github.com/plutext/docx4j-export-FO/commit/4451111aa02a698ed54788299513f7eac74bd996#diff-eeb9c00a64479f4ff29769e29a6a0cd7R455