Skip to content

.NET library serving as a converter of markdown text to PDF, supporting fully customizable styling and plugins

Notifications You must be signed in to change notification settings

geertjanthomas/MarkdownToPdf

 
 

Repository files navigation

MarkdownToPdf Library

MarkdownToPdf is a .NET library serving as a converter of markdown text to PDF. It supports fully customizable styling via cascading styles, page setup, headers and footers, page numbering, sections, page and sections breaks and it also supports plugins for features like syntax highlighting or for displaying mathematical expressions. Technically it uses markdig library to parse the markdown document and Pdfsharp/Migradoc library to render the output. It also uses ImageSharp from SixLabors to handle cross platform image rendering.

Disclaimer

This is a fresh fork from https://github.com/tkubec/MarkdownToPdf and upgraded to .NET 10.

Not yet everything is ported and tested fully.

The aim is to keep up the support for new .NET versions and to ensure cross platform compatibility

Supported markdown flavors and extensions

  • basic and github markdown
  • Pipe tables
  • Grid tables
  • Extra emphasis (strike through ~~,Subscript ~ Superscript ^ Inserted ++ Marked ==)
  • Special attributes for applying styles and formatting
  • Footnotes
  • Task Lists
  • Citation text by enclosing ""...""
  • Custom containers similar to fenced code block :::
  • Mathematics/Latex extension by enclosing $$ for block and $ for inline math
  • SmartyPants

For details, see markdig documentation and this project documentation.

Basic Usage

The basic usage is pretty straightforward:

  • create an instance of MarkdownToPdf
  • optionally set-up the page layout
  • optionally modify or add styles
  • add the markdown text
  • save

E.g.:

var pdf = new MarkdownToPdf();

pdf
    .Add("# Hello, Wolrd")
    .Save("output.pdf");

Please see the documentation for more information. Here are some sample PDF outputs:

Installation

The library is available as a NuGet package:

Plugins

Syntax highlighter

MarkdownToPdf.SyntaxHighlighter based on PrismSharp currently supports over 270 programming languages and has 44 built in visual themes

License

This software is released under the MIT license.

About

.NET library serving as a converter of markdown text to PDF, supporting fully customizable styling and plugins

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • C# 100.0%