Files
QuestPDF/QuestPDF.Examples/DefaultTextStyleExample.cs
T

48 lines
1.6 KiB
C#
Raw Normal View History

2021-10-23 02:59:47 +02:00
using NUnit.Framework;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
public class DefaultTextStyleExample
{
[Test]
public void DefaultTextStyle()
{
RenderingTest
.Create()
.ProducePdf()
2021-10-23 02:59:47 +02:00
.ShowResults()
.RenderDocument(container =>
{
container.Page(page =>
{
// all text in this set of pages has size 20
page.DefaultTextStyle(TextStyle.Default.Size(20));
page.Margin(20);
page.Size(PageSizes.A4);
page.Background(Colors.White);
page.Content().Column(column =>
2021-10-23 02:59:47 +02:00
{
column.Item().Text(Placeholders.Sentence());
2021-10-23 02:59:47 +02:00
column.Item().Text(text =>
2021-10-23 02:59:47 +02:00
{
// text in this block is additionally semibold
text.DefaultTextStyle(TextStyle.Default.SemiBold());
text.Line(Placeholders.Sentence());
// this text has size 20 but also semibold and red
2022-03-08 17:27:30 +01:00
text.Span(Placeholders.Sentence()).Color(Colors.Red.Medium);
2021-10-23 02:59:47 +02:00
});
});
});
});
}
}
}