diff --git a/QuestPDF.Examples/LineExamples.cs b/QuestPDF.Examples/LineExamples.cs
index aa1e141..7a8852a 100644
--- a/QuestPDF.Examples/LineExamples.cs
+++ b/QuestPDF.Examples/LineExamples.cs
@@ -3,6 +3,7 @@ using NUnit.Framework;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
+using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
@@ -14,16 +15,20 @@ namespace QuestPDF.Examples
RenderingTest
.Create()
.PageSize(PageSizes.A5)
- .ProducePdf()
+ .ProduceImages()
.ShowResults()
.Render(container =>
{
- container.Padding(25).Column(column =>
- {
- column.Item().Text("Above text");
- column.Item().PaddingVertical(10).LineHorizontal(1).LineColor(Colors.Blue.Accent1);
- column.Item().Text("Below text");
- });
+ container
+ .Padding(15)
+ .MinimalBox()
+ .DefaultTextStyle(TextStyle.Default.Size(16))
+ .Column(column =>
+ {
+ column.Item().Text("Above text");
+ column.Item().PaddingVertical(5).LineHorizontal(1).LineColor(Colors.Grey.Medium);
+ column.Item().Text("Below text");
+ });
});
}
@@ -33,17 +38,19 @@ namespace QuestPDF.Examples
RenderingTest
.Create()
.PageSize(PageSizes.A5)
- .ProducePdf()
+ .ProduceImages()
.ShowResults()
.Render(container =>
{
- container.Padding(25).Inlined(inlined =>
- {
- inlined.Spacing(5);
- inlined.Item().Text("Above text");
- inlined.Item().LineVertical(1).LineColor(Colors.Blue.Accent1);
- inlined.Item().Text("Below text");
- });
+ container
+ .Padding(15)
+ .DefaultTextStyle(TextStyle.Default.Size(16))
+ .Row(row =>
+ {
+ row.AutoItem().Text("Left text");
+ row.AutoItem().PaddingHorizontal(10).LineVertical(1).LineColor(Colors.Grey.Medium);
+ row.AutoItem().Text("Right text");
+ });
});
}
}
diff --git a/QuestPDF.Examples/ScaleToFitExamples.cs b/QuestPDF.Examples/ScaleToFitExamples.cs
index f1d714b..b416512 100644
--- a/QuestPDF.Examples/ScaleToFitExamples.cs
+++ b/QuestPDF.Examples/ScaleToFitExamples.cs
@@ -15,7 +15,7 @@ namespace QuestPDF.Examples
RenderingTest
.Create()
.PageSize(PageSizes.A4)
- .ProducePdf()
+ .ProduceImages()
.ShowResults()
.Render(container =>
{
@@ -23,15 +23,15 @@ namespace QuestPDF.Examples
{
var text = Placeholders.Paragraph();
- foreach (var i in Enumerable.Range(0, 16))
+ foreach (var i in Enumerable.Range(2, 5))
{
column
.Item()
.MinimalBox()
.Border(1)
.Padding(5)
- .Width(50 + i * 25)
- .Height(25 + i * 5)
+ .Width(i * 40)
+ .Height(i * 20)
.ScaleToFit()
.Text(text);
}
diff --git a/QuestPDF.Examples/StopPaging.cs b/QuestPDF.Examples/StopPaging.cs
new file mode 100644
index 0000000..cae0c98
--- /dev/null
+++ b/QuestPDF.Examples/StopPaging.cs
@@ -0,0 +1,48 @@
+using NUnit.Framework;
+using QuestPDF.Examples.Engine;
+using QuestPDF.Fluent;
+using QuestPDF.Helpers;
+using QuestPDF.Infrastructure;
+
+namespace QuestPDF.Examples
+{
+ public class StopPaging
+ {
+ [Test]
+ public void Example()
+ {
+ RenderingTest
+ .Create()
+ .PageSize(300, 250)
+ .ProduceImages()
+ .ShowResults()
+ .Render(container =>
+ {
+ container
+ .Padding(25)
+ .DefaultTextStyle(TextStyle.Default.Size(14))
+ .Decoration(decoration =>
+ {
+ decoration
+ .Before()
+ .Text(text =>
+ {
+ text.DefaultTextStyle(TextStyle.Default.SemiBold().Color(Colors.Blue.Medium));
+
+ text.Span("Page ");
+ text.CurrentPageNumber();
+ });
+
+ decoration
+ .Content()
+ .Column(column =>
+ {
+ column.Spacing(25);
+ column.Item().StopPaging().Text(Placeholders.LoremIpsum());
+ column.Item().ExtendHorizontal().Height(75).Background(Colors.Grey.Lighten2);
+ });
+ });
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/QuestPDF/Helpers/Placeholders.cs b/QuestPDF/Helpers/Placeholders.cs
index 6a6d5b5..5fa1e64 100644
--- a/QuestPDF/Helpers/Placeholders.cs
+++ b/QuestPDF/Helpers/Placeholders.cs
@@ -7,7 +7,7 @@ namespace QuestPDF.Helpers
{
public static class Placeholders
{
- public static readonly Random Random = new Random(3); // 3
+ public static readonly Random Random = new();
#region Word Cache
diff --git a/QuestPDF/QuestPDF.csproj b/QuestPDF/QuestPDF.csproj
index c9002a6..9215d4e 100644
--- a/QuestPDF/QuestPDF.csproj
+++ b/QuestPDF/QuestPDF.csproj
@@ -4,7 +4,7 @@
MarcinZiabek
CodeFlint
QuestPDF
- 2022.2.0-beta2
+ 2022.2.0
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.
$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))
9
diff --git a/QuestPDF/Resources/ReleaseNotes.txt b/QuestPDF/Resources/ReleaseNotes.txt
index 73481bb..5bcd0ac 100644
--- a/QuestPDF/Resources/ReleaseNotes.txt
+++ b/QuestPDF/Resources/ReleaseNotes.txt
@@ -1,8 +1,8 @@
-- Added a `ScaleToFit` element - scales it child down so it does fit in the provided space,
+- Added a `ScaleToFit` element - scales its child down so it fits in the provided space,
- Added a `StopPaging` element - when its child requires more than one page to fully render, only the first page is shown,
-- Added a 'LineVertical' and a 'LineHorizontal' elements - those will simplify your code a lot, no need to use the `Border` element anymore!
-- Renaming: the `Stack` element has been renamed to the `Column` element,
-- Renaming: children of the `Row` elements are not called `items` instead of `columns`, e.g. `ConstantItem`, `RelativeItem`, `AutoItem`,
+- Added a 'LineVertical' and a 'LineHorizontal' elements - those will simplify your code a lot, there is no need to use the `Border` element anymore!
+- Renaming: the `Stack` element was renamed to the `Column` element,
+- Renaming: children of the `Row` element are now called `items` instead of `columns`, e.g. `RelativeItem` instead of `RelativeColumn`,
- Added support of the `AutoItem` to the `Row` element - those items take as little width as possible,
- Improved default Fluent configuration behavior for elements: Scale, Padding, Translate,
-- Improved integration support with the HttpContext.Response.Body. This improvement was introduced by schulz3000, thank you!
\ No newline at end of file
+- Improved integration support with the HttpContext.Response.Body. This improvement was introduced by schulz3000, thank you!
diff --git a/readme.md b/readme.md
index 457fe44..3a6b933 100644
--- a/readme.md
+++ b/readme.md
@@ -149,41 +149,40 @@ void ComposeTable(IContainer container)
{
var headerStyle = TextStyle.Default.SemiBold();
- container.Decoration(decoration =>
+ container.Table(table =>
{
- // header
- decoration.Header().BorderBottom(1).Padding(5).Row(row =>
+ table.ColumnsDefinition(columns =>
{
- row.ConstantColumn(25).Text("#", headerStyle);
- row.RelativeColumn(3).Text("Product", headerStyle);
- row.RelativeColumn().AlignRight().Text("Unit price", headerStyle);
- row.RelativeColumn().AlignRight().Text("Quantity", headerStyle);
- row.RelativeColumn().AlignRight().Text("Total", headerStyle);
+ columns.ConstantColumn(25);
+ columns.RelativeColumn(3);
+ columns.RelativeColumn();
+ columns.RelativeColumn();
+ columns.RelativeColumn();
});
-
- // content
- decoration
- .Content()
- .Stack(column =>
- {
- foreach (var item in Model.Items)
- {
- column
- .Item()
- .ShowEntire()
- .BorderBottom(1)
- .BorderColor(Colors.Grey.Lighten2)
- .Padding(5)
- .Row(row =>
- {
- row.ConstantColumn(25).Text(Model.Items.IndexOf(item) + 1);
- row.RelativeColumn(3).Text(item.Name);
- row.RelativeColumn().AlignRight().Text($"{item.Price}$");
- row.RelativeColumn().AlignRight().Text(item.Quantity);
- row.RelativeColumn().AlignRight().Text($"{item.Price * item.Quantity}$");
- });
- }
- });
+
+ table.Header(header =>
+ {
+ header.Cell().Text("#", headerStyle);
+ header.Cell().Text("Product", headerStyle);
+ header.Cell().AlignRight().Text("Unit price", headerStyle);
+ header.Cell().AlignRight().Text("Quantity", headerStyle);
+ header.Cell().AlignRight().Text("Total", headerStyle);
+
+ header.Cell().ColumnSpan(5)
+ .PaddingVertical(5).BorderBottom(1).BorderColor(Colors.Black);
+ });
+
+ foreach (var item in Model.Items)
+ {
+ table.Cell().Text(Model.Items.IndexOf(item) + 1);
+ table.Cell().Text(item.Name);
+ table.Cell().AlignRight().Text($"{item.Price}$");
+ table.Cell().AlignRight().Text(item.Quantity);
+ table.Cell().AlignRight().Text($"{item.Price * item.Quantity}$");
+
+ table.Cell().ColumnSpan(5)
+ .PaddingVertical(5).LineHorizontal(1).LineColor(Colors.Grey.Lighten2);
+ }
});
}
```