A command line markdown to pdf converter with support for page headers, footers, and custom stylesheets. Mdpdf is incredibly configurable and has a JavaScript API for more extravogant usage.
For examples of how to use headers and footers, see the examples directory.
Install globally to use from the command line.
npm install mdpdf -g
Install locally to access the API.
npm install mdpdf --save
mdpdf README.md - Simple convert using GitHub Markdown CSS and some additional basic stylings.mdpdf README.md --style styles.css --header header.hbs --hHeight 22 - Convert with custom styling with a header of height 22mm.--style A single css stylesheet you wish to apply to the PDF--header A HTML (.html) file to inject into the header of the PDF--hHeight The height of the header section in mm--footer A HTML (.html) file to inject into the footer of the PDF--fHeight The height of the footer section in mm--noEmoji Disables emoji conversions--debug Save the generated html for debugging--help Display this menu--version Displays the application versionIn text emoji's are also supported, but there are a few instances of shorthand which do not work and require the longhand version, i.e. :+1: doesn't work but :thumbsup: will.
The API is very straight forward with a single function convert() which takes some options. The convert method uses a promise generated by the Bluebird.js library. For a full example see the bin/index.js!
const mdpdf = require('mdpdf'); let options = { source: path.join(__dirname, 'README.md'), destination: path.join(__dirname, 'output.pdf'), styles: path.join(__dirname, 'md-styles.css'), pdf: { format: 'A4' }}; mdpdf.convert(options).then((pdfPath) => { console.log('PDF Path:', pdfPath);}).catch((err) => { console.error(err);});false to turn this stylesheet off.false to turn stylesheet off..hbs) file which will be your header. If you set this, you must set the header height (see below).