Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when exporting JasperPrint to PDF/A document #502

Closed
VedranSlankovic opened this issue Mar 17, 2021 · 1 comment · Fixed by #504
Closed

NPE when exporting JasperPrint to PDF/A document #502

VedranSlankovic opened this issue Mar 17, 2021 · 1 comment · Fixed by #504
Milestone

Comments

@VedranSlankovic
Copy link

Hello,

I'm using JasperReports with OpenPDF and I can not export JasperPrint to PDF/A document.

I'm using jasperreports exportReport() method from JRPdfExporter which calls method com.lowagie.text.pdf.PdfWriter.getInstance(Document document, OutputStream os) in which object com.lowagie.text.pdf.PdfDocument is constructed with constructor :

    public PdfDocument() {
        super();
    }

Problem is that NPE occurs when XMPMeta object is created and populated with properties that consists of XML namespaces, names and values. Two of these properties names are CreateDate and ModifiedDate and their values are read from PdfDictionary com.lowagie.text.pdf.PdfWriter.getInfo() object. These values don't exist in PdfDictionary.

Constructor of net.sf.jasperreports.engine.export.XmpWriter class:

    XmpWriter(PdfWriter pdfWriter)
    {
        this.pdfWriter = pdfWriter;
        this.info = pdfWriter.getInfo();
    }

NPE occurs at these lines of code:

xmp.setProperty(XMPConst.NS_XMP, XMP_CREATE_DATE, ((PdfDate) info.get(PdfName.CREATIONDATE)).getW3CDate());
xmp.setProperty(XMPConst.NS_XMP, XMP_MODIFY_DATE, ((PdfDate) info.get(PdfName.MODDATE)).getW3CDate());

Can you change constructor to (like in iText versions 2.7.1 and 4.2.1) :

    public PdfDocument() {
        super();
        addProducer();
        addCreationDate();
    }

I can create Pull-request if needed.

@andreasrosdal
Copy link
Contributor

Thanks, pull requests welcome!

VedranSlankovic pushed a commit to VedranSlankovic/OpenPDF that referenced this issue Mar 18, 2021
VedranSlankovic pushed a commit to VedranSlankovic/OpenPDF that referenced this issue Mar 18, 2021
asturio pushed a commit that referenced this issue Mar 20, 2021
@asturio asturio added this to the 1.3.26 milestone May 2, 2021
@asturio asturio linked a pull request May 2, 2021 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants