galkahana / HummusJS

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

"Couldn't find tokens in file" error thrown when trying to merge two PDFs #438

Open nicosayer opened 4 years ago

nicosayer commented 4 years ago

Hi !

I'm trying to merge two PDFs like shown in the Wiki:

var pdfWriter = hummus.createWriter(__dirname + '/output.pdf');

pdfWriter.appendPDFPagesFromPDF(__dirname + '/file1.pdf');
pdfWriter.appendPDFPagesFromPDF(__dirname + '/file2.pdf');

pdfWriter.end();

But it throws an error everytime :

TypeError: unable to append page, make sure it's fine

And here are the logs :

[ 18/10/2019 14:39:19 ] PDFParser::ParseEOFLine, Couldn't find tokens in file
[ 18/10/2019 14:39:19 ] PDFDocumentHandler::StartCopyingContext, failure occured while parsing PDF file.

The error seems to be coming from file1.pdf because when I try with this file : alternativeFile.pdf everything works just fine.

The difference between those two files is that file1.pdf uses a custom font (Tangerine) while alternativeFile.pdf only uses Helvetica.

Do you have any idea what is going wrong ?

Thanks!