pdfkit-table
pdfkit-table copied to clipboard
Typescript errors even in the most basic examples
Hello,
Your docs state that pdfkit-table is a plugin. Does it mean that it requires pdfkit installed separately to run or is it standalone? I am assuming it is standalone and therefore I did not install the original pdfkit library nor its @types/pdfkit module.
I have "pdfkit-table": "^0.1.99" and "typescript": "^4.9.4" installed and none of the examples provided in your docs work.
Take your most basic example:
import PDFDocument from "pdfkit-table";
// init document
let doc = new PDFDocument({ margin: 30, size: 'A4' });
// save document
doc.pipe(fs.createWriteStream("./document.pdf"));
await (async function createTable(){
// table
const table = {
title: '',
headers: [],
datas: [ /* complex data */ ],
rows: [ /* or simple data */ ],
};
await doc.table(table, { /* options */ });
doc.end();
})();
Will return the following errors:



I had the same issue on 0.1.99. I downgraded to 0.1.86 and issue was resolved. Also, it looks like pdfkit is required.
"pdfkit": "0.13.0",
"pdfkit-table": "0.1.86"
I had faced the same issue and was resolved after intsalling @types/pdfkit.
npm i --save-dev @types/pdfkit
Facing another type error:
Property 'addBackground' does not exist on type 'PDFDocumentWithTables'.ts(2339)

Facing another type error:
Property 'addBackground' does not exist on type 'PDFDocumentWithTables'.ts(2339)
I used the doc.fill() method and it works...