$(document).ready(function() {
var demo_document = {
pageOrientation: "landscape",
pageMargins: [40, 80, 40, 40],
header: function(currentPage, pageCount) {
return [{
text: "Company Name",
bold: true,
fontSize: 14,
alignment: "center",
margin: [0, 25, 0, 0],
},
{
text: "Address: House, Road, City, Country",
alignment: "center",
},
];
},
footer: function(currentPage, pageCount) {
return [{
text: "Page " + currentPage.toString() + " of " + pageCount.toString(),
alignment: "center",
}, ];
},
content: [{
table: {
widths: ["auto", "*", "*", "auto", "*"],
headerRows: 1,
dontBreakRows: true,
body: [
[{
text: "ID",
style: "columnHeader"
},
{
text: "Name",
style: "columnHeader"
},
{
text: "Designation",
style: "columnHeader"
},
{
text: "Salary",
style: "columnHeader"
},
{
text: "Remarks",
style: "columnHeader"
},
],
[{
text: "First Group",
colSpan: 5,
},
{},
{},
{},
{},
],
[{
text: "01"
}, {
text: "AA"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "02"
}, {
text: "BB"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "03"
}, {
text: "CC"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "04"
}, {
text: "DD"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "05"
}, {
text: "EE"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "06"
}, {
text: "FF"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "07"
}, {
text: "GG"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "08"
}, {
text: "HH"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "09"
}, {
text: "II"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "10"
}, {
text: "JJ"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "11"
}, {
text: "KK"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "12"
}, {
text: "LL"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "13"
}, {
text: "MM"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "14"
}, {
text: "NN"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "15"
}, {
text: "OO"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "16"
}, {
text: "PP"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "17"
}, {
text: "QQ"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "18"
}, {
text: "RR"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "19"
}, {
text: "SS"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "20"
}, {
text: "TT"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "21"
}, {
text: "UU"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "22"
}, {
text: "VV"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "23"
}, {
text: "WW"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "24"
}, {
text: "XX"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "25"
}, {
text: "YY"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "26"
}, {
text: "ZZ"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "",
colSpan: 5,
pageBreak: "before",
},
{},
{},
{},
{},
],
[{
text: "Second Group",
colSpan: 5,
},
{},
{},
{},
{},
],
[{
text: "27"
}, {
text: "AB"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "28"
}, {
text: "BC"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "29"
}, {
text: "CD"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "30"
}, {
text: "DE"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "31"
}, {
text: "EF"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "32"
}, {
text: "FG"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "33"
}, {
text: "GH"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "34"
}, {
text: "HI"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "35"
}, {
text: "IJ"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "36"
}, {
text: "JK"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "37"
}, {
text: "KL"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "38"
}, {
text: "LM"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "39"
}, {
text: "MN"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "40"
}, {
text: "NO"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "41"
}, {
text: "OP"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "42"
}, {
text: "PQ"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "43"
}, {
text: "QR"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "44"
}, {
text: "RS"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "45"
}, {
text: "ST"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "46"
}, {
text: "TU"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "47"
}, {
text: "UV"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "48"
}, {
text: "VW"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "49"
}, {
text: "WX"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "50"
}, {
text: "XY"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "51"
}, {
text: "YZ"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
[{
text: "52"
}, {
text: "ZA"
}, {
text: "Officer"
}, {
text: "1000"
}, {
text: ""
}],
],
},
layout: {
hLineWidth: function(i, node) {
return i === 0 || i === node.table.body.length ? 1 : 0.5;
},
vLineWidth: function(i, node) {
return i === 0 || i === node.table.widths.length ? 1 : 0.5;
},
hLineColor: function(i, node) {
return "#777777";
},
vLineColor: function(i, node) {
return "#777777";
},
},
}, ],
styles: {
columnHeader: {
bold: true,
alignment: "center",
},
},
};
pdfMake.createPdf(demo_document).getDataUrl(function(frontSource) {
document.getElementById("demo-document").src = frontSource;
});
});
.container .row .col-12 .embed-responsive .embed-responsive-item {
width: 100%;
height: 500px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<div class="row border m-1">
<div class="col-12">
<div class="embed-responsive embed-responsive-4by3 text-center">
<iframe class="embed-responsive-item" src="" id="demo-document"></iframe>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.3.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.72/pdfmake.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.72/vfs_fonts.js"></script>
</body>
</html>