|
|
@ -12,7 +12,7 @@ const log = logging.create(import.meta.url); |
|
|
|
const title_box = { x: 17, y: 415, width: 405, align: "center" }; |
|
|
|
const title_box = { x: 17, y: 415, width: 405, align: "center" }; |
|
|
|
const summary_box = { width: 405, height: 540 }; |
|
|
|
const summary_box = { width: 405, height: 540 }; |
|
|
|
const main_title = { align: "center", width: 1196, height: 883, x: 586, y: 99}; |
|
|
|
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." |
|
|
|
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") { |
|
|
|
if(content.type == "title-bullets") { |
|
|
|
doc.fontSize(80); |
|
|
|
doc.fontSize(120); |
|
|
|
// add the title/body text
|
|
|
|
// add the title/body text
|
|
|
|
doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); |
|
|
|
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); |
|
|
|
doc.list(content.slide_body, main_box.x, main_box.y, main_box); |
|
|
|
|
|
|
|
|
|
|
|
} else if(content.type == "title-image") { |
|
|
|
} else if(content.type == "title-image") { |
|
|
|
// it's a title only slide
|
|
|
|
// it's a title only slide
|
|
|
|
doc.fontSize(80); |
|
|
|
doc.fontSize(120); |
|
|
|
// add the title/body text
|
|
|
|
// add the title/body text
|
|
|
|
doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); |
|
|
|
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") { |
|
|
|
} else if(content.type == "title-only") { |
|
|
|
// it's a title only slide
|
|
|
|
// it's a title only slide
|
|
|
|
doc.fontSize(80); |
|
|
|
doc.fontSize(160); |
|
|
|
doc.font("heading").text(content.slide_title, main_title.x, main_title.y + (main_title.height / 3), main_title); |
|
|
|
doc.font("heading").text(content.slide_title, main_title.x, main_title.y + (main_title.height / 3.5), main_title); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// this handles title-text slides, and anything else
|
|
|
|
// this handles title-text slides, and anything else
|
|
|
|
doc.fontSize(80); |
|
|
|
doc.fontSize(120); |
|
|
|
// add the title/body text
|
|
|
|
// add the title/body text
|
|
|
|
doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); |
|
|
|
doc.font("heading").text(content.slide_title, main_title.x, main_title.y, main_title); |
|
|
|
|
|
|
|
|
|
|
|
doc.fontSize(40); |
|
|
|
// if I put a # I want this to be a subtitle
|
|
|
|
doc.font("body").text(content.slide_body, main_box.x, main_box.y, main_box); |
|
|
|
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); |
|
|
|
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); |
|
|
|
console.log("PAGE", page); |
|
|
|
write_page(doc, opts.template, page); |
|
|
|
write_page(doc, opts.template, page); |
|
|
|
next_page(doc); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write_page(doc, opts.template, { |
|
|
|
// don't add a page when at the end
|
|
|
|
"title": pages[0].title, |
|
|
|
if(i !== pages.length - 1) { |
|
|
|
"summary": pages[0].summary, |
|
|
|
next_page(doc); |
|
|
|
"slide_title": "The End", |
|
|
|
} |
|
|
|
"slide_body": "See you soon.", |
|
|
|
} |
|
|
|
"type": "title-text" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end_pdf(doc); |
|
|
|
end_pdf(doc); |
|
|
|
} catch(error) { |
|
|
|
} catch(error) { |
|
|
|