Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4743768e23 |
@@ -1,54 +0,0 @@
|
|||||||
name: Build And Create Nuget Package
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ main ]
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: '3 0 * * 0'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ${{ matrix.environment }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
environment:
|
|
||||||
- macos-latest
|
|
||||||
- ubuntu-latest
|
|
||||||
- windows-latest
|
|
||||||
env:
|
|
||||||
DOTNET_NOLOGO: 1
|
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
|
||||||
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
|
|
||||||
UNIT_TEST_PROJECT: QuestPDF.UnitTests/QuestPDF.UnitTests.csproj
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: 📝 Fetch Sources 📝
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: ⚙ Setup .NET 6.0 SDK ⚙
|
|
||||||
uses: actions/setup-dotnet@v1
|
|
||||||
with:
|
|
||||||
dotnet-version: '6.0.x'
|
|
||||||
|
|
||||||
- name: 🔄 Restore Nuget Packages 🔄
|
|
||||||
shell: bash
|
|
||||||
run: dotnet restore
|
|
||||||
working-directory: ./Source
|
|
||||||
|
|
||||||
- name: 🛠 Build Solution 🛠
|
|
||||||
shell: bash
|
|
||||||
run: dotnet build -c Release --no-restore
|
|
||||||
working-directory: ./Source
|
|
||||||
|
|
||||||
- name: Upload build artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
if: ${{ matrix.environment == 'windows-latest' }}
|
|
||||||
with:
|
|
||||||
name: Build Package
|
|
||||||
path: |
|
|
||||||
**/*.nupkg
|
|
||||||
**/*.snupkg
|
|
||||||
!.nuget
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using QuestPDF.Examples.Engine;
|
using QuestPDF.Examples.Engine;
|
||||||
@@ -44,7 +43,7 @@ namespace QuestPDF.Examples
|
|||||||
.Height(50)
|
.Height(50)
|
||||||
.AlignCenter()
|
.AlignCenter()
|
||||||
.AlignMiddle()
|
.AlignMiddle()
|
||||||
.Text(i.ToString(CultureInfo.InvariantCulture))
|
.Text(i)
|
||||||
.FontSize(16 + i / 4);
|
.FontSize(16 + i / 4);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using QuestPDF.Elements;
|
using QuestPDF.Elements;
|
||||||
@@ -50,15 +49,15 @@ namespace QuestPDF.Examples
|
|||||||
{
|
{
|
||||||
container.MinimalBox().Decoration(decoration =>
|
container.MinimalBox().Decoration(decoration =>
|
||||||
{
|
{
|
||||||
decoration.Before().Element(header);
|
decoration.Header().Element(header);
|
||||||
|
|
||||||
decoration.Content().Column(column =>
|
decoration.Content().Box().Stack(stack =>
|
||||||
{
|
{
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
column.Item().Element(row.Element);
|
stack.Item().Element(row.Element);
|
||||||
});
|
});
|
||||||
|
|
||||||
decoration.After().Element(footer);
|
decoration.Footer().Element(footer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -83,14 +82,15 @@ namespace QuestPDF.Examples
|
|||||||
.BorderBottom(1)
|
.BorderBottom(1)
|
||||||
.BorderColor(Colors.Grey.Darken2)
|
.BorderColor(Colors.Grey.Darken2)
|
||||||
.Padding(5)
|
.Padding(5)
|
||||||
.DefaultTextStyle(TextStyle.Default.SemiBold())
|
|
||||||
.Row(row =>
|
.Row(row =>
|
||||||
{
|
{
|
||||||
row.ConstantItem(30).Text("#");
|
var textStyle = TextStyle.Default.SemiBold();
|
||||||
row.RelativeItem().Text("Item name");
|
|
||||||
row.ConstantItem(50).AlignRight().Text("Count");
|
row.ConstantItem(30).Text("#", textStyle);
|
||||||
row.ConstantItem(50).AlignRight().Text("Price");
|
row.RelativeItem().Text("Item name", textStyle);
|
||||||
row.ConstantItem(50).AlignRight().Text("Total");
|
row.ConstantItem(50).AlignRight().Text("Count", textStyle);
|
||||||
|
row.ConstantItem(50).AlignRight().Text("Price", textStyle);
|
||||||
|
row.ConstantItem(50).AlignRight().Text("Total", textStyle);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -105,8 +105,7 @@ namespace QuestPDF.Examples
|
|||||||
.Width(context.AvailableSize.Width)
|
.Width(context.AvailableSize.Width)
|
||||||
.Padding(5)
|
.Padding(5)
|
||||||
.AlignRight()
|
.AlignRight()
|
||||||
.DefaultTextStyle(TextStyle.Default.FontSize(14).SemiBold())
|
.Text($"Subtotal: {total}$", TextStyle.Default.Size(14).SemiBold());
|
||||||
.Text($"Subtotal: {total}$");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,9 +126,9 @@ namespace QuestPDF.Examples
|
|||||||
.Padding(5)
|
.Padding(5)
|
||||||
.Row(row =>
|
.Row(row =>
|
||||||
{
|
{
|
||||||
row.ConstantItem(30).Text((index + 1).ToString(CultureInfo.InvariantCulture));
|
row.ConstantItem(30).Text(index + 1);
|
||||||
row.RelativeItem().Text(item.ItemName);
|
row.RelativeItem().Text(item.ItemName);
|
||||||
row.ConstantItem(50).AlignRight().Text(item.Count.ToString(CultureInfo.InvariantCulture));
|
row.ConstantItem(50).AlignRight().Text(item.Count);
|
||||||
row.ConstantItem(50).AlignRight().Text($"{item.Price}$");
|
row.ConstantItem(50).AlignRight().Text($"{item.Price}$");
|
||||||
row.ConstantItem(50).AlignRight().Text($"{item.Count*item.Price}$");
|
row.ConstantItem(50).AlignRight().Text($"{item.Count*item.Price}$");
|
||||||
});
|
});
|
||||||
@@ -165,7 +164,7 @@ namespace QuestPDF.Examples
|
|||||||
.Decoration(decoration =>
|
.Decoration(decoration =>
|
||||||
{
|
{
|
||||||
decoration
|
decoration
|
||||||
.Before()
|
.Header()
|
||||||
.PaddingBottom(5)
|
.PaddingBottom(5)
|
||||||
.Text(text =>
|
.Text(text =>
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using QuestPDF.Elements;
|
using QuestPDF.Elements;
|
||||||
@@ -97,9 +96,9 @@ namespace QuestPDF.Examples
|
|||||||
{
|
{
|
||||||
var item = Items[index];
|
var item = Items[index];
|
||||||
|
|
||||||
table.Cell().Element(Style).Text((index + 1).ToString(CultureInfo.InvariantCulture));
|
table.Cell().Element(Style).Text(index + 1);
|
||||||
table.Cell().Element(Style).Text(item.ItemName);
|
table.Cell().Element(Style).Text(item.ItemName);
|
||||||
table.Cell().Element(Style).AlignRight().Text(item.Count.ToString(CultureInfo.InvariantCulture));
|
table.Cell().Element(Style).AlignRight().Text(item.Count);
|
||||||
table.Cell().Element(Style).AlignRight().Text($"{item.Price}$");
|
table.Cell().Element(Style).AlignRight().Text($"{item.Price}$");
|
||||||
table.Cell().Element(Style).AlignRight().Text($"{item.Count*item.Price}$");
|
table.Cell().Element(Style).AlignRight().Text($"{item.Count*item.Price}$");
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ namespace QuestPDF.Examples.Engine
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderingTest ShowResults()
|
public RenderingTest ShowResults(bool value = true)
|
||||||
{
|
{
|
||||||
ShowResult = true;
|
ShowResult = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System.IO;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using QuestPDF.Drawing.Exceptions;
|
||||||
|
using QuestPDF.Examples.Engine;
|
||||||
|
using QuestPDF.Fluent;
|
||||||
|
using QuestPDF.Helpers;
|
||||||
|
|
||||||
|
namespace QuestPDF.Examples
|
||||||
|
{
|
||||||
|
public class ImageExamples
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void LoadingImage()
|
||||||
|
{
|
||||||
|
RenderingTest
|
||||||
|
.Create()
|
||||||
|
.PageSize(PageSizes.A5)
|
||||||
|
.ProducePdf()
|
||||||
|
.ShowResults()
|
||||||
|
.Render(page =>
|
||||||
|
{
|
||||||
|
page.Padding(25).Column(column =>
|
||||||
|
{
|
||||||
|
column.Spacing(25);
|
||||||
|
|
||||||
|
column.Item().Image("logo.png");
|
||||||
|
|
||||||
|
var binaryData = File.ReadAllBytes("logo.png");
|
||||||
|
column.Item().Image(binaryData);
|
||||||
|
|
||||||
|
using var stream = new FileStream("logo.png", FileMode.Open);
|
||||||
|
column.Item().Image(stream);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Exception()
|
||||||
|
{
|
||||||
|
Assert.Throws<DocumentComposeException>(() =>
|
||||||
|
{
|
||||||
|
RenderingTest
|
||||||
|
.Create()
|
||||||
|
.PageSize(PageSizes.A2)
|
||||||
|
.ProducePdf()
|
||||||
|
.ShowResults()
|
||||||
|
.Render(page => page.Image("non_existent.png"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -120,42 +120,5 @@ namespace QuestPDF.Examples
|
|||||||
.Background(Placeholders.BackgroundColor());
|
.Background(Placeholders.BackgroundColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void RepeatingInlinedInHeader_Test()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.RenderDocument(document =>
|
|
||||||
{
|
|
||||||
document.Page(page =>
|
|
||||||
{
|
|
||||||
page.Size(PageSizes.A4);
|
|
||||||
page.Margin(1, Unit.Inch);
|
|
||||||
page.PageColor(Colors.White);
|
|
||||||
|
|
||||||
page.Header()
|
|
||||||
.Inlined(inlined =>
|
|
||||||
{
|
|
||||||
inlined.Spacing(10);
|
|
||||||
|
|
||||||
foreach (var i in Enumerable.Range(5, 5))
|
|
||||||
inlined.Item().Width(i * 10).Height(20).Background(Colors.Red.Medium);
|
|
||||||
});
|
|
||||||
|
|
||||||
page.Content()
|
|
||||||
.PaddingVertical(20)
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
column.Spacing(25);
|
|
||||||
|
|
||||||
foreach (var i in Enumerable.Range(10, 20))
|
|
||||||
column.Item().Width(i * 10).Height(50).Background(Colors.Grey.Lighten2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,12 +19,10 @@ namespace QuestPDF.Examples
|
|||||||
{
|
{
|
||||||
var url = "https://picsum.photos/300/200";
|
var url = "https://picsum.photos/300/200";
|
||||||
|
|
||||||
if (Greyscale)
|
if(Greyscale)
|
||||||
url += "?grayscale";
|
url += "?grayscale";
|
||||||
|
|
||||||
using var client = new WebClient();
|
using var client = new WebClient();
|
||||||
client.Headers.Add("user-agent", "QuestPDF/1.0 Unit Testing");
|
|
||||||
|
|
||||||
var response = client.DownloadData(url);
|
var response = client.DownloadData(url);
|
||||||
container.Image(response);
|
container.Image(response);
|
||||||
}
|
}
|
||||||
@@ -61,4 +59,4 @@ namespace QuestPDF.Examples
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,10 @@
|
|||||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
|
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
|
||||||
<PackageReference Include="microcharts" Version="0.9.5.9" />
|
<PackageReference Include="microcharts" Version="0.9.5.9" />
|
||||||
<PackageReference Include="nunit" Version="3.13.3" />
|
<PackageReference Include="nunit" Version="3.13.3" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
||||||
<PackageReference Include="SkiaSharp" Version="2.88.3" />
|
<PackageReference Include="SkiaSharp" Version="2.80.4" />
|
||||||
<PackageReference Include="Svg.Skia" Version="0.5.18" />
|
<PackageReference Include="Svg.Skia" Version="0.5.10" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -105,41 +105,5 @@ namespace QuestPDF.Examples
|
|||||||
.Row(row => { });
|
.Row(row => { });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void RowElementForRelativeHeightDivision()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.MaxPages(100)
|
|
||||||
.PageSize(250, 400)
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.Padding(25)
|
|
||||||
.AlignLeft()
|
|
||||||
.RotateRight()
|
|
||||||
.Row(row =>
|
|
||||||
{
|
|
||||||
row.Spacing(20);
|
|
||||||
|
|
||||||
row.RelativeItem(1).Element(Content);
|
|
||||||
row.RelativeItem(2).Element(Content);
|
|
||||||
row.RelativeItem(3).Element(Content);
|
|
||||||
|
|
||||||
void Content(IContainer container)
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.RotateLeft()
|
|
||||||
.Border(1)
|
|
||||||
.Background(Placeholders.BackgroundColor())
|
|
||||||
.Padding(5)
|
|
||||||
.Text(Placeholders.Label());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using QuestPDF.Drawing;
|
||||||
|
using QuestPDF.Elements;
|
||||||
|
using QuestPDF.Examples.Engine;
|
||||||
|
using QuestPDF.Fluent;
|
||||||
|
using QuestPDF.Helpers;
|
||||||
|
using QuestPDF.Infrastructure;
|
||||||
|
|
||||||
|
namespace QuestPDF.Examples
|
||||||
|
{
|
||||||
|
public class TableBenchmark
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Benchmark()
|
||||||
|
{
|
||||||
|
GenerateAndCollect();
|
||||||
|
|
||||||
|
var stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
|
|
||||||
|
foreach (var _ in Enumerable.Range(0, 10000))
|
||||||
|
{
|
||||||
|
GenerateAndCollect();
|
||||||
|
}
|
||||||
|
|
||||||
|
stopwatch.Stop();
|
||||||
|
|
||||||
|
Console.WriteLine($"Execution time: {stopwatch.Elapsed:g}");
|
||||||
|
|
||||||
|
void GenerateAndCollect()
|
||||||
|
{
|
||||||
|
var container = new Container();
|
||||||
|
|
||||||
|
container
|
||||||
|
.Padding(10)
|
||||||
|
.MinimalBox()
|
||||||
|
.Border(1)
|
||||||
|
.Column(column =>
|
||||||
|
{
|
||||||
|
const int numberOfRows = 100;
|
||||||
|
const int numberOfColumns = 10;
|
||||||
|
|
||||||
|
for (var y = 0; y < numberOfRows; y++)
|
||||||
|
{
|
||||||
|
column.Item().Row(row =>
|
||||||
|
{
|
||||||
|
for (var x = 0; x < numberOfColumns; x++)
|
||||||
|
{
|
||||||
|
row.RelativeItem()
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten5)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten4)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten3)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten2)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Lighten1)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Medium)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken1)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken2)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken3)
|
||||||
|
.Padding(3)
|
||||||
|
|
||||||
|
.Background(Colors.Red.Darken4)
|
||||||
|
.Height(3);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ElementCacheManager.Collect(container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using QuestPDF.Drawing;
|
using QuestPDF.Drawing;
|
||||||
@@ -300,18 +299,17 @@ namespace QuestPDF.Examples
|
|||||||
columns.RelativeColumn();
|
columns.RelativeColumn();
|
||||||
columns.RelativeColumn();
|
columns.RelativeColumn();
|
||||||
columns.RelativeColumn();
|
columns.RelativeColumn();
|
||||||
columns.RelativeColumn();
|
|
||||||
columns.RelativeColumn();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var image = Placeholders.Image(400, 300);
|
table.Cell().RowSpan(4).Element(Block).Text("1");
|
||||||
|
|
||||||
table.Cell().Image(image);
|
table.Cell().RowSpan(2).Element(Block).Text("2");
|
||||||
table.Cell().Image(image);
|
table.Cell().RowSpan(1).Element(Block).Text("3");
|
||||||
table.Cell().Image(image);
|
table.Cell().RowSpan(1).Element(Block).Text("4");
|
||||||
table.Cell().Image(image);
|
|
||||||
table.Cell().Image(image);
|
table.Cell().RowSpan(2).Element(Block).Text("5");
|
||||||
table.Cell().Image(image);
|
table.Cell().RowSpan(1).Element(Block).Text("6");
|
||||||
|
table.Cell().RowSpan(1).Element(Block).Text("7");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -391,12 +389,12 @@ namespace QuestPDF.Examples
|
|||||||
table.Cell().Element(CellStyle).ExtendHorizontal().AlignLeft().Text(page.name);
|
table.Cell().Element(CellStyle).ExtendHorizontal().AlignLeft().Text(page.name);
|
||||||
|
|
||||||
// inches
|
// inches
|
||||||
table.Cell().Element(CellStyle).Text(page.width.ToString(CultureInfo.InvariantCulture));
|
table.Cell().Element(CellStyle).Text(page.width);
|
||||||
table.Cell().Element(CellStyle).Text(page.height.ToString(CultureInfo.InvariantCulture));
|
table.Cell().Element(CellStyle).Text(page.height);
|
||||||
|
|
||||||
// points
|
// points
|
||||||
table.Cell().Element(CellStyle).Text((page.width * inchesToPoints).ToString(CultureInfo.InvariantCulture));
|
table.Cell().Element(CellStyle).Text(page.width * inchesToPoints);
|
||||||
table.Cell().Element(CellStyle).Text((page.height * inchesToPoints).ToString(CultureInfo.InvariantCulture));
|
table.Cell().Element(CellStyle).Text(page.height * inchesToPoints);
|
||||||
|
|
||||||
IContainer CellStyle(IContainer container) => DefaultCellStyle(container, Colors.White);
|
IContainer CellStyle(IContainer container) => DefaultCellStyle(container, Colors.White);
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ namespace QuestPDF.Examples
|
|||||||
{
|
{
|
||||||
page.Margin(50);
|
page.Margin(50);
|
||||||
|
|
||||||
page.Content().PaddingVertical(10).Column(column =>
|
page.Content().Column(column =>
|
||||||
{
|
{
|
||||||
column.Item().Element(Title);
|
column.Item().Element(Title);
|
||||||
column.Item().PageBreak();
|
column.Item().PageBreak();
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using QuestPDF.Elements.Text;
|
|
||||||
using QuestPDF.Examples.Engine;
|
using QuestPDF.Examples.Engine;
|
||||||
using QuestPDF.Fluent;
|
using QuestPDF.Fluent;
|
||||||
using QuestPDF.Helpers;
|
using QuestPDF.Helpers;
|
||||||
using QuestPDF.Infrastructure;
|
using QuestPDF.Infrastructure;
|
||||||
using SkiaSharp;
|
|
||||||
|
|
||||||
namespace QuestPDF.Examples
|
namespace QuestPDF.Examples
|
||||||
{
|
{
|
||||||
@@ -123,132 +121,7 @@ namespace QuestPDF.Examples
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void LetterSpacing()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(500, 700)
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.Padding(20)
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
var letterSpacing = new[] { -0.1f, 0f, 0.2f };
|
|
||||||
var paragraph = Placeholders.Sentence().ToUpper();
|
|
||||||
|
|
||||||
foreach (var spacing in letterSpacing)
|
|
||||||
{
|
|
||||||
column
|
|
||||||
.Item()
|
|
||||||
.Border(1)
|
|
||||||
.Padding(10)
|
|
||||||
.Column(nestedColumn =>
|
|
||||||
{
|
|
||||||
nestedColumn.Item()
|
|
||||||
.Text(paragraph)
|
|
||||||
.FontSize(16)
|
|
||||||
.LetterSpacing(spacing);
|
|
||||||
|
|
||||||
nestedColumn.Item()
|
|
||||||
.Text($"Letter spacing of {spacing} em")
|
|
||||||
.FontSize(10)
|
|
||||||
.Italic()
|
|
||||||
.FontColor(Colors.Blue.Medium);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void LetterSpacing_Arabic()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(500, 700)
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.Padding(50)
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
var letterSpacing = new[] { -0.1f, 0f, 0.2f };
|
|
||||||
var paragraph = "ينا الألم. في بعض الأحيان ونظراً للالتزامات التي يفرضها علينا";
|
|
||||||
foreach (var spacing in letterSpacing)
|
|
||||||
{
|
|
||||||
column
|
|
||||||
.Item()
|
|
||||||
.Border(1)
|
|
||||||
.Padding(10)
|
|
||||||
.Column(nestedColumn =>
|
|
||||||
{
|
|
||||||
nestedColumn.Item()
|
|
||||||
.Text(paragraph)
|
|
||||||
.FontSize(16)
|
|
||||||
.FontFamily(Fonts.Calibri)
|
|
||||||
.LetterSpacing(spacing);
|
|
||||||
|
|
||||||
nestedColumn.Item()
|
|
||||||
.Text($"Letter spacing of {spacing} em")
|
|
||||||
.FontSize(10)
|
|
||||||
.Italic()
|
|
||||||
.FontColor(Colors.Blue.Medium);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void LetterSpacing_Unicode()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(500, 700)
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.Padding(50)
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
var letterSpacing = new[] { 0f, 0.5f };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var paragraph = "Ţ̴̡̧̤̮̺̤̗͎̱̹͙͎͖͂̿̓́̉̊̀̍͜h̵̞̘͇̾̎̏̅į̵̹̖͔͉̰̎̉̄̐̏͑͂̅̃̃͘͝s̷͓͉̭̭̯̬̥̻̰̩̦̑̀̀͌́̒̍̒̌̇͛̀͛́̎ ̷̡̡̟͕̳̺̝̼͇͔̬̟̖͍̈́̽͜͝͝i̶͔͚̟̊̐͛́͛̄̌ṡ̸̡̤̪͙͍̥͙̟̼̝̰̥͈̿̓̄̿̓͠ ̶̢̦̙͍̯̖̱̰̯͕͔͎̯̝̎͑t̸͖̲̱̼̎͐̎̉̾̎̾̌̅̔̏͘ȩ̶̝̫̙͓̙̣̔̀̌̔̋̂̑̈́̏̀̈͘̕͜͝s̸̫̝̮̻̼͐̅̄̎̎̑͝ț̷̨̢̨̻͈̮̞̆͗̓͊̃̌͂̑̉̕̕͜͝͝";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var spacing in letterSpacing)
|
|
||||||
{
|
|
||||||
column.Item()
|
|
||||||
.Text($"Letter spacing of {spacing} em")
|
|
||||||
.FontSize(10)
|
|
||||||
.Italic()
|
|
||||||
.FontColor(Colors.Blue.Medium);
|
|
||||||
|
|
||||||
column.Item()
|
|
||||||
.PaddingVertical(50)
|
|
||||||
.Text(paragraph)
|
|
||||||
.FontSize(16)
|
|
||||||
.FontFamily(Fonts.Calibri)
|
|
||||||
.LetterSpacing(spacing);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SuperscriptSubscript_Simple()
|
public void SuperscriptSubscript_Simple()
|
||||||
{
|
{
|
||||||
@@ -649,7 +522,7 @@ namespace QuestPDF.Examples
|
|||||||
|
|
||||||
page.Content().Column(column =>
|
page.Content().Column(column =>
|
||||||
{
|
{
|
||||||
column.Item().Text((string) null);
|
column.Item().Text(null);
|
||||||
|
|
||||||
column.Item().Text(text =>
|
column.Item().Text(text =>
|
||||||
{
|
{
|
||||||
@@ -681,7 +554,7 @@ namespace QuestPDF.Examples
|
|||||||
|
|
||||||
page.Content().Column(column =>
|
page.Content().Column(column =>
|
||||||
{
|
{
|
||||||
column.Item().Text((string) null);
|
column.Item().Text(null);
|
||||||
|
|
||||||
column.Item().Text(text =>
|
column.Item().Text(text =>
|
||||||
{
|
{
|
||||||
@@ -730,7 +603,7 @@ namespace QuestPDF.Examples
|
|||||||
{
|
{
|
||||||
RenderingTest
|
RenderingTest
|
||||||
.Create()
|
.Create()
|
||||||
.PageSize(250, 100)
|
.PageSize(500, 100)
|
||||||
|
|
||||||
.ProduceImages()
|
.ProduceImages()
|
||||||
.ShowResults()
|
.ShowResults()
|
||||||
@@ -740,303 +613,9 @@ namespace QuestPDF.Examples
|
|||||||
.Padding(25)
|
.Padding(25)
|
||||||
.MinimalBox()
|
.MinimalBox()
|
||||||
.Background(Colors.Grey.Lighten2)
|
.Background(Colors.Grey.Lighten2)
|
||||||
.Text("خوارزمية ترتيب")
|
.Text("ينا الألم. في بعض الأحيان ونظراً للالتزامات التي يفرضها علينا")
|
||||||
.FontFamily(Fonts.Calibri)
|
.FontFamily(Fonts.Calibri)
|
||||||
.FontSize(30);
|
.FontSize(20);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void FontFallback()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.RenderDocument(container =>
|
|
||||||
{
|
|
||||||
container.Page(page =>
|
|
||||||
{
|
|
||||||
page.Margin(50);
|
|
||||||
page.PageColor(Colors.White);
|
|
||||||
page.DefaultTextStyle(x => x
|
|
||||||
.Fallback(y => y.FontFamily("Segoe UI Emoji")
|
|
||||||
.Fallback(y => y.FontFamily("Microsoft YaHei"))));
|
|
||||||
|
|
||||||
page.Size(PageSizes.A4);
|
|
||||||
|
|
||||||
page.Content().Text(t =>
|
|
||||||
{
|
|
||||||
t.Line("This is normal text.");
|
|
||||||
t.EmptyLine();
|
|
||||||
|
|
||||||
t.Line("Following line should use font fallback:");
|
|
||||||
t.Line("中文文本");
|
|
||||||
t.EmptyLine();
|
|
||||||
|
|
||||||
t.Line("The following line contains a mix of known and unknown characters.");
|
|
||||||
t.Line("Mixed line: This 中文 is 文文 a mixed 本 本 line 本 中文文本!");
|
|
||||||
t.EmptyLine();
|
|
||||||
|
|
||||||
t.Line("Emojis work out of the box because of font fallback: 😊😅🥳👍❤😍👌");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void WordWrappingStability()
|
|
||||||
{
|
|
||||||
// instruction: check if any characters repeat when performing the word-wrapping algorithm
|
|
||||||
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(PageSizes.A4)
|
|
||||||
.ProducePdf()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
var text = "Lorem ipsum dolor sit amet consectetuer";
|
|
||||||
|
|
||||||
container
|
|
||||||
.Padding(20)
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
column.Spacing(10);
|
|
||||||
|
|
||||||
foreach (var width in Enumerable.Range(25, 200))
|
|
||||||
{
|
|
||||||
column
|
|
||||||
.Item()
|
|
||||||
.MaxWidth(width)
|
|
||||||
.Background(Colors.Grey.Lighten3)
|
|
||||||
.Text(text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void AdvancedLanguagesSupport()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(new PageSize(400, 400))
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
var text = "في المعلوماتية أو الرياضيات، خوارزمية الترتيب هي خوارزمية تمكن من تنظيم مجموعة عناصر حسب ترتيب محدد.";
|
|
||||||
|
|
||||||
container
|
|
||||||
.Padding(20)
|
|
||||||
.ContentFromRightToLeft()
|
|
||||||
.Text(text)
|
|
||||||
.FontFamily(Fonts.Calibri)
|
|
||||||
.FontSize(22);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void WordWrappingWhenRightToLeft()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(new PageSize(1000, 500))
|
|
||||||
.ProducePdf()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
var text = "في المعلوماتية أو الرياضيات، خوارزمية الترتيب هي خوارزمية تمكن من تنظيم مجموعة عناصر حسب ترتيب محدد.";
|
|
||||||
|
|
||||||
container
|
|
||||||
.Padding(25)
|
|
||||||
.ContentFromRightToLeft()
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
column.Spacing(20);
|
|
||||||
|
|
||||||
foreach (var size in new[] { 36, 34, 32, 30, 15 })
|
|
||||||
{
|
|
||||||
column
|
|
||||||
.Item()
|
|
||||||
.ShowEntire()
|
|
||||||
.MaxWidth(size * 25)
|
|
||||||
.Background(Colors.Grey.Lighten3)
|
|
||||||
.MinimalBox()
|
|
||||||
.Background(Colors.Grey.Lighten2)
|
|
||||||
.Text(text)
|
|
||||||
.FontSize(20)
|
|
||||||
.FontFamily("Segoe UI");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void ForcingTextDirection()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(new PageSize(1000, 500))
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.Padding(10)
|
|
||||||
.DefaultTextStyle(x => x.FontSize(24).FontFamily("Calibri"))
|
|
||||||
.Column(column =>
|
|
||||||
{
|
|
||||||
column.Spacing(10);
|
|
||||||
|
|
||||||
var word = "الجوريتم";
|
|
||||||
var definition = "algorithm in Arabic";
|
|
||||||
|
|
||||||
var text = $"{word} - {definition}";
|
|
||||||
|
|
||||||
// text direction is automatically detected using the first word
|
|
||||||
column.Item().Text(text);
|
|
||||||
|
|
||||||
// it is possible to force specific content direction
|
|
||||||
column.Item().Text(text).DirectionFromLeftToRight();
|
|
||||||
column.Item().Text(text).DirectionFromRightToLeft();
|
|
||||||
|
|
||||||
// to combine text in various content directions, split it into segments
|
|
||||||
column.Item().Text(text =>
|
|
||||||
{
|
|
||||||
text.Span(word);
|
|
||||||
text.Span(" - ");
|
|
||||||
text.Span(definition);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DetectSpanPositionExample()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(new PageSize(650, 800))
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
var fontSize = 20;
|
|
||||||
|
|
||||||
var paint = new SKPaint
|
|
||||||
{
|
|
||||||
Color = SKColors.Red,
|
|
||||||
TextSize = fontSize
|
|
||||||
};
|
|
||||||
|
|
||||||
var fontMetrics = paint.FontMetrics;
|
|
||||||
|
|
||||||
var start = 0f;
|
|
||||||
var end = 0f;
|
|
||||||
|
|
||||||
// corner case: what if text is paged? clamp start and end?
|
|
||||||
|
|
||||||
container
|
|
||||||
.Padding(25)
|
|
||||||
.DefaultTextStyle(x => x.FontSize(fontSize).FontFamily("Calibri"))
|
|
||||||
.Layers(layers =>
|
|
||||||
{
|
|
||||||
layers.PrimaryLayer().Text(text =>
|
|
||||||
{
|
|
||||||
text.Span(Placeholders.Paragraph());
|
|
||||||
text.Span(" - ");
|
|
||||||
|
|
||||||
// record start
|
|
||||||
text.Element().Width(0).Height(0)
|
|
||||||
.Canvas((canvas, size) => start = canvas.TotalMatrix.TransY / canvas.TotalMatrix.ScaleY);
|
|
||||||
|
|
||||||
text.Span(Placeholders.LoremIpsum()).BackgroundColor(Colors.Red.Lighten4);
|
|
||||||
|
|
||||||
// record end
|
|
||||||
text.Element().Width(0).Height(0)
|
|
||||||
.Canvas((canvas, size) => end = canvas.TotalMatrix.TransY / canvas.TotalMatrix.ScaleY);
|
|
||||||
|
|
||||||
text.Span(" - ");
|
|
||||||
text.Span(Placeholders.Paragraph());
|
|
||||||
});
|
|
||||||
|
|
||||||
layers.Layer().Canvas((canvas, size) =>
|
|
||||||
{
|
|
||||||
canvas.Save();
|
|
||||||
|
|
||||||
canvas.Translate(-canvas.TotalMatrix.TransX / canvas.TotalMatrix.ScaleX, -canvas.TotalMatrix.TransY / canvas.TotalMatrix.ScaleY);
|
|
||||||
canvas.DrawRect(10, start + fontMetrics.Ascent, 5, end - start + (fontMetrics.Bottom - fontMetrics.Ascent), paint);
|
|
||||||
|
|
||||||
canvas.Restore();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void InconsistentLineHeightWhenUsingNewLineTest()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.PageSize(PageSizes.A4)
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.Render(container =>
|
|
||||||
{
|
|
||||||
container
|
|
||||||
.Padding(20)
|
|
||||||
.Background(Colors.Grey.Lighten4)
|
|
||||||
.Text(text =>
|
|
||||||
{
|
|
||||||
text.DefaultTextStyle(x => x.FontSize(16));
|
|
||||||
|
|
||||||
text.Line(Placeholders.Paragraph());
|
|
||||||
text.Line("");
|
|
||||||
text.Line(Placeholders.Paragraph());
|
|
||||||
|
|
||||||
text.Line(Placeholders.Label()).FontSize(48);
|
|
||||||
|
|
||||||
text.Line(Placeholders.Paragraph());
|
|
||||||
text.Line("");
|
|
||||||
text.Line(Placeholders.Paragraph());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void FontFallback_Nested()
|
|
||||||
{
|
|
||||||
RenderingTest
|
|
||||||
.Create()
|
|
||||||
.ProduceImages()
|
|
||||||
.ShowResults()
|
|
||||||
.RenderDocument(container =>
|
|
||||||
{
|
|
||||||
container.Page(page =>
|
|
||||||
{
|
|
||||||
page.Margin(50);
|
|
||||||
page.PageColor(Colors.White);
|
|
||||||
page.Size(PageSizes.A5.Landscape());
|
|
||||||
|
|
||||||
page.DefaultTextStyle(x => x
|
|
||||||
.FontSize(24)
|
|
||||||
.Bold()
|
|
||||||
.FontFamily("Times New Roman")
|
|
||||||
.Fallback(y => y
|
|
||||||
.FontFamily("Microsoft YaHei")
|
|
||||||
.Underline()
|
|
||||||
.BackgroundColor(Colors.Red.Lighten2)));
|
|
||||||
|
|
||||||
page.Content().Text(text =>
|
|
||||||
{
|
|
||||||
text.Line("Default times new roman 中文文本 text.");
|
|
||||||
text.Line("Normal weight and green 中文文本 text.").NormalWeight().BackgroundColor(Colors.Green.Lighten2);
|
|
||||||
text.Line("Strikethrough without underline 中文文本 text.").Strikethrough().Underline(false);
|
|
||||||
text.Line("Lato italic 中文文本 text.").FontFamily("Lato").Italic();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -4,7 +4,7 @@
|
|||||||
<Authors>MarcinZiabek</Authors>
|
<Authors>MarcinZiabek</Authors>
|
||||||
<Company>CodeFlint</Company>
|
<Company>CodeFlint</Company>
|
||||||
<PackageId>QuestPDF.Previewer</PackageId>
|
<PackageId>QuestPDF.Previewer</PackageId>
|
||||||
<Version>2022.12.0</Version>
|
<Version>2022.8.0</Version>
|
||||||
<PackAsTool>true</PackAsTool>
|
<PackAsTool>true</PackAsTool>
|
||||||
<ToolCommandName>questpdf-previewer</ToolCommandName>
|
<ToolCommandName>questpdf-previewer</ToolCommandName>
|
||||||
<PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
|
<PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<PackageIcon>Logo.png</PackageIcon>
|
<PackageIcon>Logo.png</PackageIcon>
|
||||||
<PackageIconUrl>https://www.questpdf.com/images/package-logo.png</PackageIconUrl>
|
<PackageIconUrl>https://www.questpdf.com/images/package-logo.png</PackageIconUrl>
|
||||||
<PackageReadmeFile>PackageReadme.md</PackageReadmeFile>
|
|
||||||
<PackageProjectUrl>https://www.questpdf.com/</PackageProjectUrl>
|
<PackageProjectUrl>https://www.questpdf.com/</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/QuestPDF/library.git</RepositoryUrl>
|
<RepositoryUrl>https://github.com/QuestPDF/library.git</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
@@ -34,22 +33,23 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\Logo.png" />
|
<EmbeddedResource Include="Resources\Logo.png" />
|
||||||
<None Include="Resources\Logo.png" Pack="true" PackagePath="\" />
|
<None Include="Resources\Logo.png">
|
||||||
<None Include="Resources\PackageReadme.md" Pack="true" PackagePath="\" />
|
<Pack>true</Pack>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
<PackageReference Include="Avalonia" Version="0.10.18" />
|
<PackageReference Include="Avalonia" Version="0.10.10" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
|
<PackageReference Include="Avalonia.Desktop" Version="0.10.10" />
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.18" />
|
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.10" />
|
||||||
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="0.10.18" />
|
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="0.10.10" />
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.10" />
|
||||||
<PackageReference Include="ReactiveUI" Version="18.4.1" />
|
<PackageReference Include="ReactiveUI" Version="17.1.50" />
|
||||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.3" />
|
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.4" />
|
||||||
<PackageReference Include="SkiaSharp.NativeAssets.Win32" Version="2.88.3" />
|
|
||||||
<PackageReference Include="SkiaSharp.NativeAssets.macOS" Version="2.88.3" />
|
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
<PackageReference Include="SkiaSharp" Version="2.88.3" />
|
<PackageReference Include="SkiaSharp" Version="2.80.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@@ -31,7 +31,7 @@ namespace QuestPDF.ReportSample
|
|||||||
public static string FormatAsRomanNumeral(this int number)
|
public static string FormatAsRomanNumeral(this int number)
|
||||||
{
|
{
|
||||||
if (number < 0 || number > 3999)
|
if (number < 0 || number > 3999)
|
||||||
throw new ArgumentOutOfRangeException(nameof(number), "Number should be in range from 1 to 3999");
|
throw new ArgumentOutOfRangeException("Number should be in range from 1 to 3999");
|
||||||
|
|
||||||
return RomanNumeralCache.GetOrAdd(number, x =>
|
return RomanNumeralCache.GetOrAdd(number, x =>
|
||||||
{
|
{
|
||||||
@@ -68,11 +68,9 @@ namespace QuestPDF.ReportSample.Layouts
|
|||||||
|
|
||||||
var lengthStyle = TextStyle.Default.FontColor(Colors.Grey.Medium);
|
var lengthStyle = TextStyle.Default.FontColor(Colors.Grey.Medium);
|
||||||
|
|
||||||
text.TotalPagesWithinSection(locationName).Style(lengthStyle).Format(x =>
|
text.Span(" (").Style(lengthStyle);
|
||||||
{
|
text.TotalPagesWithinSection(locationName).Style(lengthStyle).Format(x => x == 1 ? "1 page long" : $"{x} pages long");
|
||||||
var formatted = x == 1 ? "1 page long" : $"{x} pages long";
|
text.Span(")").Style(lengthStyle);
|
||||||
return $" ({formatted})";
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using BenchmarkDotNet.Attributes;
|
||||||
|
using BenchmarkDotNet.Configs;
|
||||||
|
using BenchmarkDotNet.Engines;
|
||||||
|
using BenchmarkDotNet.Running;
|
||||||
|
using Microsoft.VisualStudio.TestPlatform.TestHost;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using QuestPDF.Drawing;
|
||||||
|
using QuestPDF.Drawing.Proxy;
|
||||||
|
using QuestPDF.Elements;
|
||||||
|
using QuestPDF.Helpers;
|
||||||
|
using QuestPDF.Infrastructure;
|
||||||
|
using QuestPDF.ReportSample.Layouts;
|
||||||
|
|
||||||
|
namespace QuestPDF.ReportSample
|
||||||
|
{
|
||||||
|
[SimpleJob(RunStrategy.Monitoring, launchCount: 0, warmupCount: 1, targetCount: 256)]
|
||||||
|
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
|
||||||
|
public class PerformanceTests
|
||||||
|
{
|
||||||
|
private PageContext PageContext { get; set; }
|
||||||
|
private DocumentMetadata Metadata { get; set; }
|
||||||
|
private Container Content { get; set; }
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Run()
|
||||||
|
{
|
||||||
|
ImagePlaceholder.Solid = true;
|
||||||
|
|
||||||
|
var configuration = ManualConfig
|
||||||
|
.Create(DefaultConfig.Instance)
|
||||||
|
.WithOptions(ConfigOptions.DisableOptimizationsValidator);
|
||||||
|
|
||||||
|
BenchmarkRunner.Run<PerformanceTests>(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IterationSetup]
|
||||||
|
public void GenerateReportData()
|
||||||
|
{
|
||||||
|
ImagePlaceholder.Solid = true;
|
||||||
|
|
||||||
|
var model = DataSource.GetReport();
|
||||||
|
var report = new StandardReport(model);
|
||||||
|
Metadata = report.GetMetadata();
|
||||||
|
|
||||||
|
var documentContainer = new DocumentContainer();
|
||||||
|
report.Compose(documentContainer);
|
||||||
|
Content = documentContainer.Compose();
|
||||||
|
|
||||||
|
PageContext = new PageContext();
|
||||||
|
DocumentGenerator.RenderPass(PageContext, new FreeCanvas(), Content, null);
|
||||||
|
|
||||||
|
var sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
|
||||||
|
Content.VisitChildren(x =>
|
||||||
|
{
|
||||||
|
if (x is ICacheable)
|
||||||
|
x.CreateProxy(y => new CacheProxy(y));
|
||||||
|
});
|
||||||
|
|
||||||
|
sw.Stop();
|
||||||
|
Console.WriteLine($"Creating cache took: {sw.ElapsedMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
public void GenerationTest()
|
||||||
|
{
|
||||||
|
DocumentGenerator.RenderPass(PageContext, new FreeCanvas(), Content, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
|
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
|
||||||
<PackageReference Include="nunit" Version="3.13.2" />
|
<PackageReference Include="nunit" Version="3.13.2" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||||
<PackageReference Include="SkiaSharp" Version="2.88.3" />
|
<PackageReference Include="SkiaSharp" Version="2.80.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 993 B After Width: | Height: | Size: 993 B |
@@ -38,5 +38,20 @@ namespace QuestPDF.ReportSample
|
|||||||
Report.GenerateXps(path);
|
Report.GenerateXps(path);
|
||||||
Process.Start("explorer.exe", path);
|
Process.Start("explorer.exe", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Profile()
|
||||||
|
{
|
||||||
|
ImagePlaceholder.Solid = true;
|
||||||
|
|
||||||
|
var container = new DocumentContainer();
|
||||||
|
Report.Compose(container);
|
||||||
|
var content = container.Compose();
|
||||||
|
|
||||||
|
var pageContext = new PageContext();
|
||||||
|
|
||||||
|
DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, null);
|
||||||
|
DocumentGenerator.RenderPass(pageContext, new FreeCanvas(), content, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,43 +86,5 @@ namespace QuestPDF.UnitTests
|
|||||||
.ExpectCanvasTranslate(new Position(-300, 0))
|
.ExpectCanvasTranslate(new Position(-300, 0))
|
||||||
.CheckDrawResult();
|
.CheckDrawResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void Draw_HorizontalCenter_VerticalNone()
|
|
||||||
{
|
|
||||||
TestPlan
|
|
||||||
.For(x => new Alignment
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignment.Center,
|
|
||||||
Vertical = null,
|
|
||||||
|
|
||||||
Child = x.CreateChild()
|
|
||||||
})
|
|
||||||
.DrawElement(new Size(400, 300))
|
|
||||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.FullRender(new Size(100, 50)))
|
|
||||||
.ExpectCanvasTranslate(new Position(150, 0))
|
|
||||||
.ExpectChildDraw(new Size(100, 300))
|
|
||||||
.ExpectCanvasTranslate(new Position(-150, 0))
|
|
||||||
.CheckDrawResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void Draw_HorizontalNone_VerticalMiddle()
|
|
||||||
{
|
|
||||||
TestPlan
|
|
||||||
.For(x => new Alignment
|
|
||||||
{
|
|
||||||
Horizontal = null,
|
|
||||||
Vertical = VerticalAlignment.Middle,
|
|
||||||
|
|
||||||
Child = x.CreateChild()
|
|
||||||
})
|
|
||||||
.DrawElement(new Size(400, 300))
|
|
||||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.FullRender(new Size(100, 50)))
|
|
||||||
.ExpectCanvasTranslate(new Position(0, 125))
|
|
||||||
.ExpectChildDraw(new Size(400, 50))
|
|
||||||
.ExpectCanvasTranslate(new Position(0, -125))
|
|
||||||
.CheckDrawResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,9 +153,7 @@ namespace QuestPDF.UnitTests
|
|||||||
Ratio = 2f
|
Ratio = 2f
|
||||||
})
|
})
|
||||||
.DrawElement(new Size(500, 200))
|
.DrawElement(new Size(500, 200))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.ExpectChildDraw(new Size(400, 200))
|
.ExpectChildDraw(new Size(400, 200))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.CheckDrawResult();
|
.CheckDrawResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,45 +168,7 @@ namespace QuestPDF.UnitTests
|
|||||||
Ratio = 2f
|
Ratio = 2f
|
||||||
})
|
})
|
||||||
.DrawElement(new Size(400, 300))
|
.DrawElement(new Size(400, 300))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.ExpectChildDraw(new Size(400, 200))
|
.ExpectChildDraw(new Size(400, 200))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.CheckDrawResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DrawChild_PerWidth_RightToLeft()
|
|
||||||
{
|
|
||||||
TestPlan
|
|
||||||
.For(x => new AspectRatio
|
|
||||||
{
|
|
||||||
Child = x.CreateChild(),
|
|
||||||
Option = AspectRatioOption.FitArea,
|
|
||||||
Ratio = 2f,
|
|
||||||
ContentDirection = ContentDirection.RightToLeft
|
|
||||||
})
|
|
||||||
.DrawElement(new Size(500, 200))
|
|
||||||
.ExpectCanvasTranslate(100, 0)
|
|
||||||
.ExpectChildDraw(new Size(400, 200))
|
|
||||||
.ExpectCanvasTranslate(-100, 0)
|
|
||||||
.CheckDrawResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void DrawChild_PerHeight_RightToLeft()
|
|
||||||
{
|
|
||||||
TestPlan
|
|
||||||
.For(x => new AspectRatio
|
|
||||||
{
|
|
||||||
Child = x.CreateChild(),
|
|
||||||
Option = AspectRatioOption.FitArea,
|
|
||||||
Ratio = 2f,
|
|
||||||
ContentDirection = ContentDirection.RightToLeft
|
|
||||||
})
|
|
||||||
.DrawElement(new Size(400, 300))
|
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.ExpectChildDraw(new Size(400, 200))
|
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.CheckDrawResult();
|
.CheckDrawResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,9 +35,7 @@ namespace QuestPDF.UnitTests
|
|||||||
})
|
})
|
||||||
.MeasureElement(new Size(400, 300))
|
.MeasureElement(new Size(400, 300))
|
||||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.PartialRender(200, 100))
|
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.PartialRender(200, 100))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.ExpectChildDraw(new Size(200, 100))
|
.ExpectChildDraw(new Size(200, 100))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.CheckDrawResult();
|
.CheckDrawResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,43 +49,7 @@ namespace QuestPDF.UnitTests
|
|||||||
})
|
})
|
||||||
.MeasureElement(new Size(500, 400))
|
.MeasureElement(new Size(500, 400))
|
||||||
.ExpectChildMeasure(expectedInput: new Size(500, 400), returns: SpacePlan.FullRender(300, 200))
|
.ExpectChildMeasure(expectedInput: new Size(500, 400), returns: SpacePlan.FullRender(300, 200))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.ExpectChildDraw(new Size(300, 200))
|
.ExpectChildDraw(new Size(300, 200))
|
||||||
.ExpectCanvasTranslate(0, 0)
|
|
||||||
.CheckDrawResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void Measure_PartialRender_RightToLeft()
|
|
||||||
{
|
|
||||||
TestPlan
|
|
||||||
.For(x => new MinimalBox
|
|
||||||
{
|
|
||||||
Child = x.CreateChild(),
|
|
||||||
ContentDirection = ContentDirection.RightToLeft
|
|
||||||
})
|
|
||||||
.MeasureElement(new Size(400, 300))
|
|
||||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.PartialRender(200, 100))
|
|
||||||
.ExpectCanvasTranslate(200, 0)
|
|
||||||
.ExpectChildDraw(new Size(200, 100))
|
|
||||||
.ExpectCanvasTranslate(-200, 0)
|
|
||||||
.CheckDrawResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void Measure_FullRender_RightToLeft()
|
|
||||||
{
|
|
||||||
TestPlan
|
|
||||||
.For(x => new MinimalBox
|
|
||||||
{
|
|
||||||
Child = x.CreateChild(),
|
|
||||||
ContentDirection = ContentDirection.RightToLeft
|
|
||||||
})
|
|
||||||
.MeasureElement(new Size(500, 400))
|
|
||||||
.ExpectChildMeasure(expectedInput: new Size(500, 400), returns: SpacePlan.FullRender(350, 200))
|
|
||||||
.ExpectCanvasTranslate(150, 0)
|
|
||||||
.ExpectChildDraw(new Size(350, 200))
|
|
||||||
.ExpectCanvasTranslate(-150, 0)
|
|
||||||
.CheckDrawResult();
|
.CheckDrawResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||