Adding an attachment to a PDF while keeping pdf accessbility (pdfUA) doesnt seem to work?



  • Hi!

    I am trying to render a PDF which is PDF/A-3b compliant - I know that's not fully supported, but if I enable pdf accessbility pdfUA the PDF gets almost compliant. Without it, I get errors like missing color schemes for example. With pdfAccessbility/pdfUA enabled those are resolved. That's really nice.

    But I also have a case where the same PDF gets a file attached. And then it seems pdfUA & attachment are somewhat mutual exclusive. If I first set pdfUA and then add the attachment, pdfUA isn't applied. If I first add the attachment and then run pdfUA, the attachment is gone.

    That's the code trying to apply both:

    async function afterRender(req, res) {
        if(res.meta.contentType === 'application/pdf') {
    
            // enable pdfUA
            res.content = await jsreport.pdfUtils.postprocess(res.content, {
                pdfMeta: {
                    title: 'Report  ' + getCurrentDateFormatted()
                },
                pdfAccessibility: {
                    pdfUA: true
                }
            });
    
            // add attachment(s)
            for (var attachmentName in req.data.pdfAttachments) {
                const base64DecodedAttachment = Buffer.from(req.data.pdfAttachments[attachmentName], 'base64');
                res.content = await jsreport.pdfUtils.addAttachment(res.content, base64DecodedAttachment, {
                    name: attachmentName
                });
            }
        }
    }
    

    WIth the code above, the attachments survive. If i flip the two blocks, only pdfUA survives.

    Also enabling pdfUA directly on the template in the UI and having the snippet only add the attachment doesn't solve the issue, the attachment survives, pdfUA is gone.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.