[Practical Tips] Teach You to Convert Markdown to PDF, PNG, JPEG

[Practical Tips] Teach You to Convert Markdown to PDF, PNG, JPEG

Markdown, as a very easy-to-master document format, is being used by more and more people to write documents, resumes, blogs, etc.

Last updated 5/8/2022 7:00 PM
青城 网上冲浪程序员
4 min read
Category
Sharing
Tags
Markdown PDF

Table of Contents

  1. Introduction
  2. Today's Star
  3. Summary
  4. Webmaster's Additional Notes

1. Introduction

Markdown, as a very easy-to-grasp document format, is increasingly used by people for writing documentation, resumes, blogs, and more.

However, if the target users' computers don't have a Markdown editor, they won't be able to see the preview. Therefore, when sending documents to clients or others, it's common to convert Markdown files to formats like PDF.

Initially, I used the Typora editor, which had a great built-in export feature, but it has now become paid software.

2. Today's Star

Nowadays, VS Code is incredibly powerful. By using VS Code along with the Markdown Preview Enhanced extension, you can easily export Markdown files to PDF and other formats.

This extension for VS Code even allows you to choose themes, and it's very simple to use. Below are the steps to export a Markdown file to a PDF file:

  1. Install the Markdown Preview Enhanced extension in VS Code.

  1. Restart VS Code.

  2. Create a new Markdown file and write some Markdown content, for example:

  1. Right-click inside the document:

  1. Select MPE: Open Preview to the Side or use the shortcut Ctrl + K V (the one shown above is for Mac) to preview the Markdown rendering:

  1. Right-click in the preview window to bring up the menu:

  1. Click Chrome (Puppeteer) > PDF to export the Markdown file to PDF. As shown, it automatically opens the default PDF viewer on your computer:

3. Summary

Currently, Markdown Preview Enhanced supports exporting to PDF, PNG, JPEG, and other formats.

Here's a little surprise: you can use the Preview Theme menu option at the bottom to choose a theme you like before exporting.

Of course, this article only covers a small part of the extension's features — it's quite powerful, so feel free to explore it.

4. Webmaster's Additional Notes

The webmaster recorded a GIF animation of using the Markdown Preview Enhanced extension to export a Markdown file to PDF. See how great it looks. The exported file is saved in the same directory as the original Markdown file by default:

I usually use mdnice to edit Markdown files, and it also has a PDF export feature:

Click the "More Settings" in the image above. You can choose whether to display file information (file export time, file URL) in the header and footer. Usually, this is left unchecked:

Below is the PDF file exported with the header and footer option checked:

And below is the same PDF file exported with the header and footer option unchecked:

  • The advantage of the Markdown Preview Enhanced extension for VS Code is that it is free, has no watermark, requires no internet connection, and once installed, you can use it immediately. It exports not only PDF but also PNG, JPEG, etc.
  • The advantage of mdnice is that after logging in, you can save your editing history. Currently, it can only export PDF files and only works online, but it is also free.

Which one to use is up to you (personally, I recommend the VS Code extension, haha).

Follow me for occasional tips and tricks for programmers.

Keep Exploring

Related Reading

More Articles
Same tag 1/17/2025

Markdown Rendering in Avalonia UI

This article will detail how to use Markdown.AIRender for Markdown rendering in Avalonia UI, including installation, style referencing, example demonstrations, and various features (such as support for black/white themes, accent colors, etc.). It also delves into its ongoing internationalization features, aiming to help developers better integrate Markdown content into Avalonia applications, provide a better user experience, and enhance the application's global adaptation capabilities. Additionally, it compares related Markdown rendering libraries to provide users with a reference for choosing the right tool.

Continue Reading
Same tag 7/16/2022

C# Convert PDF to Image

Today, a colleague told me that the PDF file you obtained doesn't quite fit our existing software workflow, so can you convert our PDF file to an image?

Continue Reading