//Helpful tips here: https://codepen.io/blikblum/pen/gJNWMg?editors=1010
let blob;
let doc;
let txtTitle = "Da Title"; //Future ternary
let txtAuthor = "Da Author"; //Future ternary
let txtNotes = "I have lots of notes that I want to include in this map but I'm not sure how many characters I can put before I get to the end of the area that could be filled by such information. Maybe if I type lots of information I can tell how long this might be able to get to before I reach the limits. Or maybe this will get too long and I will need to come up with a different solution. But I could keep going juust to see when this actually cuts off and no longer produces any outputs on the screen. I have lots of notes that I want to include in this map but I'm not sure how many characters I can put* before I get to the end of t";
//txtNotes = "I have lots of notes that I want to include in this map but this is all.";
//txtNotes = "";
const dateOptions = {
year: "numeric",
month: "short",
day: "2-digit",
};
const date = new Date();
let txtDate = date.toLocaleString("en-US", dateOptions);
let txtDateAuth = `Date: ${txtDate}\nAuthor: ${txtAuthor}`
function generatePDF() {
doc = new window.PDFDocument({
pdfVersion: '1.6',
lang: 'en-US',
tagged: true,
displayTitle: true,
info: {
Title: txtTitle,
Author: txtTitle
},
size: "letter", //w,h: 792,612 ; //590 is right edge of map
layout: "landscape",
margin: 2
});
const stream = doc.pipe(blobStream());
// Initialise document logical structure
var struct = doc.struct('Document');
doc.addStructure(struct);
//Add outline: Thick border
doc.lineWidth(3);
doc.rect(15, 15, doc.page.width - 30, doc.page.height - 30);
doc.stroke();
//Add outline: thin border
doc.lineWidth(1);
doc.rect(20, 20, doc.page.width - 40, doc.page.height - 40);
doc.stroke();
//Add outline: Map area
doc.lineWidth(1);
doc.rect(30, 30, 560, doc.page.height - 60);
doc.stroke();
//...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.