Files
QuestPDF/Source/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);
2022-03-13 22:47:06 +01:00
page.PageColor(Colors.White);
2021-10-23 02:59:47 +02:00
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-11 13:23:36 +01:00
text.Span(Placeholders.Sentence()).FontColor(Colors.Red.Medium);
2021-10-23 02:59:47 +02:00
});
});
});
});
}
}
}