galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.15k stars 169 forks source link

Reading File with Base 14 fonts not embedded in document #385

Open jasperA256 opened 5 years ago

jasperA256 commented 5 years ago

Summary

I'm trying to read a file that does not have the Base 14 font Helvetica embedded, to merge it to an existing pdf.

Environment

The code is running on a Debian Jessie server hummus-js -v 1.0.95 node -v 8.15.1

Snippet

try {
    let pdfReader = hummus.createReader(new hummus.PDFRStreamForBuffer(pdfBuffer));
    pdfWriter.appendPDFPagesFromPDF(new hummus.PDFRStreamForBuffer(pdfBuffer));
} catch (e) {
    // Throws 'Unable to start parsing PDF file'
}

where pdfBuffer is a Buffer containing the pdf to be merged.

Info

The (test)pdf I'm trying to merge, causing troubles is the following: https://cdn.a256.eu/test-files/base-14-fonts-not-embedded.pdf The application handles user-uploaded pdfs, so we don't have control over the pdfs themselves. The user regards the pdf as valid, because all readers handle it fine.

Is there any way the Base 14 fonts can be pre-loaded in hummus to prevent errors like that? Or specified to the reader?

Thanks a lot, Jasper