By using apache POI how to convert ms word file to pdf?
I an using the following code but its not working giving errors I gues
This save my day, i load docx file from an url and convert it to pdf:
pom.xml
org.apache.poi
poi
3.13
org.apache.poi
poi-ooxml
3.13
fr.opensagres.xdocreport
org.apache.poi.xwpf.converter.pdf
LATEST
main_class
public String wordToPDFPOI(String url) throws Exception {
InputStream doc = new URL(url).openStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XWPFDocument document = new XWPFDocument(doc);
PdfOptions options = PdfOptions.create();
PdfConverter.getInstance().convert(document, baos, options);
String base64_encoded = Base64.encodeBytes(baos.toByteArray());
return base64_encoded;
}