Generate a GitHub-styled PDF from a local or online Markdown document.
I wrote this because I was tired of wrestling with pandocs trying to get my Gist-hosted resume into a nice, GitHub-styled PDF. Plus it was a fun exercise!
-
Clone from GitHub:
git clone https://github.com/noelleleigh/pdf-from-markdown.git
-
Enter cloned directory:
cd ./pdf-from-markdown
-
Install dependencies:
npm install
-
Run with Node.js. Usage:
$ node ./index.js --help index.js <inputPath> <outputPath> Convert a Markdown file to a PDF File with GitHub styling Positionals: inputPath Path/URL of a Markdown file [string] outputPath Path of the output PDF file [string] Options: --help Show help [boolean] --version Show version number [boolean] --scale Scale of the webpage rendering, between 0.1 and 2. [number] [default: 0.8] --preview Get a look at the document instead of rendering it as a PDF [boolean]
Generate a PDF from an online file:
node ./index.js https://www.example.com/document.md ./document.pdf
Generate a PDF from a local file with a scale factor of 0.75:
node ./index.js C:/Documents/resume.md ./resume.pdf --scale 0.75
- marked: Markdown parsing
- github-markdown-css: GitHub CSS styling
- puppeteer: PDF rendering