Feeding Pdfkit generated file to pdf-lib.
See original GitHub issueI am trying to send a pdfkit generated pdf file as input to pdflib for merging. I am using async function. My project is being developed using sails Js version:“^1.2.3”, “node”: “^12.16”, my pdf-kit version is: “^0.11.0”, “pdf-lib”: “^1.9.0”, This is the code:
const textbytes=fs.readFileSync(textfile);
var bytes1 = new Uint8Array(textbytes);
const textdoc = await PDFDocument.load(bytes1)
The error i am getting is:
UnhandledPromiseRejectionWarning: Error: Failed to parse PDF document (line:0 col:0 offset=0): No PDF header found
Please help me with this issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (3 by maintainers)
Top Results From Across the Web
node.js - Feeding PDF generated from pdfkit as input to pdf-lib ...
I am trying to send a pdfkit generated pdf file as input to pdflib for merging. I am using async function. My project...
Read more >Feeding PDFKit into pdf-lib · Issue #9 - GitHub
I'm using PDFKit/Svg-to_PDF to convert SVG maps to a GeoPDF aalong with the sajjad-shirazy/pdfkit.js fork of PDFKit to insert SPOT colors.
Read more >PDFKit Guide
PDFKit normally flushes pages to the output file immediately when a new page is created, making it impossible to jump back and add...
Read more >Working With PDFs in Node.js Using pdf-lib
Puppeteer is a great tool for generating PDFs from HTML, ... The PDF document will have 1 page with the Mastering JS logo...
Read more >Microservices – Generating PDF with Node.js & PDFKit
Create the main function (GenInvoice.js) to provide the sample invoice data to be displayed in the generated PDF document. The sample invoice ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Patcher56 Looks like a very interesting project! I suspect that in many places the
protectedaccess modifier could be used instead of theprivateone. I don’t want to replace all usages ofprivate, and relatively few instances should be changed topublic. If something is marked asprivatethen it is not meant to be public interfaces and is subject to breaking changes. If you’d like to open a PR changing the things you need toprotected, I’d be happy to take a look.I also use pdfkit and pdf-lib at the same time, but I can embed the pdf files generated by pdfkit. I use
embedPdfinstead ofPDFDocument.load.I think the problem may be that the pdf generated by pdfkit is not saved completely, you can try to ensure that the pdf file has been written before load by pdf-lib.