RE: Re: Creating Table of Contents

Anton Oellerer <[email protected]> Tue, 28 Jun 2022 07:37:11 +0000
Newsgroups gmane.comp.jakarta.poi.user
Message-ID <AS4PR09MB56835F4038DE702F75987290ABB89@AS4PR09MB5683.eurprd09.prod.outlook.com>
I found another solution for now, but if it comes up again, I will ask there, thank you!

On 2022/06/22 13:41:36 PJ Fanning wrote:
> I have never come across anyone using POI and docx4j together.
> Maybe you would be better off using stackoverflow.com and providing a reproducible use case. A larger number of developers can be reached there.
>
>
> On Tuesday 21 June 2022, 08:56:51 IST, Anton Oellerer <[email protected]> wrote:
>
> Hello,
> The project I am currently working on needs to hand over a .docx document with a finished table of contents to an API for pdf conversion.
> As far as I figured out, it is currently not possible to generate a finished TOC with Apache POI alone, so we decided to try using docx4j + Apache FOP to update the TOC after generating the document with Apache POI.
> In the first testing runs, we noticed that there are multiple errors in docx4j Apache FOP stemming from missing values, which prevent generating a valid document.
> Those include:
>
>   *  Cannot invoke "org.docx4j.wml.Style$Name.getVal()" because the return value of "org.docx4j.wml.Style.getName()" is null
>   *  org.docx4j.XmlUtils: java.lang.NullPointerException: Cannot invoke "org.w3c.dom.DocumentFragment.getFirstChild()" because "df" is null
>   *  java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 2 at org.docx4j.model.properties.run.Lang.setXslFO(Lang.java:71)
>   *  javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: "fo:table-cell" is missing child elements. Required content model: marker* (%block;)+ (See position 9:3836)
>
> Do you know whether these results stem from a misconfiguration on our side, or is Apache POI -> docx4j simply not a supported use case?
> Best regards
> Anton Oellerer
>
>

Mit freundlichen Grüßen

Anton Oellerer
Junior Backend Developer

[cid:437c1d34-d91f-4205-9e33-a210fea4b608]
docu tools GmbH • Gatterburggasse 5 • 1190 Wien

T +43 1 890 32 27 27 • [email protected]<mailto:[email protected]> • www.docu-tools.com<https://www.docu-tools.com/>

FN 531024v HG Wien • UID Nr. ATU75458238