Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center align table - PDFMAKE

Tags:

vue.js

pdfmake

Can i create one table with center alignment (page) using PDFMAKE?

Already defined alignment: "center" in Styles and inside the tag table: {}

{
              table: {
                width: "auto",
                body: [
                  [
                    { text: "PERÍODO", style: "tableHeader" },
                    { text: "VOLUME (MW médios)", style: "tableHeader" }
                  ],
                  ["{7} a {8}", "{9}"],
                  ["{10} a {11}", "{12}"],
                  ["{13} a {14}", "{15}"]
                ],
                alignment: "center"
              }
            }

I expect one table align in the center of the page.

like image 394
Emmanuel Oliveira Avatar asked Sep 16 '19 02:09

Emmanuel Oliveira


1 Answers

alignment:"center" only aligns the content of the columns in center. You can try as following:

{
    columns: [
        { width: '*', text: '' },
        {
            width: 'auto',
                table: {
                body: [
                  [
                    { text: "PERÍODO", style: "tableHeader" },
                    { text: "VOLUME (MW médios)", style: "tableHeader" }
                  ],
                  ["{7} a {8}", "{9}"],
                  ["{10} a {11}", "{12}"],
                  ["{13} a {14}", "{15}"]
                ],
                alignment: "center"
                }
        },
        { width: '*', text: '' },
    ]
}
like image 59
ImtiazNur Avatar answered Nov 01 '22 16:11

ImtiazNur