Files
QuestPDF/Source/QuestPDF.Examples/MinimalApiExamples.cs
T

53 lines
1.8 KiB
C#
Raw Normal View History

2022-02-20 16:17:43 +01:00
using System.Diagnostics;
using NUnit.Framework;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
public class MinimalApiExamples
{
[Test]
public void MinimalApi()
{
Document
.Create(container =>
{
container.Page(page =>
{
2022-03-08 17:27:30 +01:00
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
2022-03-13 22:47:06 +01:00
page.PageColor(Colors.White);
page.DefaultTextStyle(x => x.FontSize(20));
2022-02-28 15:41:10 +01:00
page.Header()
2022-03-13 22:47:06 +01:00
.Text("Hello PDF!")
.SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
2022-02-28 15:41:10 +01:00
page.Content()
.PaddingVertical(1, Unit.Centimetre)
.Column(x =>
{
2022-03-08 17:27:30 +01:00
x.Spacing(20);
2022-02-28 15:41:10 +01:00
x.Item().Text(Placeholders.LoremIpsum());
x.Item().Image(Placeholders.Image(200, 100));
});
2022-03-08 17:27:30 +01:00
page.Footer()
.AlignCenter()
.Text(x =>
{
x.Span("Page ");
x.CurrentPageNumber();
});
2022-02-20 16:17:43 +01:00
});
})
.GeneratePdf("hello.pdf");
Process.Start("explorer.exe", "hello.pdf");
}
}
}