QuestPDF.Markdown
1.26.0
dotnet add package QuestPDF.Markdown --version 1.26.0
NuGet\Install-Package QuestPDF.Markdown -Version 1.26.0
<PackageReference Include="QuestPDF.Markdown" Version="1.26.0" />
paket add QuestPDF.Markdown --version 1.26.0
#r "nuget: QuestPDF.Markdown, 1.26.0"
// Install QuestPDF.Markdown as a Cake Addin #addin nuget:?package=QuestPDF.Markdown&version=1.26.0 // Install QuestPDF.Markdown as a Cake Tool #tool nuget:?package=QuestPDF.Markdown&version=1.26.0
<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.
Usage
var text =
@"# Hello, world!
*Greetings* from **markdown**!
> Hello, back!";
var document = Document.Create(container =>
{
container.Page(page =>
{
page.Margin(20);
page.Content().Markdown(text);
});
});
Styling the output
The styling used by QuestPDF.Markdown can be configured using MarkdownRendererOptions
.
var text = @"> Hello, world!";
var options = new MarkdownRendererOptions
{
BlockQuoteBorderColor = Colors.Red.Medium,
BlockQuoteBorderThickness = 5
};
var document = Document.Create(container =>
{
container.Page(page =>
{
page.Margin(20);
page.Content().Markdown(text, options);
});
});
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.Margin(20);
page.Content().Markdown(markdown, options);
});
});
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.
&
,<
,>
)
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 previewer, run the following command in the root directory of the repository:
dotnet watch test --project ./tests/QuestPDF.Markdown.Tests -- --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:
dotnet watch test --project ./tests/QuestPDF.Markdown.Tests -- --filter Name=RenderDebug
Any changes made to the MarkdownRenderer class will be automatically reflected in the previewer.
Product | Versions 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 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
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.26.0 | 276 | 11/25/2024 |
1.25.0 | 610 | 11/11/2024 |
1.24.0 | 91 | 11/8/2024 |
1.23.1 | 158 | 10/31/2024 |
1.23.0 | 142 | 10/28/2024 |
1.22.0 | 379 | 10/7/2024 |
1.22.0-beta.1 | 52 | 9/29/2024 |
1.21.0 | 1,574 | 8/28/2024 |
1.20.3 | 263 | 8/27/2024 |
1.20.2 | 1,473 | 8/13/2024 |
1.20.1 | 753 | 8/7/2024 |
1.20.0 | 76 | 8/5/2024 |
1.19.0 | 170 | 7/25/2024 |
1.18.0 | 306 | 7/18/2024 |
1.17.0 | 373 | 7/5/2024 |
1.16.0 | 1,349 | 6/21/2024 |
1.15.0 | 15,966 | 6/12/2024 |
1.14.0 | 959 | 5/27/2024 |
1.13.0 | 119 | 5/24/2024 |
1.12.0 | 133 | 5/23/2024 |
1.11.1 | 204 | 5/15/2024 |
1.11.0 | 108 | 5/13/2024 |
1.10.0 | 259 | 5/6/2024 |
1.9.0 | 5,234 | 4/29/2024 |
1.8.0 | 176 | 4/22/2024 |
1.8.0-beta.4 | 72 | 4/1/2024 |
1.8.0-beta.3 | 83 | 3/27/2024 |
1.8.0-beta.2 | 65 | 3/20/2024 |
1.8.0-beta.1 | 61 | 3/2/2024 |
1.8.0-alpha | 113 | 2/20/2024 |
1.7.3 | 1,537 | 4/1/2024 |
1.7.2 | 116 | 4/1/2024 |
1.7.1 | 1,801 | 3/2/2024 |
1.7.0 | 6,576 | 2/20/2024 |
1.6.1 | 119 | 2/16/2024 |
1.6.0 | 915 | 2/7/2024 |
1.5.0 | 637 | 2/2/2024 |
1.4.0 | 809 | 12/27/2023 |
1.3.1 | 177 | 12/22/2023 |
1.3.0 | 983 | 12/8/2023 |
1.2.0 | 242 | 11/19/2023 |
1.1.0 | 1,464 | 11/15/2023 |
1.0.1 | 137 | 11/14/2023 |
1.0.0 | 188 | 11/13/2023 |
1.0.0-alpha.6 | 70 | 11/12/2023 |
1.0.0-alpha.5 | 68 | 11/12/2023 |