Skip to content

Commit baac7f1

Browse files
committed
Updated to QuestPDF 2021.5.2
1 parent 04c5e2c commit baac7f1

3 files changed

Lines changed: 35 additions & 35 deletions

File tree

‎InvoiceDocument.cs‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public void Compose(IContainer container)
2323
.PaddingVertical(50)
2424
.Page(page =>
2525
{
26-
page.Header(ComposeHeader);
27-
page.Content(ComposeContent);
26+
page.Header().Element(ComposeHeader);
27+
page.Content().Element(ComposeContent);
2828
page.Footer().AlignCenter().PageNumber("Page {number}");
2929
});
3030
}
@@ -33,11 +33,11 @@ void ComposeHeader(IContainer container)
3333
{
3434
container.Row(row =>
3535
{
36-
row.RelativeColumn().Stack(column =>
36+
row.RelativeColumn().Stack(stack =>
3737
{
38-
column.Element().Text($"Invoice #{Model.InvoiceNumber}", TextStyle.Default.Size(20).Bold());
39-
column.Element().Text($"Issue date: {Model.IssueDate:d}");
40-
column.Element().Text($"Due date: {Model.DueDate:d}");
38+
stack.Item().Text($"Invoice #{Model.InvoiceNumber}", TextStyle.Default.Size(20).Bold());
39+
stack.Item().Text($"Issue date: {Model.IssueDate:d}");
40+
stack.Item().Text($"Due date: {Model.DueDate:d}");
4141
});
4242

4343
row.ConstantColumn(100).Height(50).Placeholder();
@@ -46,35 +46,35 @@ void ComposeHeader(IContainer container)
4646

4747
void ComposeContent(IContainer container)
4848
{
49-
container.PaddingVertical(40).PageableStack(column =>
49+
container.PaddingVertical(40).Stack(column =>
5050
{
5151
column.Spacing(5);
5252

53-
column.Element().Row(row =>
53+
column.Item().Row(row =>
5454
{
5555
row.RelativeColumn().Component(new AddressComponent("From", Model.SellerAddress));
5656
row.ConstantColumn(50);
5757
row.RelativeColumn().Component(new AddressComponent("For", Model.CustomerAddress));
5858
});
5959

60-
column.Element(ComposeTable);
60+
column.Item().Element(ComposeTable);
6161

6262
var totalPrice = Model.Items.Sum(x => x.Price * x.Quantity);
63-
column.Element().PaddingRight(5).AlignRight().Text($"Grand total: {totalPrice}$", TextStyle.Default.SemiBold());
63+
column.Item().PaddingRight(5).AlignRight().Text($"Grand total: {totalPrice}$", TextStyle.Default.SemiBold());
6464

6565
if (!string.IsNullOrWhiteSpace(Model.Comments))
66-
column.Element().PaddingTop(25).Element(ComposeComments);
66+
column.Item().PaddingTop(25).Element(ComposeComments);
6767
});
6868
}
6969

7070
void ComposeTable(IContainer container)
7171
{
7272
var headerStyle = TextStyle.Default.SemiBold();
7373

74-
container.PaddingTop(10).Section(section =>
74+
container.PaddingTop(10).Decoration(decoration =>
7575
{
7676
// header
77-
section.Header().BorderBottom(1).Padding(5).Row(row =>
77+
decoration.Header().BorderBottom(1).Padding(5).Row(row =>
7878
{
7979
row.ConstantColumn(25).Text("#", headerStyle);
8080
row.RelativeColumn(3).Text("Product", headerStyle);
@@ -84,13 +84,13 @@ void ComposeTable(IContainer container)
8484
});
8585

8686
// content
87-
section
87+
decoration
8888
.Content()
89-
.PageableStack(column =>
89+
.Stack(column =>
9090
{
9191
foreach (var item in Model.Items)
9292
{
93-
column.Element().BorderBottom(1).BorderColor("CCC").Padding(5).Row(row =>
93+
column.Item().BorderBottom(1).BorderColor("CCC").Padding(5).Row(row =>
9494
{
9595
row.ConstantColumn(25).Text(Model.Items.IndexOf(item) + 1);
9696
row.RelativeColumn(3).Text(item.Name);
@@ -105,11 +105,11 @@ void ComposeTable(IContainer container)
105105

106106
void ComposeComments(IContainer container)
107107
{
108-
container.Background("#EEE").Padding(10).Stack(message =>
108+
container.ShowEntire().Background("#EEE").Padding(10).Stack(message =>
109109
{
110110
message.Spacing(5);
111-
message.Element().Text("Comments", TextStyle.Default.Size(14).SemiBold());
112-
message.Element().Text(Model.Comments);
111+
message.Item().Text("Comments", TextStyle.Default.Size(14).SemiBold());
112+
message.Item().Text(Model.Comments);
113113
});
114114
}
115115
}
@@ -127,17 +127,17 @@ public AddressComponent(string title, Address address)
127127

128128
public void Compose(IContainer container)
129129
{
130-
container.Stack(column =>
130+
container.ShowEntire().Stack(column =>
131131
{
132132
column.Spacing(5);
133133

134-
column.Element().BorderBottom(1).PaddingBottom(5).Text(Title, TextStyle.Default.SemiBold());
134+
column.Item().BorderBottom(1).PaddingBottom(5).Text(Title, TextStyle.Default.SemiBold());
135135

136-
column.Element().Text(Address.CompanyName);
137-
column.Element().Text(Address.Street);
138-
column.Element().Text($"{Address.City}, {Address.State}");
139-
column.Element().Text(Address.Email);
140-
column.Element().Text(Address.Phone);
136+
column.Item().Text(Address.CompanyName);
137+
column.Item().Text(Address.Street);
138+
column.Item().Text($"{Address.City}, {Address.State}");
139+
column.Item().Text(Address.Email);
140+
column.Item().Text(Address.Phone);
141141
});
142142
}
143143
}

‎InvoiceDocumentDataSource.cs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public static InvoiceModel GetInvoiceDetails()
2525
CustomerAddress = GenerateRandomAddress(),
2626

2727
Items = items,
28-
Comments = TextPlaceholder.Paragraph()
28+
Comments = Placeholders.Paragraph()
2929
};
3030
}
3131

3232
private static OrderItem GenerateRandomOrderItem()
3333
{
3434
return new OrderItem
3535
{
36-
Name = TextPlaceholder.Label(),
36+
Name = Placeholders.Label(),
3737
Price = (decimal) Math.Round(Random.NextDouble() * 100, 2),
3838
Quantity = Random.Next(1, 10)
3939
};
@@ -43,12 +43,12 @@ private static Address GenerateRandomAddress()
4343
{
4444
return new Address
4545
{
46-
CompanyName = TextPlaceholder.Name(),
47-
Street = TextPlaceholder.Label(),
48-
City = TextPlaceholder.Label(),
49-
State = TextPlaceholder.Label(),
50-
Email = TextPlaceholder.Email(),
51-
Phone = TextPlaceholder.PhoneNumber()
46+
CompanyName = Placeholders.Name(),
47+
Street = Placeholders.Label(),
48+
City = Placeholders.Label(),
49+
State = Placeholders.Label(),
50+
Email = Placeholders.Email(),
51+
Phone = Placeholders.PhoneNumber()
5252
};
5353
}
5454
}

‎QuestPDF.ExampleInvoice.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="QuestPDF" Version="2021.3.1" />
10+
<PackageReference Include="QuestPDF" Version="2021.5.2" />
1111
</ItemGroup>
1212

1313
</Project>

0 commit comments

Comments
 (0)