I am testing Apache POI and I have questions.
I am working with maven and java.
- Is possible convert an excel file to PDF without reading it (Something similar to
PdfConverter.getInstance().convert
) - In case there is no function for doing as in step 1, how can I keep the excel styles, formats and others things?
- Why does this code
PdfConverter.getInstance().convert(doc,outFile,options);
have this error java.lang.ClassNotFoundException: org.apache.poi.POIXMLDocumentPart (see the code below)? - Is there some other library that is FREE that I can use?.
I have attached the pom.xml and the code for the word conversion:
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<!-- org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
</dependency>
<!-- 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>
<!-- com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version>
</dependency>
Code for the word conversion:
File file1 = new File("myWord.docx");
FileInputStream fileInpStr1 = new FileInputStream(file1.getAbsolutePath());
XWPFDocument doc = new XWPFDocument(fileInpStr1);
OutputStream outFile = new FileOutputStream("myPDFout.pdf"));
PdfOptions options = null;
PdfConverter.getInstance().convert(doc,outFile,options); <-- here the error jumps
outFile.close();
doc.close();