Closed uclnj closed 2 years ago
same here
any solution?
downgrade to pdfkit@^0.10.0 solves this
@petrkrizek thanks a lot, its work
@petrkrizek, yes, it works, thanks! Any news on why this could be happening?
@RdC1965 the pdfkit helper in the library was written for pdfkit 10. Version 11 support is on the way here https://github.com/vbuch/node-signpdf/pull/115
Thanks a lot, Valery. I am looking forward to the upgrade. In the meantime, I am quite happy with version 10: it works perfectly. Regards, Rodrigo
On Tuesday, October 19, 2021, 08:37:34 AM GMT+2, Valery Buchinsky ***@***.***> wrote:
@RdC1965 the pdfkit helper in the library was written for pdfkit 10. Version 11 support is on the way here #115
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Testing code using Jest examples, fails on the mock up createPdf function.
It never gets past the init of createPdf.
`const fs = require('fs') const PDFDocument = require('pdfkit') const signer = require('./signpdf').default const { pdfkitAddPlaceholder } = require('./helpers')
const createPdf = params => new Promise((resolve) => { const requestParams = { placeholder: {}, text: 'node-signpdf', addSignaturePlaceholder: true, pages: 1, ...params } const pdf = new PDFDocument({ autoFirstPage: false, size: 'A4', layout: 'portrait', bufferPages: true }) pdf.info.CreationDate = '' if (requestParams.pages < 1) { requestParams.pages = 1; } for (let i = 0; i < requestParams.pages; i++) { pdf.addPage().fillColor('#333').fontSize(25).moveDown().text(requestParams.text).save() } const pdfChunks = [] pdf.on('data', (data) => { pdfChunks.push(data) }) pdf.on('end', () => { resolve(Buffer.concat(pdfChunks)) }) const refs = pdfkitAddPlaceholder({ pdf, pdfBuffer: Buffer.from([pdf]), reason: 'I am the author', ...requestParams.placeholder }) Object.keys(refs).forEach(key => refs[key].end()) pdf.end() })
async function test() { const pdf = await createPdf({ placeholder: { signatureLength: 2, } }) pdf = signer.sign(pdf, fs.readFileSync(
./resources/certificate.p12
)) pdf.pipe(fs.createWriteStream('test.pdf')) pdf.end() }(async () => { await test() })() `