Skip to content

Instantly share code, notes, and snippets.

@hunzo
Created September 30, 2021 05:55
Show Gist options
  • Save hunzo/0ec0120444029f872f5ce66b2a4c6fe3 to your computer and use it in GitHub Desktop.
Save hunzo/0ec0120444029f872f5ce66b2a4c6fe3 to your computer and use it in GitHub Desktop.
Simple PDFmake
<!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" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.2/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.2/vfs_fonts.min.js"></script>
<title>Document</title>
</head>
<body>
<h1>PDFmake</h1>
<script>
let docDefination = {
content: [
{
layout: 'lightHorizontalLines', // optional
table: {
// headers are automatically repeated if the table spans over multiple pages
// you can declare how many rows should be treated as headers
headerRows: 1,
widths: ['*', 'auto', 100, '*'],
body: [
['First', 'Second', 'Third', 'The last one'],
['Value 1', 'Value 2', 'Value 3', 'Value 4'],
[
{ text: 'Bold value', bold: true },
'Val 2',
'Val 3',
'Val 4',
],
],
},
},
],
}
pdfMake.createPdf(docDefination).open()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment