DEPRECATED: Following a more reliable release of the Export functionality within Notion, this tool is no longer fully necessary.
Converts pages exported from Notion as Markdown into PDF files using the command line due to browser rendering issues.
Provided by default within the application, Notion's "Export -> Print as PDF" functionality only allows a single page to be printed to PDF at a time. As a result, formatting issues occur in most cases (e.g. multiline code snippets) from the browser attempting to render the markup unsuccessfully.
Markdown Files -> marked -> HTML Files -> wkhtmltoPDF -> PDF Files
The methodology used by this tool is simply to take exported Markdown pages from Notion, individually or in bulk, uncompress the downloaded archive and then process each by first parsing into HTML using marked
and then converting to PDF using wkhtmltopdf
.
Note: wkhtmltopdf
is used instead of other PhantomJS
-based methods which seem to suffer some similar defects (#10373, #10669, #13524) as the browser, even though both are using the QtWebKit rendering engine.
Use your ideal package manager for Node and install globally.
Yarn
yarn global add notion-md-pdf
NPM
npm install notion-md-pdf -g
Call the following shell command with the desired zip archive of Markdown files as the first argument.
notion-md-pdf Export-XXXXXX.zip
# Conversion completed: ~/Document-Name-XXXXXX-1.pdf
notion-md-pdf Document-Name-XXXXXX.md
# Conversion completed: ~/Document-Name-XXXXXX-1.pdf
Windows (64-bit), Mac OS X (64-bit), and Linux (32-bit) (64-bit) OS are supported.
Based on the version of wkhtmltopdf
that is downloaded from a CDN by the post installation script.
Feel free to submit a pull request at any time.
This project is licensed under the MIT License - see the LICENSE file for details