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

Table header row text not populating #2743

Open
MeesterZee opened this issue Jul 2, 2024 · 0 comments
Open

Table header row text not populating #2743

MeesterZee opened this issue Jul 2, 2024 · 0 comments

Comments

@MeesterZee
Copy link

MeesterZee commented Jul 2, 2024

I am using PDFMake to generate two tables side by side in a PDF. The first table renders correctly and shows the text in its header row. The second table in the right column shows the header row but does not place the header text in the header row cells.

Reproducible example:

function writeTables() {
    const tableHeaders = [
        { text: 'Last Name', style: 'tableHeader' },
        { text: 'First Name', style: 'tableHeader' },
        { text: 'Grade', style: 'tableHeader' },
        { text: 'Class', style: 'tableHeader' }
    ];

    const leftTableBody = [
        tableHeaders,
        ['Doe', 'John', '5', 'A']
    ];

    const rightTableBody = [
        tableHeaders,
        ['Smith', 'Jane', '6', 'B']
    ];

    const columns = [
        {
            width: '50%',
            table: {
                headerRows: 1,
                widths: ['*', '*', 40, 40],
                body: leftTableBody
            }
        },
        {
            width: '50%',
            table: {
                headerRows: 1,
                widths: ['*', '*', 40, 40],
                body: rightTableBody
            }
        }
    ];

    const docDefinition = {
        pageSize: 'LETTER',
        pageOrientation: 'portrait',
        pageMargins: [40, 40, 40, 40], // Standard margins
        content: [
            { columns: columns, columnGap: 10 }
        ],
        styles: {
            tableHeader: { fontSize: 12, bold: true, fillColor: 'gray' },
            tableCell: { fontSize: 12 }
        }
    };

    pdfMake.createPdf(docDefinition).download('TableTest.pdf');
  }
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

1 participant