showing results for - "how to create pdfs in node js using pdf kit"
Jacob
09 Aug 2020
1/*
2    This code comes from Vincent Lab
3    And it has a video version linked here: https://www.youtube.com/watch?v=VR8Q43bJfwc
4*/
5
6// Import dependencies
7const fs = require("fs");
8const PDFDocument = require("./pdfkit-tables");
9
10// Load the patients 
11const patients = require("./patients.json");
12
13// Create The PDF document
14const doc = new PDFDocument();
15
16// Pipe the PDF into a patient's file
17doc.pipe(fs.createWriteStream(`patients.pdf`));
18
19// Add the header - https://pspdfkit.com/blog/2019/generate-invoices-pdfkit-node/
20doc
21    .image("logo.png", 50, 45, { width: 50 })
22    .fillColor("#444444")
23    .fontSize(20)
24    .text("Patient Information.", 110, 57)
25    .fontSize(10)
26    .text("725 Fowler Avenue", 200, 65, { align: "right" })
27    .text("Chamblee, GA 30341", 200, 80, { align: "right" })
28    .moveDown();
29
30// Create the table - https://www.andronio.me/2017/09/02/pdfkit-tables/
31const table = {
32    headers: ["Name", "Address", "Phone", "Birthday", "Email Address", "Blood Type", "Height", "Weight"],
33    rows: []
34};
35
36// Add the patients to the table
37for (const patient of patients) {
38    table.rows.push([patient.name, patient.address, patient.phone, patient.birthday, patient.emailAddress, patient.bloodType, patient.height, patient.weight])
39}
40
41// Draw the table
42doc.moveDown().table(table, 10, 125, { width: 590 });
43
44// Finalize the PDF and end the stream
45doc.end();
queries leading to this page
javascript node js generate pdfnodejs generate a pdfnode js generate pdfhow to download pdf node jsgenerate pdf node jspdfkit download pdf nodejshow to download pdf in nodejshow to generate a pdf in nodejsnice pdf node jsdownload pdf in node js pdf creator for node jshow to create pdf in node jsgenerating pdf nodenodejs generate pdf and download from clientcreate a pdf file using node js and download itnode js guide pdfpdf creator node jshow to download a pdf generated by pdf kit in node jsgenerate pdf using nodejshow to generate pdf using node jscreate a pdf in nodejsmake a pdf in nodejshow to generate pdf in node jsnode js create pdfnode js server pdfnode js basics pdfnodejs pdfkit create pdf filehow to generate pdf files from html in node using pdfkitcreate pdf on nodejsdownload pdf in node js through api pdfkitnodejs generate pdf and downloaddownload pdf pdfkit nodejshow to download pdf nodejsinstalling pdf js with nodefree pdf creator node jsgenerate pdf node jshow to make pdf in nodejsnode js create pdfgenerating pdf in javascript nodecreate pdf with node jshow to generate pdf in nodejsgenerate pdf from nodejscreate 26 download pdf nodejshow to create a pdf doc in nodejs npmnode js create pdf from templategenerate pdf in node jsmake pdf from nodejsnode js tutorial pdf downloadhow to write doc from pdf kit with node jshow to generate pdf 27s nodejshtml to pdf with pdf kit node jsserving pdf document pdf kit nodejsprofessional node js pdfhow to create pdfs in node js using pdf kithow to download a pdf functionality using node jsdownload pdf in nodejshow to create pdfs in node js using pdf kit