pdfmake
example PDf
by Gopinath Kaliappan
JavaScript
import { Injectable } from '@angular/core';
import pdfMake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
@Injectable({
providedIn: 'root'
})
export class PdfService {
constructor(
) {
}
generatePdf(){
let rows = [[
{text: 'Header 1', style: 'tableHeader'},
{text: 'Header 2', style: 'tableHeader'},
{text: 'Header 3', style: 'tableHeader'},
{text: 'Header 3', style: 'tableHeader'},
],
[1,2,3,4]];
let i = 0;
do {
rows.push([
100, 200, 400, 1
])
i +=1;
}
while(i < 100);
console.log(rows);
const documentDefinition = {
content: [
'This is an sample PDF printed with pdfMake',
{
layout: 'lightHorizontalLines', // optional
style: 'tableExample',
table: {
headerRows: 1,
// dontBreakRows: true,
// keepWithHeaderRows: 1,
alignment: 'justify',
widths: ['25%', '25%', '25%', '25%'],
body: [
[
{
text: 'Hello',
style: 'newHead'
},
{
text: 'Hello',
},
{
text: 'Hello',
},
{
text: 'Hello',
}
],
[1, 2,3,4]
]
}
},
{
layout: 'lightHorizontalLines', // optional
style: 'tableExample',
table: {
headerRows: 1,
// dontBreakRows: true,
// keepWithHeaderRows: 1,
alignment: 'justify',
widths: ['25%','25%','25%','25%'],
body: rows
}
}
],
styles: {
header: {
fontSize: 18,
bold: true
},
subheader: {
fontSize: 15,
bold:...