2021-08-26 22:25:33 +02:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2021-08-25 03:40:16 +02:00
|
|
|
using NUnit.Framework;
|
2021-08-09 22:35:39 +02:00
|
|
|
using QuestPDF.Examples.Engine;
|
|
|
|
|
using QuestPDF.Fluent;
|
|
|
|
|
using QuestPDF.Helpers;
|
|
|
|
|
using QuestPDF.Infrastructure;
|
|
|
|
|
|
|
|
|
|
namespace QuestPDF.Examples
|
|
|
|
|
{
|
|
|
|
|
public class TextExamples
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TextElements()
|
|
|
|
|
{
|
|
|
|
|
RenderingTest
|
|
|
|
|
.Create()
|
2021-08-25 03:40:16 +02:00
|
|
|
.PageSize(PageSizes.A4)
|
2021-08-09 22:35:39 +02:00
|
|
|
.FileName()
|
|
|
|
|
.ProducePdf()
|
|
|
|
|
.Render(container =>
|
|
|
|
|
{
|
2021-08-25 03:40:16 +02:00
|
|
|
container
|
|
|
|
|
.Padding(20)
|
|
|
|
|
.Box()
|
|
|
|
|
.Border(1)
|
|
|
|
|
.Padding(5)
|
|
|
|
|
.Text(text =>
|
|
|
|
|
{
|
|
|
|
|
text.Span("Let's start with bold text. ", TextStyle.Default.Bold().BackgroundColor(Colors.Grey.Lighten3).Size(16));
|
|
|
|
|
text.Span("Then something bigger. ", TextStyle.Default.Size(28).Color(Colors.DeepOrange.Darken2).BackgroundColor(Colors.Yellow.Lighten3).Underlined());
|
|
|
|
|
text.Span("And tiny teeny-tiny. ", TextStyle.Default.Size(6));
|
|
|
|
|
text.Span("Stroked text also works fine. ", TextStyle.Default.Size(14).Stroked().BackgroundColor(Colors.Grey.Lighten4));
|
2021-08-26 22:25:33 +02:00
|
|
|
//text.NewLine();
|
2021-08-25 03:40:16 +02:00
|
|
|
text.Span("Is it time for lorem ipsum? ", TextStyle.Default.Size(12).Underlined().BackgroundColor(Colors.Grey.Lighten3));
|
|
|
|
|
text.Span(Placeholders.LoremIpsum(), TextStyle.Default.Size(12));
|
|
|
|
|
|
2021-08-26 22:25:33 +02:00
|
|
|
//text.NewLine();
|
2021-08-25 03:40:16 +02:00
|
|
|
text.Span("And now some colors: ", TextStyle.Default.Size(16).Color(Colors.Green.Medium));
|
|
|
|
|
|
|
|
|
|
foreach (var i in Enumerable.Range(1, 100))
|
|
|
|
|
{
|
|
|
|
|
text.Span($"{i}: {Placeholders.Sentence()} ", TextStyle.Default.Size(12 + i / 5).LineHeight(2.75f - i / 50f).Color(Placeholders.Color()).BackgroundColor(Placeholders.BackgroundColor()));
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-08-09 22:35:39 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|