natancabral / pdfkit-table

Helps to draw informations in simple tables using pdfkit. #server-side. Generate pdf tables with javascript (PDFKIT plugin)
MIT License
93 stars 59 forks source link

Typescript errors even in the most basic examples #67

Open vresetnikov opened 1 year ago

vresetnikov commented 1 year ago

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:

image

image

image

ibliskavka commented 1 year ago

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"
opxyc commented 1 year ago

I had faced the same issue and was resolved after intsalling @types/pdfkit.

npm i --save-dev @types/pdfkit
opxyc commented 1 year ago

Facing another type error:

Property 'addBackground' does not exist on type 'PDFDocumentWithTables'.ts(2339)

image

7doctor7 commented 8 months ago

Facing another type error:

Property 'addBackground' does not exist on type 'PDFDocumentWithTables'.ts(2339)

I used the doc.fill() method and it works...