2021-10-11 01:48:12 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Linq;
|
2021-10-23 02:59:47 +02:00
|
|
|
|
using System.Reflection.Metadata.Ecma335;
|
2021-10-11 01:48:12 +02:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
using QuestPDF.Examples.Engine;
|
|
|
|
|
|
using QuestPDF.Fluent;
|
|
|
|
|
|
using QuestPDF.Helpers;
|
2021-10-11 22:48:44 +02:00
|
|
|
|
using QuestPDF.Infrastructure;
|
2021-10-11 01:48:12 +02:00
|
|
|
|
|
|
|
|
|
|
namespace QuestPDF.Examples
|
|
|
|
|
|
{
|
|
|
|
|
|
public class InlinedExamples
|
|
|
|
|
|
{
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Inlined()
|
|
|
|
|
|
{
|
|
|
|
|
|
RenderingTest
|
|
|
|
|
|
.Create()
|
2021-10-11 22:48:44 +02:00
|
|
|
|
.PageSize(800, 650)
|
2021-10-11 01:48:12 +02:00
|
|
|
|
.ProduceImages()
|
|
|
|
|
|
.ShowResults()
|
|
|
|
|
|
.Render(container =>
|
|
|
|
|
|
{
|
|
|
|
|
|
container
|
|
|
|
|
|
.Padding(25)
|
2021-10-11 22:48:44 +02:00
|
|
|
|
.Decoration(decoration =>
|
2021-10-11 01:48:12 +02:00
|
|
|
|
{
|
2022-01-16 17:08:57 +01:00
|
|
|
|
decoration.Before().Text(text =>
|
2021-10-11 01:48:12 +02:00
|
|
|
|
{
|
2021-10-11 22:48:44 +02:00
|
|
|
|
text.DefaultTextStyle(TextStyle.Default.Size(20));
|
|
|
|
|
|
|
|
|
|
|
|
text.CurrentPageNumber();
|
|
|
|
|
|
text.Span(" / ");
|
|
|
|
|
|
text.TotalPages();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
decoration
|
|
|
|
|
|
.Content()
|
|
|
|
|
|
.PaddingTop(25)
|
2022-01-06 00:22:07 +01:00
|
|
|
|
//.MinimalBox()
|
2021-10-11 22:48:44 +02:00
|
|
|
|
.Border(1)
|
|
|
|
|
|
.Background(Colors.Grey.Lighten2)
|
|
|
|
|
|
.Inlined(inlined =>
|
|
|
|
|
|
{
|
|
|
|
|
|
inlined.Spacing(25);
|
|
|
|
|
|
|
|
|
|
|
|
inlined.AlignSpaceAround();
|
|
|
|
|
|
inlined.BaselineMiddle();
|
|
|
|
|
|
|
|
|
|
|
|
var random = new Random(123);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var _ in Enumerable.Range(0, 50))
|
|
|
|
|
|
{
|
|
|
|
|
|
var width = random.Next(2, 7);
|
|
|
|
|
|
var height = random.Next(2, 7);
|
|
|
|
|
|
|
|
|
|
|
|
var sizeText = $"{width}×{height}";
|
|
|
|
|
|
|
|
|
|
|
|
inlined
|
|
|
|
|
|
.Item()
|
|
|
|
|
|
.Border(1)
|
|
|
|
|
|
.Width(width * 25)
|
|
|
|
|
|
.Height(height * 25)
|
|
|
|
|
|
.Background(Placeholders.BackgroundColor())
|
|
|
|
|
|
.Layers(layers =>
|
|
|
|
|
|
{
|
|
|
|
|
|
layers.Layer().Grid(grid =>
|
|
|
|
|
|
{
|
|
|
|
|
|
grid.Columns(width);
|
|
|
|
|
|
Enumerable.Range(0, width * height).ToList().ForEach(x => grid.Item().Border(1).BorderColor(Colors.White).Width(25).Height(25));
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
layers
|
|
|
|
|
|
.PrimaryLayer()
|
|
|
|
|
|
.AlignCenter()
|
|
|
|
|
|
.AlignMiddle()
|
2022-03-08 17:27:30 +01:00
|
|
|
|
.Text(sizeText)
|
2022-03-11 13:23:36 +01:00
|
|
|
|
.FontSize(15);
|
2021-10-11 22:48:44 +02:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2021-10-11 01:48:12 +02:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-10-23 02:59:47 +02:00
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Inline_AlignLeft_BaselineBottom()
|
|
|
|
|
|
{
|
|
|
|
|
|
RenderingTest
|
|
|
|
|
|
.Create()
|
2021-11-14 23:03:22 +01:00
|
|
|
|
.PageSize(800, 600)
|
2021-10-23 02:59:47 +02:00
|
|
|
|
.ProduceImages()
|
|
|
|
|
|
.ShowResults()
|
|
|
|
|
|
.Render(container =>
|
|
|
|
|
|
{
|
|
|
|
|
|
container
|
|
|
|
|
|
.Padding(20)
|
2022-01-06 00:22:07 +01:00
|
|
|
|
.MinimalBox()
|
2021-10-23 02:59:47 +02:00
|
|
|
|
.Border(1)
|
2021-11-14 23:03:22 +01:00
|
|
|
|
.Background(Colors.Grey.Lighten4)
|
2021-10-23 02:59:47 +02:00
|
|
|
|
.Inlined(inlined =>
|
|
|
|
|
|
{
|
|
|
|
|
|
inlined.VerticalSpacing(50);
|
2021-11-14 23:03:22 +01:00
|
|
|
|
inlined.HorizontalSpacing(25);
|
|
|
|
|
|
inlined.AlignRight();
|
|
|
|
|
|
inlined.BaselineMiddle();
|
2021-10-23 02:59:47 +02:00
|
|
|
|
|
2021-11-14 23:03:22 +01:00
|
|
|
|
foreach (var _ in Enumerable.Range(0, 100))
|
2021-10-23 02:59:47 +02:00
|
|
|
|
inlined.Item().Element(RandomBlock);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
void RandomBlock(IContainer container)
|
|
|
|
|
|
{
|
|
|
|
|
|
container
|
|
|
|
|
|
.Width(Placeholders.Random.Next(1, 5) * 20)
|
|
|
|
|
|
.Height(Placeholders.Random.Next(1, 5) * 20)
|
|
|
|
|
|
.Border(1)
|
|
|
|
|
|
.BorderColor(Colors.Grey.Darken2)
|
|
|
|
|
|
.Background(Placeholders.BackgroundColor());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-10-11 01:48:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|