|
@@ -293,31 +293,31 @@ public class TableExamples
|
|
|
{
|
|
{
|
|
|
page.MinSize(new PageSize(0, 0));
|
|
page.MinSize(new PageSize(0, 0));
|
|
|
page.MaxSize(new PageSize(700, 1000));
|
|
page.MaxSize(new PageSize(700, 1000));
|
|
|
- page.DefaultTextStyle(x => x.FontSize(20));
|
|
|
|
|
|
|
+ page.DefaultTextStyle(x => x.FontSize(16));
|
|
|
page.Margin(25);
|
|
page.Margin(25);
|
|
|
|
|
|
|
|
page.Content()
|
|
page.Content()
|
|
|
- .Width(325)
|
|
|
|
|
|
|
+ .Width(450)
|
|
|
.Table(table =>
|
|
.Table(table =>
|
|
|
{
|
|
{
|
|
|
table.ColumnsDefinition(columns =>
|
|
table.ColumnsDefinition(columns =>
|
|
|
{
|
|
{
|
|
|
- columns.ConstantColumn(100);
|
|
|
|
|
- columns.RelativeColumn();
|
|
|
|
|
|
|
+ columns.ConstantColumn(150);
|
|
|
columns.RelativeColumn(2);
|
|
columns.RelativeColumn(2);
|
|
|
|
|
+ columns.RelativeColumn(3);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
table.Cell().ColumnSpan(3)
|
|
table.Cell().ColumnSpan(3)
|
|
|
.Background(Colors.Grey.Lighten2).Element(CellStyle)
|
|
.Background(Colors.Grey.Lighten2).Element(CellStyle)
|
|
|
- .Text("Total width: 325px");
|
|
|
|
|
|
|
+ .Text("Total width: 450px");
|
|
|
|
|
|
|
|
- table.Cell().Element(CellStyle).Text("C: 100");
|
|
|
|
|
- table.Cell().Element(CellStyle).Text("R: 1");
|
|
|
|
|
- table.Cell().Element(CellStyle).Text("R: 2");
|
|
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text("Constant: 150px");
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text("Relative: 2*");
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text("Relative: 3*");
|
|
|
|
|
|
|
|
- table.Cell().Element(CellStyle).Text("100px");
|
|
|
|
|
- table.Cell().Element(CellStyle).Text("75px");
|
|
|
|
|
table.Cell().Element(CellStyle).Text("150px");
|
|
table.Cell().Element(CellStyle).Text("150px");
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text("120px");
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text("180px");
|
|
|
|
|
|
|
|
static IContainer CellStyle(IContainer container)
|
|
static IContainer CellStyle(IContainer container)
|
|
|
=> container.Border(1).Padding(10);
|
|
=> container.Border(1).Padding(10);
|
|
@@ -326,4 +326,100 @@ public class TableExamples
|
|
|
})
|
|
})
|
|
|
.GenerateImages(x => "table-columns-definition.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
|
|
.GenerateImages(x => "table-columns-definition.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ [Test]
|
|
|
|
|
+ public void HeaderAndFooter()
|
|
|
|
|
+ {
|
|
|
|
|
+ Document
|
|
|
|
|
+ .Create(document =>
|
|
|
|
|
+ {
|
|
|
|
|
+ document.Page(page =>
|
|
|
|
|
+ {
|
|
|
|
|
+ page.MinSize(new PageSize(0, 0));
|
|
|
|
|
+ page.MaxSize(new PageSize(600, 250));
|
|
|
|
|
+ page.DefaultTextStyle(x => x.FontSize(16));
|
|
|
|
|
+ page.Margin(25);
|
|
|
|
|
+
|
|
|
|
|
+ page.Content()
|
|
|
|
|
+ .Border(1)
|
|
|
|
|
+ .BorderColor(Colors.Grey.Lighten1)
|
|
|
|
|
+ .Table(table =>
|
|
|
|
|
+ {
|
|
|
|
|
+ var pageSizes = new List<(string name, double width, double height)>()
|
|
|
|
|
+ {
|
|
|
|
|
+ ("Letter (ANSI A)", 8.5f, 11),
|
|
|
|
|
+ ("Legal", 8.5f, 14),
|
|
|
|
|
+ ("Ledger (ANSI B)", 11, 17),
|
|
|
|
|
+ ("Tabloid (ANSI B)", 17, 11),
|
|
|
|
|
+ ("ANSI C", 22, 17),
|
|
|
|
|
+ ("ANSI D", 34, 22),
|
|
|
|
|
+ ("ANSI E", 44, 34)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const int inchesToPoints = 72;
|
|
|
|
|
+
|
|
|
|
|
+ IContainer DefaultCellStyle(IContainer container, string backgroundColor)
|
|
|
|
|
+ {
|
|
|
|
|
+ return container
|
|
|
|
|
+ .Border(1)
|
|
|
|
|
+ .BorderColor(Colors.Grey.Lighten1)
|
|
|
|
|
+ .Background(backgroundColor)
|
|
|
|
|
+ .PaddingVertical(5)
|
|
|
|
|
+ .PaddingHorizontal(10)
|
|
|
|
|
+ .AlignCenter()
|
|
|
|
|
+ .AlignMiddle();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ table.ColumnsDefinition(columns =>
|
|
|
|
|
+ {
|
|
|
|
|
+ columns.RelativeColumn();
|
|
|
|
|
+
|
|
|
|
|
+ columns.ConstantColumn(80);
|
|
|
|
|
+ columns.ConstantColumn(80);
|
|
|
|
|
+
|
|
|
|
|
+ columns.ConstantColumn(80);
|
|
|
|
|
+ columns.ConstantColumn(80);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ table.Header(header =>
|
|
|
|
|
+ {
|
|
|
|
|
+ // please be sure to call the 'header' handler!
|
|
|
|
|
+
|
|
|
|
|
+ header.Cell().RowSpan(2).Element(CellStyle).ExtendHorizontal().AlignLeft()
|
|
|
|
|
+ .Text("Document type").Bold();
|
|
|
|
|
+
|
|
|
|
|
+ header.Cell().ColumnSpan(2).Element(CellStyle).Text("Inches").Bold();
|
|
|
|
|
+ header.Cell().ColumnSpan(2).Element(CellStyle).Text("Points").Bold();
|
|
|
|
|
+
|
|
|
|
|
+ header.Cell().Element(CellStyle).Text("Width");
|
|
|
|
|
+ header.Cell().Element(CellStyle).Text("Height");
|
|
|
|
|
+
|
|
|
|
|
+ header.Cell().Element(CellStyle).Text("Width");
|
|
|
|
|
+ header.Cell().Element(CellStyle).Text("Height");
|
|
|
|
|
+
|
|
|
|
|
+ // you can extend existing styles by creating additional methods
|
|
|
|
|
+ IContainer CellStyle(IContainer container) =>
|
|
|
|
|
+ DefaultCellStyle(container, Colors.Grey.Lighten3);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ foreach (var page in pageSizes)
|
|
|
|
|
+ {
|
|
|
|
|
+ table.Cell().Element(CellStyle).ExtendHorizontal().AlignLeft().Text(page.name);
|
|
|
|
|
+
|
|
|
|
|
+ // inches
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text(page.width);
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text(page.height);
|
|
|
|
|
+
|
|
|
|
|
+ // points
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text(page.width * inchesToPoints);
|
|
|
|
|
+ table.Cell().Element(CellStyle).Text(page.height * inchesToPoints);
|
|
|
|
|
+
|
|
|
|
|
+ IContainer CellStyle(IContainer container) =>
|
|
|
|
|
+ DefaultCellStyle(container, Colors.White).ShowOnce();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ .GenerateImages(x => $"table-header-and-footer-{x}.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|