thomaspark / pubcss

Format academic publications in HTML & CSS
http://thomaspark.co/2015/01/pubcss-formatting-academic-publications-in-html-css/
MIT License
791 stars 80 forks source link

Use puppeteer for generating the PDF's? #12

Open cbleslie opened 6 years ago

cbleslie commented 6 years ago

I figure we could make a gulp build, and run puppeteer (headless chrome) to export the PDF's? Thoughts?

https://github.com/GoogleChrome/puppeteer has an example of creating a PDF from a page:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
  await page.pdf({path: 'hn.pdf', format: 'A4'});

  await browser.close();
})();

Addtional docs: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions

galaxyblack commented 6 years ago

Yeah, there are tons of other open source options, you don't need to be uising prince.

thomaspark commented 6 years ago

Setting up a way to build with a more open option like Puppeteer would be welcome.

cbleslie commented 6 years ago

https://github.com/thomaspark/pubcss/pull/13

PR for this issue. ;)

7fe commented 6 years ago

@cbleslie if you look at the outputs of Chrome they do not match prince

cbleslie commented 6 years ago

@limeb Totally not perfect. I would love help with the issues, feel free to raise a PR if you have the time to look into rendering.