Skip to content

Instantly share code, notes, and snippets.

@buddylindsey
Created February 17, 2020 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buddylindsey/278cb6d1d8ede504e52772f9a6159326 to your computer and use it in GitHub Desktop.
Save buddylindsey/278cb6d1d8ede504e52772f9a6159326 to your computer and use it in GitHub Desktop.
const pdf = require("pdfjs");
const fs = require("fs");
const run = async () => {
const doc = new pdf.Document();
doc.pipe(fs.createWriteStream("./test.pdf"));
doc.text("Hello World");
const table = doc.table({
widths: [256, 256],
padding: 5,
borderWidth: 1
});
const row1 = table.row();
row1.cell("I am text", {
textAlign: "justify",
backgroundColor: 0xdddddd
});
row1.cell("I am text hear me roar for a really long time. YAYs", {
textAlign: "justify",
backgroundColor: 0xeeeeee
});
const row2 = table.row();
row2.cell("I am text hear me roar for a really long time. YAYs", {
textAlign: "justify"
});
row2.cell("I am text", {
textAlign: "justify"
});
// const newDoc = await doc;
try {
await doc.end();
} catch (error) {
console.log(error);
}
};
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment