All Projects → BlueHatbRit → Mdpdf

BlueHatbRit / Mdpdf

Licence: apache-2.0
Markdown to PDF command line app with support for stylesheets

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Mdpdf

Gotenberg Go Client
Go client for the Gotenberg API
Stars: ✭ 35 (-93.16%)
Mutual labels:  markdown, pdf, pdf-converter
Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (-74.02%)
Mutual labels:  pdf, converter, pdf-converter
Doctron
Docker-powered html convert to pdf(html2pdf), html to image(html2image like jpeg,png),which using chrome(golang) kernel, add watermarks to pdf, convert pdf to images etc.
Stars: ✭ 141 (-72.46%)
Mutual labels:  pdf, converter, pdf-converter
Mybox
Easy tools of document, image, file, network, location, color, and media.
Stars: ✭ 45 (-91.21%)
Mutual labels:  markdown, pdf, converter
Gulp Markdown Pdf
Markdown to PDF
Stars: ✭ 56 (-89.06%)
Mutual labels:  markdown, pdf, converter
Remarks
Extract highlights, scribbles, and annotations from PDFs marked with the reMarkable tablet. Export to Markdown, PDF, PNG, and SVG
Stars: ✭ 94 (-81.64%)
Mutual labels:  markdown, pdf, pdf-converter
Gotenberg Php Client
PHP client for the Gotenberg API
Stars: ✭ 80 (-84.37%)
Mutual labels:  markdown, pdf, pdf-converter
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+361.91%)
Mutual labels:  markdown, pdf, converter
Pdf Flipbook
Browse PDF document like a book turning its pages
Stars: ✭ 279 (-45.51%)
Mutual labels:  pdf, pdf-converter
Python Automation Scripts
Simple yet powerful automation stuffs.
Stars: ✭ 292 (-42.97%)
Mutual labels:  pdf, pdf-converter
Node Html Pdf
📄 Html to pdf converter in nodejs. It spawns a phantomjs process and passes the pdf as buffer or as filename.
Stars: ✭ 3,364 (+557.03%)
Mutual labels:  pdf, pdf-converter
Pdf To Markdown
A PDF to Markdown converter
Stars: ✭ 270 (-47.27%)
Mutual labels:  markdown, pdf-converter
node-poppler
Asynchronous node.js wrapper for the Poppler PDF rendering library
Stars: ✭ 97 (-81.05%)
Mutual labels:  converter, pdf-converter
Pandoc Latex Template
A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
Stars: ✭ 3,750 (+632.42%)
Mutual labels:  markdown, pdf
Markdown Pdf
Convert markdown to pdf, png or jpeg on the fly in Atom
Stars: ✭ 250 (-51.17%)
Mutual labels:  markdown, pdf
Letter Boilerplate
Finest letter typesetting from the command line
Stars: ✭ 374 (-26.95%)
Mutual labels:  markdown, pdf
Md To Pdf
Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
Stars: ✭ 374 (-26.95%)
Mutual labels:  markdown, pdf
Gotenberg
A Docker-powered stateless API for PDF files.
Stars: ✭ 3,272 (+539.06%)
Mutual labels:  markdown, pdf
Minder
Mind-mapping application for Elementary OS
Stars: ✭ 306 (-40.23%)
Mutual labels:  markdown, pdf
Crowbook
Converts books written in Markdown to HTML, LaTeX/PDF and EPUB
Stars: ✭ 399 (-22.07%)
Mutual labels:  markdown, pdf

MDPDF - Markdown to PDF converter

NPM version code style: prettier

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.

If you're using the Atom text editor, checkout the markdown-pdf plugin which uses mdpdf.

Sponsor this project

This project is actively maintained during evenings and weekends. If you or your company find it useful, please consider supporting the project through sponsorship.

Contributions

If you wish to report bugs or contribute fixes and features, please see the contributors guide

Installation

Install globally to use from the command line.

npm install mdpdf -g

Install locally to access the API.

npm install mdpdf --save

Example usage

  • 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.

Options

  • --style=<filename> - A single css stylesheet you wish to apply to the PDF
  • --header=<filename> - A HTML (.html) file to inject into the header of the PDF
  • --h-height=<height> - The height of the header section
  • --footer=<filename> - A HTML (.html) file to inject into the footer of the PDF
  • --f-height=<height> - The height of the footer section
  • --border=<size> - Border (top, left, bottom, right; default: 20mm)
  • --border-top=<size> - Top border (default: 20mm)
  • --border-left=<size> - Left border (default: 20mm)
  • --border-bottom=<size> - Bottom border (default: 20mm)
  • --border-right=<size> - Right border (default: 20mm)
  • --gh-style - Enable default gh-styles, when --style is used
  • --no-emoji - Disables emoji conversions
  • --debug - Save the generated html for debugging
  • --help - Display this menu
  • --version - Display the application version
  • --format=<format> - PDF size format: A3, A4, A5, Legal, Letter, Tabloid (Default: A4)
  • --orientation=<orientation> - PDF orientation: portrait or landscape (Default: portrait)

Length parameters (<height> and <size>) require a unit. Valid units are mm, cm, in and px.

Headers and footers

Mdpdf is powered by Puppeteer, the headless Chrome browser project by Google. Puppeteer provides a number of header and footer html classes which can be used to insert things such as page numbers.

Note: mdpdf pre-2.x made use of Phantom.js which had considerably better support for headers and footers, and including better styling support for them. Sadly Phantom.js is no longer supported and had a number of other rendering bugs meaning it was no longer possible to support it as a core component of mdpdf. If you previously relied on good header and footer support you may wish to stick with 1.x releases until Puppeteer prioritises better header and footer support. Currently headers and footers do work in 2.x+ releases, but their styles must be handled independently of the main markdown file via --styles options and a few css tags do not work correctly. Past this there shouldn't be any issues with 2.x+ headers and footers.

Environment variables

  • MDPDF_STYLES - The full path to a stylesheet you wish to use if --style is not specified when calling mdpdf from the command line.

Emoji support

In 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. 👍 doesn't work but 👍 will.

Programatic API

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!

Example API usage

const mdpdf = require('mdpdf');
const path = require('path');

let options = {
    source: path.join(__dirname, 'README.md'),
    destination: path.join(__dirname, 'output.pdf'),
    styles: path.join(__dirname, 'md-styles.css'),
    pdf: {
        format: 'A4',
        orientation: 'portrait'
    }
};

mdpdf.convert(options).then((pdfPath) => {
    console.log('PDF Path:', pdfPath);
}).catch((err) => {
    console.error(err);
});

Options

  • source (required) - Full path to the source markdown file.
  • destination (required) - Full path to the destination (pdf) file.
  • styles - Full path to a single css stylesheet which is applied last to the PDF.
  • ghStyle - Boolean value of whether or not to use the GitHub Markdown CSS, defaults to false.
  • defaultStyle - Boolean value of whether or not to use the additional default styles. These styles provide some things like a basic border and font size. Defaults to false.
  • header - Full path to a the Handlebars (.hbs) file which will be your header. If you set this, you must set the header height (see below).
  • debug - An optional path that can be set to cause the intermediate HTML to be saved to a the desired path.
  • pdf (required) - An object which contains some sub parameters to control the final PDF document
    • format (required) - Final document format, allowed values are "A3, A4, A5, Legal, Letter, Tabloid"
    • orientation - Final document size orientation, allowed values are "potrait, orientation"
    • header - A sub object which contains some header settings
      • height - Height of the documents header in mm (default 45mm). If you wish to use a header, then this must be set.
    • border - The document borders
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].