-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment: produce PDF with Puppeteer (#6)
This is currently only a sketch of how the final solution could look like. Still missing: - [x] parameterize with filename and variables from meta.yaml - [x] integrate into Github workflow - [x] only generate PDF if HTML or Markdown have changed - [ ] extract inline styles to `odata.css`?
- Loading branch information
Showing
7 changed files
with
1,445 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import pdf from './pdf.js'; | ||
import url from "url"; | ||
|
||
await pdf("odata-data-aggregation-ext"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const puppeteer = require('puppeteer'); | ||
const fs = require("fs"); | ||
const url = require("url"); | ||
const yaml = require("js-yaml"); | ||
|
||
module.exports = async function(name) { | ||
const meta = yaml.load(fs.readFileSync(__dirname + "/../" + name + "/meta.yaml")); | ||
|
||
const browser = await puppeteer.launch({ | ||
headless: "new" | ||
}); | ||
const page = await browser.newPage(); | ||
const htmlUrl = url.pathToFileURL(`${__dirname}/../docs/${name}/${name}.html`).href; | ||
await page.goto(htmlUrl, { | ||
waitUntil: "networkidle2", | ||
}); | ||
await page.pdf({ | ||
path: `${__dirname}/../docs/${name}/${name}.pdf`, | ||
format: "letter", | ||
displayHeaderFooter: true, | ||
headerTemplate: '<div style="font-size: 10px; width: 100%; text-align: center;">Standards Track Work Product</div>', | ||
footerTemplate: `<div style="font-size: 8px; width: 90%; margin: auto; margin-top: 40px; display:flex; flex-flow:row wrap;"> | ||
<span style="text-align: left; width: 30%;">${meta.filename}</span> | ||
<span style="text-align: center; width: 40%;">Copyright ${meta.copyright}. All Rights Reserved.</span> | ||
<span style="text-align: right; width: 30%;">${meta.pubdate} - Page <span class="pageNumber"></span> of <span class="totalPages"></span> | ||
</span></div>`, | ||
margin: { top: 50, bottom: 60 } | ||
}); | ||
|
||
await browser.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pagetitle: OData Extension for Data Aggregation Version 4.0 | ||
subtitle: Committee Specification Draft 04 | ||
filename: odata-data-aggregation-ext-csd04 | ||
pubdate: 24 May 2023 | ||
pubdateISO: '2023-05-24' | ||
copyright: © OASIS Open 2023 |
Oops, something went wrong.