'how to horizontally center a table in pdfkmake when it does not occupy the entire width
The totals text is centered horizontally, I would like to center the table so that both sides have the same space
generatePdf(template: ElementRef): any {
const pdfTable = template.nativeElement;
const html: Array<any> = htmlToPdfmake(pdfTable.innerHTML);
html.forEach((item) => {
item.style = ['tableCenter'];
});
console.log(html);
const documentDefinition = {
content: html,
pageSize: 'A3',
pageOrientation: 'landscape',
styles: {
tableCenter: {
alignment: 'center',
absolutePosition: { x: 10, y: 35 },
},
},
};
return pdfMake.createPdf(documentDefinition);
}
I am using html as a template for the pdf
Solution 1:[1]
You can use margin for it:
margin: [20, 5, 0, 10],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | H S Progr |

