Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a6b11ab85 |
@@ -3,6 +3,7 @@ using NUnit.Framework;
|
|||||||
using QuestPDF.Examples.Engine;
|
using QuestPDF.Examples.Engine;
|
||||||
using QuestPDF.Fluent;
|
using QuestPDF.Fluent;
|
||||||
using QuestPDF.Helpers;
|
using QuestPDF.Helpers;
|
||||||
|
using QuestPDF.Infrastructure;
|
||||||
|
|
||||||
namespace QuestPDF.Examples
|
namespace QuestPDF.Examples
|
||||||
{
|
{
|
||||||
@@ -14,16 +15,20 @@ namespace QuestPDF.Examples
|
|||||||
RenderingTest
|
RenderingTest
|
||||||
.Create()
|
.Create()
|
||||||
.PageSize(PageSizes.A5)
|
.PageSize(PageSizes.A5)
|
||||||
.ProducePdf()
|
.ProduceImages()
|
||||||
.ShowResults()
|
.ShowResults()
|
||||||
.Render(container =>
|
.Render(container =>
|
||||||
{
|
{
|
||||||
container.Padding(25).Column(column =>
|
container
|
||||||
{
|
.Padding(15)
|
||||||
column.Item().Text("Above text");
|
.MinimalBox()
|
||||||
column.Item().PaddingVertical(10).LineHorizontal(1).LineColor(Colors.Blue.Accent1);
|
.DefaultTextStyle(TextStyle.Default.Size(16))
|
||||||
column.Item().Text("Below text");
|
.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
|
RenderingTest
|
||||||
.Create()
|
.Create()
|
||||||
.PageSize(PageSizes.A5)
|
.PageSize(PageSizes.A5)
|
||||||
.ProducePdf()
|
.ProduceImages()
|
||||||
.ShowResults()
|
.ShowResults()
|
||||||
.Render(container =>
|
.Render(container =>
|
||||||
{
|
{
|
||||||
container.Padding(25).Inlined(inlined =>
|
container
|
||||||
{
|
.Padding(15)
|
||||||
inlined.Spacing(5);
|
.DefaultTextStyle(TextStyle.Default.Size(16))
|
||||||
inlined.Item().Text("Above text");
|
.Row(row =>
|
||||||
inlined.Item().LineVertical(1).LineColor(Colors.Blue.Accent1);
|
{
|
||||||
inlined.Item().Text("Below text");
|
row.AutoItem().Text("Left text");
|
||||||
});
|
row.AutoItem().PaddingHorizontal(10).LineVertical(1).LineColor(Colors.Grey.Medium);
|
||||||
|
row.AutoItem().Text("Right text");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace QuestPDF.Examples
|
|||||||
RenderingTest
|
RenderingTest
|
||||||
.Create()
|
.Create()
|
||||||
.PageSize(PageSizes.A4)
|
.PageSize(PageSizes.A4)
|
||||||
.ProducePdf()
|
.ProduceImages()
|
||||||
.ShowResults()
|
.ShowResults()
|
||||||
.Render(container =>
|
.Render(container =>
|
||||||
{
|
{
|
||||||
@@ -23,15 +23,15 @@ namespace QuestPDF.Examples
|
|||||||
{
|
{
|
||||||
var text = Placeholders.Paragraph();
|
var text = Placeholders.Paragraph();
|
||||||
|
|
||||||
foreach (var i in Enumerable.Range(0, 16))
|
foreach (var i in Enumerable.Range(2, 5))
|
||||||
{
|
{
|
||||||
column
|
column
|
||||||
.Item()
|
.Item()
|
||||||
.MinimalBox()
|
.MinimalBox()
|
||||||
.Border(1)
|
.Border(1)
|
||||||
.Padding(5)
|
.Padding(5)
|
||||||
.Width(50 + i * 25)
|
.Width(i * 40)
|
||||||
.Height(25 + i * 5)
|
.Height(i * 20)
|
||||||
.ScaleToFit()
|
.ScaleToFit()
|
||||||
.Text(text);
|
.Text(text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace QuestPDF.Helpers
|
|||||||
{
|
{
|
||||||
public static class Placeholders
|
public static class Placeholders
|
||||||
{
|
{
|
||||||
public static readonly Random Random = new Random(3); // 3
|
public static readonly Random Random = new();
|
||||||
|
|
||||||
#region Word Cache
|
#region Word Cache
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<Authors>MarcinZiabek</Authors>
|
<Authors>MarcinZiabek</Authors>
|
||||||
<Company>CodeFlint</Company>
|
<Company>CodeFlint</Company>
|
||||||
<PackageId>QuestPDF</PackageId>
|
<PackageId>QuestPDF</PackageId>
|
||||||
<Version>2022.2.0-beta2</Version>
|
<Version>2022.2.0</Version>
|
||||||
<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>
|
||||||
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
|
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
|
||||||
<LangVersion>9</LangVersion>
|
<LangVersion>9</LangVersion>
|
||||||
|
|||||||
@@ -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 `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!
|
- 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 has been renamed to the `Column` element,
|
- Renaming: the `Stack` element was renamed to the `Column` element,
|
||||||
- Renaming: children of the `Row` elements are not called `items` instead of `columns`, e.g. `ConstantItem`, `RelativeItem`, `AutoItem`,
|
- 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,
|
- 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 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!
|
- Improved integration support with the HttpContext.Response.Body. This improvement was introduced by schulz3000, thank you!
|
||||||
@@ -149,41 +149,40 @@ void ComposeTable(IContainer container)
|
|||||||
{
|
{
|
||||||
var headerStyle = TextStyle.Default.SemiBold();
|
var headerStyle = TextStyle.Default.SemiBold();
|
||||||
|
|
||||||
container.Decoration(decoration =>
|
container.Table(table =>
|
||||||
{
|
{
|
||||||
// header
|
table.ColumnsDefinition(columns =>
|
||||||
decoration.Header().BorderBottom(1).Padding(5).Row(row =>
|
|
||||||
{
|
{
|
||||||
row.ConstantColumn(25).Text("#", headerStyle);
|
columns.ConstantColumn(25);
|
||||||
row.RelativeColumn(3).Text("Product", headerStyle);
|
columns.RelativeColumn(3);
|
||||||
row.RelativeColumn().AlignRight().Text("Unit price", headerStyle);
|
columns.RelativeColumn();
|
||||||
row.RelativeColumn().AlignRight().Text("Quantity", headerStyle);
|
columns.RelativeColumn();
|
||||||
row.RelativeColumn().AlignRight().Text("Total", headerStyle);
|
columns.RelativeColumn();
|
||||||
});
|
});
|
||||||
|
|
||||||
// content
|
table.Header(header =>
|
||||||
decoration
|
{
|
||||||
.Content()
|
header.Cell().Text("#", headerStyle);
|
||||||
.Stack(column =>
|
header.Cell().Text("Product", headerStyle);
|
||||||
{
|
header.Cell().AlignRight().Text("Unit price", headerStyle);
|
||||||
foreach (var item in Model.Items)
|
header.Cell().AlignRight().Text("Quantity", headerStyle);
|
||||||
{
|
header.Cell().AlignRight().Text("Total", headerStyle);
|
||||||
column
|
|
||||||
.Item()
|
header.Cell().ColumnSpan(5)
|
||||||
.ShowEntire()
|
.PaddingVertical(5).BorderBottom(1).BorderColor(Colors.Black);
|
||||||
.BorderBottom(1)
|
});
|
||||||
.BorderColor(Colors.Grey.Lighten2)
|
|
||||||
.Padding(5)
|
foreach (var item in Model.Items)
|
||||||
.Row(row =>
|
{
|
||||||
{
|
table.Cell().Text(Model.Items.IndexOf(item) + 1);
|
||||||
row.ConstantColumn(25).Text(Model.Items.IndexOf(item) + 1);
|
table.Cell().Text(item.Name);
|
||||||
row.RelativeColumn(3).Text(item.Name);
|
table.Cell().AlignRight().Text($"{item.Price}$");
|
||||||
row.RelativeColumn().AlignRight().Text($"{item.Price}$");
|
table.Cell().AlignRight().Text(item.Quantity);
|
||||||
row.RelativeColumn().AlignRight().Text(item.Quantity);
|
table.Cell().AlignRight().Text($"{item.Price * item.Quantity}$");
|
||||||
row.RelativeColumn().AlignRight().Text($"{item.Price * item.Quantity}$");
|
|
||||||
});
|
table.Cell().ColumnSpan(5)
|
||||||
}
|
.PaddingVertical(5).LineHorizontal(1).LineColor(Colors.Grey.Lighten2);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user