How to hide the header content of the Markdown PDF plug-in in Vscode

Recently, there was a need to convert markdown documents into pdf files. Since I was completing this task on a 2014 MacBook, I didn’t want to install additional software (there are many such software on Linux and can even be completed from the command line). I wanted to use vscode to complete it directly. , after all, vscode is used every day.

Markdown PDF is a plug-in related to vscode with high download volume. After using it, I found that header and footer will be added by default.

markdown pdf

The left side of the header is the file name, the right side is the time after formatting: YYYY-MM-DD, and the bottom is the page number.

The page number time is still acceptable, but the file name has also been adjusted by default. To me, this is really superfluous.

Remove the header information of markdonw pdf

The method to remove this is very simple. Find the setting options of the plug-in and change the corresponding setting items.

markdown pdf settings

Before Header Template changes:

1<div style="font-size: 9px; margin-left: 1cm;"> <span class='title'></span></div> <div style="font-size: 9px; margin-left: auto; margin-right: 1cm;">%%ISO-DATE%%</div>

After changes:

1<div style="font-size: 9px; margin-left: 1cm; display: none;"> <span class='title'></span></div> <div style="font-size: 9px; margin-left: auto; margin-right: 1cm; display: none;">%%ISO-DATE%%</div>

That's right, just add display: none; in the style, so that the header will not be included after converting to PDF. Of course, you can also choose to hide one of them, or keep them all.

I chose to keep the page numbers of the footer. After all, it is somewhat useful, has no interference, and can be understood by junior high school students.

Judging from the code information above, users who need it can completely define the content. For example, if you want to make a PDF e-book and display specific content at the head or tail, in this case, the header and footer will automatically The definition comes into play.

how to use

How to use official documentation

Command mode:

Just open the md file, press F1, enter export, and then select the format you want to export.

  1. Open the Markdown file
  2. Press F1 or Ctrl+Shift+P
  3. Type export and select below
    • markdown-pdf: Export (settings.json)
    • markdown-pdf: Export (pdf)
    • markdown-pdf: Export (html)
    • markdown-pdf: Export (png)
    • markdown-pdf: Export (jpeg)
    • markdown-pdf: Export (all: pdf, html, png, jpeg)

Menu mode, this method is the simplest. After opening the file, just right-click and select.

  1. Opn the Markdown file
  2. Right click and select below
    • markdown-pdf: Export (settings.json)
    • markdown-pdf: Export (pdf)
    • markdown-pdf: Export (html)
    • markdown-pdf: Export (png)
    • markdown-pdf: Export (jpeg)
    • markdown-pdf: Export (all: pdf, html, png, jpeg)

In addition, this plug-in also has many advanced customization functions, which are not used for the time being. Readers who need it can study it. When exported to png, it will be a long picture, which is quite interesting.

Lastmod: Friday, April 12, 2024

See Also:

Translations: