QuestPDF.Markdown 1.38.0

dotnet add package QuestPDF.Markdown --version 1.38.0
                    
NuGet\Install-Package QuestPDF.Markdown -Version 1.38.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QuestPDF.Markdown" Version="1.38.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QuestPDF.Markdown" Version="1.38.0" />
                    
Directory.Packages.props
<PackageReference Include="QuestPDF.Markdown" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add QuestPDF.Markdown --version 1.38.0
                    
#r "nuget: QuestPDF.Markdown, 1.38.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=QuestPDF.Markdown&version=1.38.0
                    
Install as a Cake Addin
#tool nuget:?package=QuestPDF.Markdown&version=1.38.0
                    
Install as a Cake Tool

<img src="/img/logo.svg?raw=true" width="128" align="right">

QuestPDF.Markdown

QuestPDF.Markdown allows rendering markdown into a QuestPDF document using the markdig parser.

Nuget Nuget Prerelease

QuestPDF.Markdown is not a HTML-to-PDF conversion library and does intend to become one. It aims to use markdown to add basic user-provided content into PDFs without the pitfalls of HTML-to-PDF conversion.

Usage

var text = """
           # Hello, world!

           *Greetings* from **markdown**!

           > Hello, back!
           """;

var document = Document.Create(container =>
{
    container.Page(page =>
    {
        page.PageColor(Colors.White);
        page.Margin(20);
        page.Content().Markdown(text);
    });
});

Usage

Styling the output

The styling used by QuestPDF.Markdown can be configured using the configure action.

var text = @"> Hello, world!";

var document = Document.Create(container =>
{
    container.Page(page =>
    {
        page.PageColor(Colors.White);
        page.Margin(20);
        page.Content().Markdown(text, options => 
        {
            options.BlockQuoteBorderColor = Colors.Red.Medium;
            options.BlockQuoteBorderThickness = 5;
        });
    });
});

Rendering images

By default, downloading and rendering external images is disabled. Images can be downloaded using the ParsedMarkdownDocument.DownloadImages() method. The parsed markdown document can then be passed to the Markdown() extension method.

var text = @"![title](https://placehold.co/100x50.jpg)";

var markdown = ParsedMarkdownDocument.FromText(text);
await markdown.DownloadImages(httpClient: myHttpClient /* Optionally provide your own HttpClient */);

var document = Document.Create(container =>
{
    container.Page(page =>
    {
        page.PageColor(Colors.White);
        page.Margin(20);
        page.Content().Markdown(markdown);
    });
});

Rendering custom text

In some cases it can be helpful to render custom text content in the PDF (e.g. allowing a user to inject the page number).

This is possible by using the template tag feature:

var text = @"This is page {currentPage}/{totalPages}";

var document = Document.Create(container =>
{
    container.Page(page =>
    {
        page.PageColor(Colors.White);
        page.Margin(20);
        page.Content().Markdown(text, options =>
        {
            options.AddTemplateTag("currentPage", t => t.CurrentPageNumber());
            options.AddTemplateTag("totalPages", t => t.TotalPages());
        }));
    });
});

Note that the template tags are only used to replace simple text content and not larger blocks like tables.

What's supported?

The aim of this library is to support all basic markdown functionality and some of the extensions supported by markdig.

Currently the following features are supported:

  • Headings
  • Block quotes
  • Code blocks
  • Lists (ordered, unordered)
  • Emphasis (bold, italic)
  • Task lists
  • Extra emphasis (subscript, superscript, strikethrough, marked, inserted)
  • Tables
  • Images
  • HTML encoded entities (e.g. &amp;, &lt;, &gt;)
  • Custom renderers for text content

Support for the following extensions is currently not planned:

  • Raw HTML
  • Math blocks
  • Diagrams

A full sample can be found in test.md and the resulting test.pdf.

Contributing

To quickly test changes made in the library, you can make use of the excellent QuestPDF previewer in combination with the QuestPDF.Markdown.Tests project and dotnet watch

To render the test markdown file in the companion app, first start the companion app and then run the following command in the root directory of the repository:

cd ./tests/QuestPDF.Markdown.Tests && dotnet watch test --filter Name=Render

To render the test markdown file in the previewer with additional background colors and margins, run the following command in the root directory of the repository:

cd ./tests/QuestPDF.Markdown.Tests && dotnet watch test --filter Name=RenderDebug

Any changes made to the MarkdownRenderer class will be automatically reflected in the previewer.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on QuestPDF.Markdown:

Package Downloads
Gnoe.Workflow

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.38.0 1,451 6/6/2025
1.37.0 455 5/28/2025
1.36.0 687 5/21/2025
1.35.0 166 5/20/2025
1.34.0 1,180 4/11/2025
1.33.0 2,833 3/22/2025
1.32.0 3,102 2/22/2025
1.31.1 422 2/19/2025
1.31.0 1,862 2/9/2025
1.30.0 7,706 1/25/2025
1.29.0 1,933 1/11/2025
1.28.0 16,105 12/21/2024
1.27.0 2,118 12/5/2024
1.26.0 1,238 11/25/2024
1.25.0 2,237 11/11/2024
1.24.0 131 11/8/2024
1.23.1 204 10/31/2024
1.23.0 186 10/28/2024
1.22.0 470 10/7/2024
1.22.0-beta.1 79 9/29/2024
1.21.0 2,587 8/28/2024
1.20.3 465 8/27/2024
1.20.2 2,641 8/13/2024
1.20.1 1,338 8/7/2024
1.20.0 117 8/5/2024
1.19.0 409 7/25/2024
1.18.0 537 7/18/2024
1.17.0 418 7/5/2024
1.16.0 2,439 6/21/2024
1.15.0 18,039 6/12/2024
1.14.0 1,047 5/27/2024
1.13.0 145 5/24/2024
1.12.0 161 5/23/2024
1.11.1 254 5/15/2024
1.11.0 133 5/13/2024
1.10.0 285 5/6/2024
1.9.0 5,263 4/29/2024
1.8.0 205 4/22/2024
1.8.0-beta.4 86 4/1/2024
1.8.0-beta.3 96 3/27/2024
1.8.0-beta.2 79 3/20/2024
1.8.0-beta.1 78 3/2/2024
1.8.0-alpha 148 2/20/2024
1.7.3 1,573 4/1/2024
1.7.2 141 4/1/2024
1.7.1 2,252 3/2/2024
1.7.0 6,612 2/20/2024
1.6.1 159 2/16/2024
1.6.0 1,861 2/7/2024
1.5.0 662 2/2/2024
1.4.0 1,052 12/27/2023
1.3.1 198 12/22/2023
1.3.0 1,006 12/8/2023
1.2.0 259 11/19/2023
1.1.0 1,484 11/15/2023
1.0.1 153 11/14/2023
1.0.0 321 11/13/2023
1.0.0-alpha.6 82 11/12/2023
1.0.0-alpha.5 81 11/12/2023