Pdfkit: unable to open pdf file.

Created on 15 May 2018  路  6Comments  路  Source: foliojs/pdfkit

I'm using pdfkit module for last 6 months. it worked in the beginning but past few days the downloaded file not opening showing an error that "there was an error while opening this document.the file is damaged .......", it's working with local server, but not working with azure node server, I compared versions also, everything is same in azure as local.Can any one help me out where i'm doing wrong.

Most helpful comment

Not sure if this is similar to your issue. My code also creates proper PDFs locally (Win10/node 8) but fails when deployed to the older CentOS 6.8 we use. I am able to work-around the CentOS issue and get an openable PDF by disabling compression.

let doc = new PDFDocument({compress:false})

All 6 comments

Not sure if this is similar to your issue. My code also creates proper PDFs locally (Win10/node 8) but fails when deployed to the older CentOS 6.8 we use. I am able to work-around the CentOS issue and get an openable PDF by disabling compression.

let doc = new PDFDocument({compress:false})

you saved almost 2 days of work just by passing that parameters, seems like that compress function corrupts the file i was piping to

Wow what a bug! This is exactly what I needed to make it work with NodeJs and Express

Version 0.9.0 fix a issue with compressed pdf, can you retest?

I tested without 'compress: false' on CentOS release 6.10 (Final) with 0.9.0. Worked for me. Thanks

I have a similar issue. When I create pdf with 2-3 pages, with vector graphics.
Writing the pdf to a file through :
`let fileStream: WriteStream = createWriteStream(filePath);
let docDesigner = new PDFDocument({ autoFirstPage: false, compress: false });
docDesigner.pipe(fileStream);

  fileStream.on("close", () => {
                    console.log(`Generated PDF file `);
                })

`
Apparently "Generated PDF file " is logged correctly after all PDFDocument vector graphic design instructions. But It looks like finalising (doc.end()) happens before all the lines and pages have been completed....

Sometimes a page remains apparently blank and unreadable.
Both for Acrobat reader and Adobe Illustrator.
I tried also
new PDFDocument({compress:false})
but still having the issue.

Package version is 0.10.0

Adobe Illustrator states, trying to opening the blank page:
"Acrobat PDF File Format is having difficulties. Expected a stream object."

Any idea?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akaleeroy picture akaleeroy  路  4Comments

huy-nguyen picture huy-nguyen  路  4Comments

liubin picture liubin  路  4Comments

balsamiqMichele picture balsamiqMichele  路  4Comments

ehaubold picture ehaubold  路  5Comments