Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript errors even in the most basic examples #67

Open
vresetnikov opened this issue Feb 20, 2023 · 4 comments
Open

Typescript errors even in the most basic examples #67

vresetnikov opened this issue Feb 20, 2023 · 4 comments

Comments

@vresetnikov
Copy link

vresetnikov commented Feb 20, 2023

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
Copy link

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
Copy link

opxyc commented Apr 19, 2023

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

npm i --save-dev @types/pdfkit

@opxyc
Copy link

opxyc commented Apr 19, 2023

Facing another type error:

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

image

@7doctor7
Copy link

Facing another type error:

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants