Skip to content

Instantly share code, notes, and snippets.

@flew2bits
Created March 11, 2023 18:48
Show Gist options
  • Save flew2bits/4135379e8b396d1bde0f9a1350dbe041 to your computer and use it in GitHub Desktop.
Save flew2bits/4135379e8b396d1bde0f9a1350dbe041 to your computer and use it in GitHub Desktop.
Sample of Markdown component for QuestPDF
using PdfExperiments;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Previewer;
Document.Create(doc =>
{
doc.Page(page =>
{
page.Size(PageSizes.Letter);
page.Margin(18);
page.Header().ShowOnce().PaddingBottom(10).Background(Colors.Black).AlignCenter().PaddingVertical(30).Text(Placeholders.Sentence())
.FontColor(Colors.White).Bold();
page.Content().Component(new MarkdownComponent(@$"
# {Placeholders.Label()}
This is a paragraph. It has **bold** and *italic* text and ***mixed** text* and even ***bold italic text*** which works now!
We can put more text onto the end of this.
## {Placeholders.Label()}
{Placeholders.Paragraph()}
{Placeholders.Paragraph()}
### {Placeholders.Label()}
{Placeholders.Paragraphs().Replace("\n", "\n\n")}
> {Placeholders.Paragraph()}
>
> {Placeholders.Paragraph()}
{Placeholders.Paragraph()}
### {Placeholders.Label()}
{Placeholders.Paragraphs().Replace("\n", "\n\n")}
## {Placeholders.Label()}
{Placeholders.Paragraphs().Replace("\n", "\n\n")}
### {Placeholders.Label()}
{Placeholders.Paragraphs().Replace("\n", "\n\n")}
1. List Item
2. List Item
3. List Item
"));
});
}).ShowInPreviewer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment