We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm doing something very simple, just adding a QR code and some text to a pdf page. It fails.
I'm using it on Firebase Cloud Functions which uses Node v6.x
Here is the code that works and generates a pdf file that can be opened in a browser/google drive:
doc = new pdf() pdfpath = path.join(os.tmpdir(), 'test.pdf') doc.pipe(fs.createWriteStream(pdfpath)) doc.end()
This does not work:
doc = new pdf() pdfpath = path.join(os.tmpdir(), 'test.pdf') doc.pipe(fs.createWriteStream(pdfpath)) doc.text('hello world') doc.end()
No idea how to fix this, every example I can find shows the same thing; that this should work just fine.
The text was updated successfully, but these errors were encountered:
If I create a blank pdf file and it works, this is what I get from opening the file in Notepad:
%PDF-1.3 %ÿÿÿÿ 5 0 obj << /Type /Page /Parent 1 0 R /MediaBox [0 0 612 792] /Contents 3 0 R /Resources 4 0 R >> endobj 4 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] >> endobj 6 0 obj << /Producer (PDFKit) /Creator (PDFKit) /CreationDate (D:20171205214225Z) >> endobj 2 0 obj << /Type /Catalog /Pages 1 0 R >> endobj 1 0 obj << /Type /Pages /Count 1 /Kids [5 0 R] >> endobj 3 0 obj << /Length 23 /Filter /FlateDecode >> stream xœ3T0 B]C ani¤�œË� �I�\ endstream endobj xref 0 7 0000000000 65535 f 0000000327 00000 n 0000000278 00000 n 0000000384 00000 n 0000000119 00000 n 0000000015 00000 n 0000000186 00000 n trailer << /Size 7 /Root 2 0 R /Info 6 0 R >> startxref 478 %%EOF
Here is the broken pdf created by having the line doc.text('hello world') in the code:
doc.text('hello world')
%PDF-1.3 %ÿÿÿÿ 5 0 obj << /Type /Page /Parent 1 0 R /MediaBox [0 0 612 792] /Contents 3 0 R /Resources 4 0 R >> endobj 4 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] /XObject << /I1 6 0 R >> >> endobj 7 0 obj << /Producer (PDFKit) /Creator (PDFKit) /CreationDate (D:20171205205103Z) >> endobj 2 0 obj << /Type /Catalog /Pages 1 0 R >> endobj 1 0 obj << /Type /Pages /Count 1 /Kids [5 0 R] >> endobj
Sorry, something went wrong.
You can try to use the finish callback. It could be the server that timeouts before the document is finished. Maybe there is an option to wait longer?
var stream = fs.createWriteStream(pdfpath); doc.pipe(stream); stream.on('finish', function() { console.log('The file is ready'); });
No branches or pull requests
I'm doing something very simple, just adding a QR code and some text to a pdf page. It fails.
I'm using it on Firebase Cloud Functions which uses Node v6.x
Here is the code that works and generates a pdf file that can be opened in a browser/google drive:
This does not work:
No idea how to fix this, every example I can find shows the same thing; that this should work just fine.
The text was updated successfully, but these errors were encountered: