public void DefaultTextStyle() { RenderingTest .Create() .ProducePdf() .ShowResults() .RenderDocument(container => { container.Page(page => { // all text in this set of pages has size 20 page.DefaultTextStyle(TextStyle.Default.Size(20)); page.Margin(20); page.Size(PageSizes.A4); page.PageColor(Colors.White); page.Content().Column(column => { column.Item().Text(Placeholders.Sentence()); column.Item().Text(text => { // text in this block is additionally semibold text.DefaultTextStyle(TextStyle.Default.SemiBold()); text.Line(Placeholders.Sentence()); // this text has size 20 but also semibold and red text.Span(Placeholders.Sentence()).FontColor(Colors.Red.Medium); }); }); }); }); }
public void LayersExample() { RenderingTest .Create() .PageSize(400, 250) .Render(container => { container .Padding(25) .Layers(layers => { // layer below main content layers .Layer() .Height(100) .Width(100) .Background(Colors.Grey.Lighten3); layers .PrimaryLayer() .Padding(25) .Column(column => { column.Spacing(5); foreach (var _ in Enumerable.Range(0, 7)) { column.Item().Text(Placeholders.Sentence()); } }); // layer above the main content layers .Layer() .AlignCenter() .AlignMiddle() .Text("Watermark") .FontSize(48) .Bold() .FontColor(Colors.Green.Lighten3); layers .Layer() .AlignBottom() .Text(text => text.CurrentPageNumber().FontSize(16).FontColor(Colors.Green.Medium)); }); }); }
public static void GeneratePerformanceStructure(IContainer container, int repeats) { container .Padding(25) //.Background(Colors.Blue.Lighten2) .MinimalBox() .Border(1) //.Background(Colors.Red.Lighten2) .Table(table => { table.ColumnsDefinition(columns => { columns.ConstantColumn(100); columns.RelativeColumn(); columns.ConstantColumn(100); columns.RelativeColumn(); }); table.ExtendLastCellsToTableBottom(); foreach (var i in Enumerable.Range(0, repeats)) { table.Cell().RowSpan(3).LabelCell("Project"); table.Cell().RowSpan(3).ShowEntire().ValueCell(Placeholders.Sentence()); table.Cell().LabelCell("Report number"); table.Cell().ValueCell(i.ToString()); table.Cell().LabelCell("Date"); table.Cell().ValueCell(Placeholders.ShortDate()); table.Cell().LabelCell("Inspector"); table.Cell().ValueCell("Marcin Ziąbek"); table.Cell().ColumnSpan(2).LabelCell("Morning weather"); table.Cell().ColumnSpan(2).LabelCell("Evening weather"); table.Cell().ValueCell("Time"); table.Cell().ValueCell("7:13"); table.Cell().ValueCell("Time"); table.Cell().ValueCell("18:25"); table.Cell().ValueCell("Description"); table.Cell().ValueCell("Sunny"); table.Cell().ValueCell("Description"); table.Cell().ValueCell("Windy"); table.Cell().ValueCell("Wind"); table.Cell().ValueCell("Mild"); table.Cell().ValueCell("Wind"); table.Cell().ValueCell("Strong"); table.Cell().ValueCell("Temperature"); table.Cell().ValueCell("17°C"); table.Cell().ValueCell("Temperature"); table.Cell().ValueCell("32°C"); table.Cell().LabelCell("Remarks"); table.Cell().ColumnSpan(3).ValueCell(Placeholders.Paragraph()); } }); }
public static ReportModel GetReport() { return(new ReportModel { Title = "Sample Report Document", HeaderFields = HeaderFields(), LogoData = Helpers.GetImage("Logo.png"), Sections = Enumerable.Range(0, 40).Select(x => GenerateSection()).ToList(), Photos = Enumerable.Range(0, 25).Select(x => GetReportPhotos()).ToList() }); List <ReportHeaderField> HeaderFields() { return(new List <ReportHeaderField> { new ReportHeaderField() { Label = "Scope", Value = "Internal activities" }, new ReportHeaderField() { Label = "Author", Value = "Marcin Ziąbek" }, new ReportHeaderField() { Label = "Date", Value = DateTime.Now.ToString("g") }, new ReportHeaderField() { Label = "Status", Value = "Completed, found 2 issues" } }); } ReportSection GenerateSection() { var sectionLength = Helpers.Random.NextDouble() > 0.75 ? Helpers.Random.Next(20, 40) : Helpers.Random.Next(5, 10); return(new ReportSection { Title = Placeholders.Label(), Parts = Enumerable.Range(0, sectionLength).Select(x => GetRandomElement()).ToList() }); } ReportSectionElement GetRandomElement() { var random = Helpers.Random.NextDouble(); if (random < 0.9f) { return(GetTextElement()); } if (random < 0.95f) { return(GetMapElement()); } return(GetPhotosElement()); } ReportSectionText GetTextElement() { return(new ReportSectionText { Label = Placeholders.Label(), Text = Placeholders.Paragraph() }); } ReportSectionMap GetMapElement() { return(new ReportSectionMap { Label = "Location", Location = Helpers.RandomLocation() }); } ReportSectionPhotos GetPhotosElement() { return(new ReportSectionPhotos { Label = "Photos", PhotoCount = Helpers.Random.Next(1, 15) }); } ReportPhoto GetReportPhotos() { return(new ReportPhoto() { Comments = Placeholders.Sentence(), Date = DateTime.Now - TimeSpan.FromDays(Helpers.Random.NextDouble() * 100), Location = Helpers.RandomLocation() }); } }