0

I am looking to convert a HTMLdocument to a PDF file. For that I convert without problem my document from HTML into .docx. To convert it from .docx to PDF I followed this link: Converting docx into pdf in java
But I have this error:

Exception in thread "JavaFX Application Thread" java.lang.NoSuchMethodError: org.apache.poi.POIXMLDocumentPart.getPackageRelationship()Lorg/apache/poi/openxml4j/opc/PackageRelationship;

I use the libraries POI version 3.17.

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
Simon
  • 1
  • 1
  • 2
    You can use online API to convert HTML to PDF directly, without using docx first. Plenty exists, like [PDFShift](https://pdfshift.io), [DocRaptor](http://docraptor.com/), [PDFLayer](https://pdflayer.com/), ... etc. – Cyril N. Jun 06 '18 at 13:52

1 Answers1

0

The exception is thrown as the conversion library was designed/built with Apache POI version 3.10-FINAL.

For those using Maven, here are the dependencies that I declared:

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.10-FINAL</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.10-FINAL</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas/ -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>ooxml-schemas</artifactId>
    <version>1.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.core/ -->
<dependency>
    <groupId>fr.opensagres.xdocreport</groupId>
    <artifactId>org.apache.poi.xwpf.converter.core</artifactId>
    <version>1.0.6</version>
</dependency>

<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.pdf/ -->
<dependency>
    <groupId>fr.opensagres.xdocreport</groupId>
    <artifactId>org.apache.poi.xwpf.converter.pdf</artifactId>
    <version>1.0.6</version>
</dependency>

<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.xdocreport.itext.extension/ -->
<dependency>
    <groupId>fr.opensagres.xdocreport</groupId>
    <artifactId>fr.opensagres.xdocreport.itext.extension</artifactId>
    <version>2.0.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.lowagie/itext/ -->
<dependency>
    <groupId>com.lowagie</groupId>
    <artifactId>itext</artifactId>
    <version>2.1.7</version>
</dependency>
Osmund Francis
  • 771
  • 10
  • 27