opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.19k stars 368 forks source link

fix the NullPointerException issue. for issue detail please check htt… #638

Closed Xiaoshu-Zhao closed 4 months ago

Xiaoshu-Zhao commented 4 months ago

fix the NullPointerException issue. for issue detail please check https://github.com/opensagres/xdocreport/issues/637

angelozerr commented 4 months ago

Thanks @Xiaoshu-Zhao !

Adrian012344 commented 3 months ago

I am having the same problem when trying to convert an Apache POI document to PDF with the method:

private byte[] createPdf(XWPFDocument document) {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    PdfOptions options = PdfOptions.create();
    document.enforceReadonlyProtection();
    try {
        PdfConverter.getInstance().convert(document, byteArrayOutputStream, options);
    } catch (IOException e) {
        throw new RuntimeException("Pdf converter failed", e);
    }
    return byteArrayOutputStream.toByteArray();
}.

Will this fix also work for PDFs? And will this fix be released soon? Have a good day.