diff --git a/commands/pdfpresgen.js b/commands/pdfpresgen.js index 57edcf1..7e38fdf 100644 --- a/commands/pdfpresgen.js +++ b/commands/pdfpresgen.js @@ -12,7 +12,7 @@ const log = logging.create(import.meta.url); const title_box = { x: 17, y: 415, width: 405, align: "center" }; const summary_box = { width: 405, height: 540 }; const main_title = { align: "center", width: 1196, height: 883, x: 586, y: 99}; -const main_box = { width: 928, height: 535, x: 720, y: 273}; +const main_box = { width: 928, height: 535, x: 720, y: 323}; export const description = "Generates a PDF presentation from an input .md file and a background template." @@ -77,17 +77,17 @@ const write_page = (doc, template, content) => { if(content.type == "title-bullets") { - doc.fontSize(80); + doc.fontSize(120); // add the title/body text doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); - doc.fontSize(40); + doc.fontSize(80); doc.list(content.slide_body, main_box.x, main_box.y, main_box); } else if(content.type == "title-image") { // it's a title only slide - doc.fontSize(80); + doc.fontSize(120); // add the title/body text doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); @@ -98,16 +98,24 @@ const write_page = (doc, template, content) => { }); } else if(content.type == "title-only") { // it's a title only slide - doc.fontSize(80); - doc.font("heading").text(content.slide_title, main_title.x, main_title.y + (main_title.height / 3), main_title); + doc.fontSize(160); + doc.font("heading").text(content.slide_title, main_title.x, main_title.y + (main_title.height / 3.5), main_title); } else { // this handles title-text slides, and anything else - doc.fontSize(80); + doc.fontSize(120); // add the title/body text doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); - doc.fontSize(40); - doc.font("body").text(content.slide_body, main_box.x, main_box.y, main_box); + // if I put a # I want this to be a subtitle + if(content.slide_body.startsWith("#")) { + doc.fontSize(100); + const trim_body = content.slide_body.slice(1).trim(); + doc.font("body").text(trim_body, main_box.x, main_box.y, {align: "center", ...main_box}); + } else { + doc.fontSize(60); + doc.font("body").text(content.slide_body, main_box.x, main_box.y, main_box); + } + } } @@ -165,19 +173,17 @@ export const main = async (opts) => { const pages = parse_input(opts.input); - for(let page of pages) { + for(let i = 0; i < pages.length; i++) { + const page = pages[i]; + console.log("PAGE", page); write_page(doc, opts.template, page); - next_page(doc); - } - write_page(doc, opts.template, { - "title": pages[0].title, - "summary": pages[0].summary, - "slide_title": "The End", - "slide_body": "See you soon.", - "type": "title-text" - }); + // don't add a page when at the end + if(i !== pages.length - 1) { + next_page(doc); + } + } end_pdf(doc); } catch(error) { diff --git a/scripts/pdfpres_example.md b/scripts/pdfpres_example.md index b60feac..e6fab64 100644 --- a/scripts/pdfpres_example.md +++ b/scripts/pdfpres_example.md @@ -20,3 +20,6 @@ Image Slide --- Slide Title Only --- +The End + +# Next, Your Setup