Save As PDF Dialog

In addition to using a printer or browser to generate PDF output you can also use the direct PDF generation that's built in using the Save As Pdf Dialog. From this dialog you can directly generate a PDF document by providing a few document specific options.

Markdown Monster uses wkhtmltopdf which is a command line utility for converting HTML to PDF. MM renders the document to PDF using the active preview theme and then converts the generated HTML to PDF.

The command line tool has many options which are documented here:

Markdown Monster uses this dialog to collect some basic information for generating the PDF file via command line utility. Note that you can also capture the command line and optionally run the commands from the command line yourself, adding additional options from the reference above.

PDF Generation Configuration

The following provides additional info on the input fields of the form.

Title

The title is displayed at the top of the document on the left side. The text is taken as is and displayed on every page. You can optionally embed any of wkhtmltopdf's meta tags like [section], [page], [topage] etc.

The footer is displayed on the lower right of each page. As with the title you can embed meta tags into the text that will be expanded by the tool.

Page Size, Page Orientation and Image DPI

These are pretty self explanatory. Image DPI only refers to image DPI not the entire document as the document is created as text.

Margins

Margins for all four document sides can be specified in millimeters. 0 is the default and it looks like it provides about 1/2 inch side margins. Top margins are much smaller if there are there are headers and/or footers.

Generate Table of Contents

A table of contents is generated by default for the first 3 levels (H1,H2,H3) of the document. If you don't want a TOC, uncheck this checkbox.

Display PDF after Generation

You can optionally view the PDF in your default PDF viewer.

PDF Viewer Locks

If you have your PDF open in a PDF viewer, most likely the PDF file is locked and you won't be able to re-generate it resulting in an error.

Generate PDF File

Once all the settings have been made you're ready to generate your PDF file. If all goes well you should be able to view your newly generated PDF right away.

Executing wkhtmltopdf.exe explicitly

If an error occurs, an error message is displayed. Unfortunately wkhtmltopdf doesn't generate very helpful error messages on failures, but you can capture the command line and take a look at the command MM sends to run the PDF generation. Using the Copy Commandline Button captures the last exectued command line to the clipboard.

You can open a command Window in the Markdown Monster install folder (%localappdata%\MarkdownMonster by default) and then execute and modify the captured command line there.

Rendering Infidelities with wkhtml2pdf

Although wkhtmltopdf does a good job rendering HTML to PDF there it's not a perfect tool as there are differences in how PDF and HTML documents work.

Emojis and Special Characters

wkhtml2pdf uses UTF-8 to print documents and Markdown Monster also produces UTF-8 document output when it generates HTML. However, due to differences in font handling, multiple fonts are not treated the same in PDF generation. By default MM's fonts use standard system fonts with fallbacks to generic fonts that work on non-Windows systems. However, special characters like Emoji are different on each platform and the inability of wkhtml2pdf to mix-in multiple fonts results in a difference in font rendering for things like emojis.

To work around this Markdown Monster does the following in it's default theme.css templates that render output to prioritize local emoji fonts:

@media print {
    html, body {
        font-family: "Segoe UI Emoji", "Apple Color Emoji", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Helvetica, Arial, sans-serif;
        text-rendering: optimizeLegibility;
    }
    /*... more print/pdf specific css */
}

This works to print Emoji fonts, but it forces use of the specific emoji font. On Windows this uses Segoe UI Emoji rather than Segoe UI the former of which is a similar but different font. You can customize the fonts used to your preferences by manually editing theme.css from the Preview Window's Context Menu using Edit Template Themes.

Save As PDF FAQ

wkhtmltopdf is a Third Party Tool

Markdown Monster uses a third party library as a convenience feature. We'll address any issues that can be managed through the command line interface, but any rendering engine issues you may run into are not something we can fix. If you run into issues for this you can file an issue on Github:

See also

Printing and Generating PDF Output

© West Wind Technologies, 1996-2021 • Updated: 07/28/21
Comment or report problem with topic