Save As PDF Dialog

You can generate PDF output 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 a selectable preview theme and then converts the generated HTML to PDF.

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 command from the command line yourself, adding additional options from the reference above.

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

wkhtml2pdf PDF Generation Limitations

wkhtml2pdf works well for PDF creation, but it has a number of limitations and won't produce 100% accurate PDF output from your HTML rendered content. Specifically, fonts may not match, code snippets will not use syntax coloring and extended characters like emoticons may not work in some of the HTML themes.

It's recommended that you use the PDF Output Print Theme which is optimized for PDF output with basic formatting and fonts that support the widest variety of characters.

Alternate PDF Output: Print to PDF

As an alternative you can also use the Print Output (ctrl-p) and Save As PDF to create PDF output. This produces richer PDF output that preserves fonts and code snippets syntax coloring. However this raw print output does not produce a table of contents and doesn't allow control over page breaks.

PDF Generation Configuration

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

Document 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. You can embed wkhtml2pdf meta tags as with the title.

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.

This lets you select a preview theme that is used to render the HTML document that is converted to HTML. This is the same list of themes used for preview themes.

We highly recommend you use the default Pdf Output theme as that is optimized for PDF generation. As mentioned other themes may have problems with printing code snippets or representing extended characters. You can customize theme starting with the Pdf Output theme if you want to use different fonts or colors.

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.

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 wkhtml2pdf 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 executed 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 wkhtml2pdf 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

wkhtml2pdf 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

Generating PDF Output |

© West Wind Technologies, 2016-2023 • Updated: 10/23/21
Comment or report problem with topic