Closed loresclement closed 3 weeks ago
Hello!
You should be able to do it via:
const { writeFile } = require("node:fs/promises");
const { buffer } = require('node:stream/consumers');
const { generate } = require('@stafyniaksacha/facturx');
const PDFDocument = require("pdfkit-table");
const xml = `<?xml version="1.0" encoding="UTF-8"?>...`
function createPdfKitStream() {
const doc = new PDFDocument({ margin: 30, size: 'A4' });
// ...
doc.end()
// return doc without using pipe()
return doc
}
async function main() {
const stream = createPdfKitStream();
// consume pdfkit stream to buffer
const pdf = await buffer(stream);
await writeFile("./document.pdf", pdf);
const facturx = await generate({
pdf,
xml,
})
await writeFile("./document-facturx.pdf", facturx);
}
main().catch(console.error);
It's working ! Thank you
Hello ! Thank you for your package. I'm trying to use it but I have an issue.
I'm using the package pdfkit-table (which is an extension of pdf-kit). It has the type of PDFDocumentWithTables
Could you add the support of this type ? Otherwise does a workaround exists ?