Email a file, i.e. generate a PDF then grab it from the PDF Express viewer

Which product are you using?

PDF.js Express Version

Detailed description of issue
Hi,
I was trying to figure out how I could generate a pdf then retrieve it from the viewer and send it to a server to be emailed. Bonus: I’m doing this in Blazor so essentially I’m restricted as to what I can do.

Expected behaviour
_________^^^^^^^^^ Nice Canadian Spelling!!!
Generate a report and send it in an email.

Does your issue happen with every document, or just one?
Every one.

Link to document
NA

Code snippet

// I’m calling this javascript from a Blazor app to get the displayed PDF. It doesn’t
// return the PDF but I think it’s close
getPDF: (elementWanted) => {
const viewerElement = document.getElementById(elementWanted);
instance = getInstance(viewerElement);
const { documentViewer } = instance.Core;

    // must wait for the document to be loaded before you can save the file
    documentViewer.addEventListener('documentLoaded', async () => {
        const documentStream = documentViewer.getDocument().getFileData({});
        const documentBlob = new Blob([documentStream], { type: 'data:application/pdf' });

        return(documentBlob);
    })
}

Thanks

Craig

Hi there,

Thank you for contacting pdf.js express forums,

It looks like you followed this guide to get the blob created from the document:

From there you would need to save that blob to the server.
I am not an expert on this topic but you will need to setup a SMTP from your end and then send off the blob as an attachment?

You can also check if that blob is returning the pdf you expect by using loadDocument on the blob:

Best regards,
Kevin Kim


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here