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

57 lines
1.9 KiB
C#
Raw Normal View History

using System;
using System.Linq;
using NUnit.Framework;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
2022-03-13 22:47:06 +01:00
public class PageBackgroundForegroundExample
{
[Test]
2022-03-13 22:47:06 +01:00
public void PageBackgroundForeground()
{
RenderingTest
.Create()
2022-03-13 22:47:06 +01:00
.ProduceImages()
.MaxPages(100)
.ShowResults()
.RenderDocument(document =>
{
document.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(1, Unit.Inch);
page.DefaultTextStyle(TextStyle.Default.FontSize(16));
2022-03-13 22:47:06 +01:00
page.PageColor(Colors.White);
2022-03-13 22:47:06 +01:00
const string transparentBlue = "#662196f3";
page.Background()
.AlignTop()
.ExtendHorizontal()
.Height(200)
.Background(transparentBlue);
2022-03-13 22:47:06 +01:00
page.Foreground()
.AlignBottom()
.ExtendHorizontal()
.Height(250)
.Background(transparentBlue);
page.Header().Text("Background and foreground").Bold().FontColor(Colors.Blue.Darken2).FontSize(36);
page.Content().PaddingVertical(25).Column(column =>
{
column.Spacing(25);
foreach (var i in Enumerable.Range(0, 100))
column.Item().Background(Colors.Grey.Lighten2).Height(75);
});
});
});
}
}
}