Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6e0bd505c | |||
| 779245b260 | |||
| 1698212669 | |||
| 388adc5ad1 | |||
| 81a9599b99 | |||
| 48f41db98b | |||
| 3dd8513e42 | |||
| c3d805e5e5 | |||
| f77d8baa63 | |||
| 950d971119 | |||
| e4203838cb | |||
| 25b690fcca | |||
| 4e3ba1d878 | |||
| 3f0b500b1b | |||
| fb3aec4bf8 | |||
| 8c2250ecde | |||
| bb2850b2d8 | |||
| 842b856f7a | |||
| 733dbc8746 | |||
| 0b7b05d36c | |||
| a83ebe2fed | |||
| 6f0c6513da | |||
| 500cea1fbf | |||
| 3369da42ed | |||
| c5cb588857 | |||
| 08126b2fa4 | |||
| 5e9ff7ec1e | |||
| 9c05c182b8 | |||
| dee97b22e4 | |||
| 1d1d969b5a | |||
| 190b1e7dee | |||
| 98be1abe74 |
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Please provide an example, minimalistic code that shows the problem.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is.
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,7 +1,7 @@
|
||||
using QuestPDF.Examples.Engine;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace QuestPDF.Examples
|
||||
{
|
||||
@@ -24,7 +24,7 @@ namespace QuestPDF.Examples
|
||||
container
|
||||
.Background("#FFF")
|
||||
.Padding(25)
|
||||
.Section(section =>
|
||||
.Decoration(section =>
|
||||
{
|
||||
section
|
||||
.Header()
|
||||
@@ -37,7 +37,7 @@ namespace QuestPDF.Examples
|
||||
.Background("#DDD")
|
||||
.Padding(10)
|
||||
.ExtendVertical()
|
||||
.Text(TextPlaceholder.LoremIpsum());
|
||||
.Text(Helpers.Placeholders.LoremIpsum());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ namespace QuestPDF.Examples
|
||||
.Padding(20)
|
||||
.Stack(stack =>
|
||||
{
|
||||
stack.Element()
|
||||
stack.Item()
|
||||
.PaddingBottom(10)
|
||||
.AlignCenter()
|
||||
.Text("This Row element is 700pt wide");
|
||||
|
||||
stack.Element().Row(row =>
|
||||
stack.Item().Row(row =>
|
||||
{
|
||||
row.ConstantColumn(100)
|
||||
.Background("#DDD")
|
||||
@@ -119,20 +119,109 @@ namespace QuestPDF.Examples
|
||||
column.Spacing(10);
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Background("#999")
|
||||
.Height(50);
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Background("#BBB")
|
||||
.Height(100);
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Background("#DDD")
|
||||
.Height(150);
|
||||
});
|
||||
}
|
||||
|
||||
//[ShowResult]
|
||||
[ImageSize(300, 200)]
|
||||
public void Debug(IContainer container)
|
||||
{
|
||||
container
|
||||
.Padding(25)
|
||||
.Debug()
|
||||
.Padding(-5)
|
||||
.Row(row =>
|
||||
{
|
||||
row.RelativeColumn().Padding(5).Extend().Placeholder();
|
||||
row.RelativeColumn().Padding(5).Extend().Placeholder();
|
||||
});
|
||||
}
|
||||
|
||||
//[ShowResult]
|
||||
[ImageSize(300, 200)]
|
||||
public void ElementEnd(IContainer container)
|
||||
{
|
||||
var text = "";
|
||||
|
||||
container
|
||||
.Padding(10)
|
||||
.Element(x =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
x.Height(10).Width(50).Background("#DDD");
|
||||
else
|
||||
x.Text(text);
|
||||
});
|
||||
}
|
||||
|
||||
//[ShowResult]
|
||||
[ImageSize(300, 200)]
|
||||
public void GridExample(IContainer container)
|
||||
{
|
||||
var textStyle = TextStyle.Default.Size(14);
|
||||
|
||||
container
|
||||
.Padding(20)
|
||||
.AlignRight()
|
||||
.Grid(grid =>
|
||||
{
|
||||
grid.Spacing(5);
|
||||
grid.Columns(12);
|
||||
|
||||
grid.Element(8).Background("#DDD").Height(50).Padding(5).Text("This is a short text", textStyle);
|
||||
grid.Element(4).Background("#BBB").Padding(5).Text("Showing how to...", textStyle);
|
||||
grid.Element(2).Background("#999").Height(50);
|
||||
grid.Element(4).Background("#AAA").Border(2).BorderColor("#666").Padding(5).Text("...generate", textStyle);
|
||||
grid.Element(6).Background("#CCC").Padding(5).Text("simple grids", textStyle.Size(18).Bold());
|
||||
grid.Element(8).Background("#DDD").Height(50);
|
||||
});
|
||||
}
|
||||
|
||||
[ShowResult]
|
||||
[ImageSize(300, 300)]
|
||||
public void Layers(IContainer container)
|
||||
{
|
||||
container
|
||||
.Background("#FFF")
|
||||
.Padding(25)
|
||||
.Layers(layers =>
|
||||
{
|
||||
layers.Layer().Text("Something else");
|
||||
|
||||
layers.PrimaryLayer().Stack(stack =>
|
||||
{
|
||||
stack.Item().PaddingTop(20).Text("Text 1");
|
||||
stack.Item().PaddingTop(40).Text("Text 2");
|
||||
});
|
||||
|
||||
layers.Layer().Canvas((canvas, size) =>
|
||||
{
|
||||
using var paint = new SKPaint
|
||||
{
|
||||
Color = SKColors.Red,
|
||||
StrokeWidth = 5
|
||||
};
|
||||
|
||||
canvas.Translate(size.Width / 2, size.Height / 2);
|
||||
canvas.DrawCircle(0, 0, 50, paint);
|
||||
});
|
||||
|
||||
layers.Layer().Background("#8F00").Extend();
|
||||
layers.Layer().PaddingTop(40).Text("It works!", TextStyle.Default.Size(24));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
@@ -62,10 +61,17 @@ namespace QuestPDF.Examples.Engine
|
||||
methodInfo.Invoke(this, new object[] {container});
|
||||
|
||||
Func<int, string> fileNameSchema = i => $"{fileName.ToLower()}-${i}.png";
|
||||
|
||||
var document = new SimpleDocument(container, size);
|
||||
document.GenerateImages(fileNameSchema);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var document = new SimpleDocument(container, size);
|
||||
document.GenerateImages(fileNameSchema);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"Cannot perform test {fileName}", e);
|
||||
}
|
||||
|
||||
if (showResult)
|
||||
Process.Start("explorer", fileNameSchema(0));
|
||||
}
|
||||
@@ -79,7 +85,7 @@ namespace QuestPDF.Examples.Engine
|
||||
using var surface = SKSurface.Create(imageInfo);
|
||||
surface.Canvas.Scale(scalingFactor);
|
||||
|
||||
var canvas = new Canvas(surface.Canvas);
|
||||
var canvas = new Drawing.Canvas(surface.Canvas);
|
||||
element?.Draw(canvas, size);
|
||||
|
||||
surface.Canvas.Save();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace QuestPDF.Examples.Engine
|
||||
|
||||
public void Compose(IContainer container)
|
||||
{
|
||||
container.Element(Container.Child);
|
||||
container.Background("#FFF").Element(Container.Child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using QuestPDF.Examples.Engine;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
@@ -33,10 +32,10 @@ namespace QuestPDF.Examples
|
||||
{
|
||||
for(var i=1; i<=4; i++)
|
||||
{
|
||||
stack.Element().Row(row =>
|
||||
stack.Item().Row(row =>
|
||||
{
|
||||
row.RelativeColumn(2).LabelCell().Text(TextPlaceholder.Label());
|
||||
row.RelativeColumn(3).ValueCell().Text(TextPlaceholder.Paragraph());
|
||||
row.RelativeColumn(2).LabelCell().Text(Placeholders.Label());
|
||||
row.RelativeColumn(3).ValueCell().Text(Placeholders.Paragraph());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace QuestPDF.Examples
|
||||
column.Spacing(10);
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Component(new LoremPicsum(true));
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.AlignRight()
|
||||
.Text("From Lorem Picsum");
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace QuestPDF.Examples
|
||||
.Stack(column =>
|
||||
{
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Height(100)
|
||||
.Background("#FFF")
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace QuestPDF.Examples
|
||||
.Background("#444");
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Height(100)
|
||||
.Background("#DDD")
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace QuestPDF.Examples
|
||||
.Background("#222");
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Height(100)
|
||||
.Background("#BBB")
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace QuestPDF.Examples
|
||||
.Stack(column =>
|
||||
{
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Height(150)
|
||||
.Row(row =>
|
||||
{
|
||||
@@ -108,7 +108,7 @@ namespace QuestPDF.Examples
|
||||
});
|
||||
|
||||
column
|
||||
.Element()
|
||||
.Item()
|
||||
.Height(150)
|
||||
.Row(row =>
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\QuestPDF.InvoiceSample\QuestPDF.InvoiceSample.csproj" />
|
||||
<ProjectReference Include="..\QuestPDF\QuestPDF.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.ReportSample.Layouts;
|
||||
|
||||
namespace QuestPDF.ReportSample
|
||||
{
|
||||
@@ -18,9 +17,9 @@ namespace QuestPDF.ReportSample
|
||||
Title = "Sample Report Document",
|
||||
HeaderFields = HeaderFields(),
|
||||
|
||||
LogoData = Helpers.GetImage("logo.png"),
|
||||
Sections = Enumerable.Range(0, 10).Select(x => GenerateSection()).ToList(),
|
||||
Photos = Enumerable.Range(0, 10).Select(x => GetReportPhotos()).ToList()
|
||||
LogoData = Helpers.GetImage("Logo.png"),
|
||||
Sections = Enumerable.Range(0, 8).Select(x => GenerateSection()).ToList(),
|
||||
Photos = Enumerable.Range(2, 6).Select(x => GetReportPhotos()).ToList()
|
||||
};
|
||||
|
||||
List<ReportHeaderField> HeaderFields()
|
||||
@@ -41,6 +40,11 @@ namespace QuestPDF.ReportSample
|
||||
{
|
||||
Label = "Date",
|
||||
Value = DateTime.Now.ToString("g")
|
||||
},
|
||||
new ReportHeaderField()
|
||||
{
|
||||
Label = "Status",
|
||||
Value = "Completed, found 2 issues"
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -53,7 +57,7 @@ namespace QuestPDF.ReportSample
|
||||
|
||||
return new ReportSection
|
||||
{
|
||||
Title = TextPlaceholder.Label(),
|
||||
Title = Placeholders.Label(),
|
||||
Parts = Enumerable.Range(0, sectionLength).Select(x => GetRandomElement()).ToList()
|
||||
};
|
||||
}
|
||||
@@ -62,10 +66,10 @@ namespace QuestPDF.ReportSample
|
||||
{
|
||||
var random = Helpers.Random.NextDouble();
|
||||
|
||||
if (random < 0.8f)
|
||||
if (random < 0.9f)
|
||||
return GetTextElement();
|
||||
|
||||
if (random < 0.9f)
|
||||
if (random < 0.95f)
|
||||
return GetMapElement();
|
||||
|
||||
return GetPhotosElement();
|
||||
@@ -75,19 +79,17 @@ namespace QuestPDF.ReportSample
|
||||
{
|
||||
return new ReportSectionText
|
||||
{
|
||||
Label = TextPlaceholder.Label(),
|
||||
Text = TextPlaceholder.Paragraph()
|
||||
Label = Placeholders.Label(),
|
||||
Text = Placeholders.Paragraph()
|
||||
};
|
||||
}
|
||||
|
||||
ReportSectionMap GetMapElement()
|
||||
{
|
||||
var rnd = Helpers.Random.Next(0, 64);
|
||||
|
||||
return new ReportSectionMap
|
||||
{
|
||||
Label = "Location",
|
||||
ImageSource = x => Helpers.GetDocumentMap($"{rnd}.jpg"),
|
||||
ImageSource = Placeholders.Image,
|
||||
Location = Helpers.RandomLocation()
|
||||
};
|
||||
}
|
||||
@@ -100,26 +102,23 @@ namespace QuestPDF.ReportSample
|
||||
Photos = Enumerable
|
||||
.Range(0, Helpers.Random.Next(1, 10))
|
||||
.Select(x => Helpers.Random.Next(0, 128))
|
||||
.Select(x => Helpers.GetPhoto($"{x}.jpg"))
|
||||
.Select(x => Placeholders.Image(400, 300))
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
|
||||
ReportPhoto GetReportPhotos()
|
||||
{
|
||||
var photoId = Helpers.Random.Next(0, 128);
|
||||
var mapId = Helpers.Random.Next(0, 64);
|
||||
|
||||
return new ReportPhoto()
|
||||
{
|
||||
PhotoData = Helpers.GetPhoto($"{photoId}.jpg"),
|
||||
PhotoData = Placeholders.Image(400, 300),
|
||||
|
||||
Comments = TextPlaceholder.Paragraph(),
|
||||
Comments = Placeholders.Sentence(),
|
||||
Date = DateTime.Now - TimeSpan.FromDays(Helpers.Random.NextDouble() * 100),
|
||||
Location = Helpers.RandomLocation(),
|
||||
|
||||
MapContextSource = x => Helpers.GetContextMap($"{mapId}.jpg"),
|
||||
MapDetailsSource = x => Helpers.GetDetailsMap($"{mapId}.jpg")
|
||||
MapContextSource = x => Placeholders.Image(400, 300),
|
||||
MapDetailsSource = x => Placeholders.Image(400, 300)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using QuestPDF.ReportSample.Layouts;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace QuestPDF.ReportSample
|
||||
@@ -10,13 +9,7 @@ namespace QuestPDF.ReportSample
|
||||
public static Random Random { get; } = new Random();
|
||||
|
||||
public static string GetTestItem(string path) => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", path);
|
||||
|
||||
public static byte[] GetDocumentMap(string name) => GetImage(Path.Combine("Maps", "Document", name));
|
||||
public static byte[] GetDetailsMap(string name) => GetImage(Path.Combine("Maps", "Details", name));
|
||||
public static byte[] GetContextMap(string name) => GetImage(Path.Combine("Maps", "Context", name));
|
||||
|
||||
public static byte[] GetPhoto(string name) => GetImage(Path.Combine("Photos", name));
|
||||
|
||||
|
||||
public static byte[] GetImage(string name)
|
||||
{
|
||||
var photoPath = GetTestItem(name);
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
using System;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.ReportSample.Layouts
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
static IContainer Cell(this IContainer container, string color)
|
||||
static IContainer Cell(this IContainer container, bool background)
|
||||
{
|
||||
return container
|
||||
.Border(0.5f)
|
||||
.Background(color)
|
||||
.BorderColor(Colors.Grey.Lighten1)
|
||||
.Background(background ? Colors.Grey.Lighten4 : Colors.White)
|
||||
.Padding(5);
|
||||
}
|
||||
|
||||
public static IContainer LightCell(this IContainer container)
|
||||
public static IContainer ValueCell(this IContainer container)
|
||||
{
|
||||
return container.Cell("#0000");
|
||||
return container.Cell(false);
|
||||
}
|
||||
|
||||
public static IContainer DarkCell(this IContainer container)
|
||||
public static IContainer LabelCell(this IContainer container)
|
||||
{
|
||||
return container.Cell("#1000");
|
||||
return container.Cell(true);
|
||||
}
|
||||
|
||||
public static string Format(this Location location)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.ReportSample.Layouts
|
||||
@@ -15,47 +16,45 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
public void Compose(IContainer container)
|
||||
{
|
||||
container
|
||||
.ShowEntire()
|
||||
.Stack(stack =>
|
||||
{
|
||||
stack.Element(PhotoWithMaps);
|
||||
stack.Element(PhotoDetails);
|
||||
stack.Spacing(5);
|
||||
stack.Item(PhotoWithMaps);
|
||||
stack.Item(PhotoDetails);
|
||||
});
|
||||
}
|
||||
|
||||
void PhotoWithMaps(IContainer container)
|
||||
{
|
||||
container
|
||||
.Padding(-3)
|
||||
.PaddingBottom(3)
|
||||
.Row(row =>
|
||||
{
|
||||
row.RelativeColumn(2).Padding(3).Component(new ImageTemplate(Model.PhotoData));
|
||||
row.RelativeColumn(2).AspectRatio(4 / 3f).Image(Placeholders.Image);
|
||||
|
||||
row.RelativeColumn().Stack(stack =>
|
||||
row.RelativeColumn().PaddingLeft(5).Stack(stack =>
|
||||
{
|
||||
stack.Element().Padding(3).Component(new ImageTemplate(Model.MapDetailsSource));
|
||||
stack.Element().Padding(3).Component(new ImageTemplate(Model.MapContextSource));
|
||||
stack.Spacing(7f);
|
||||
|
||||
stack.Item().AspectRatio(4 / 3f).Image(Placeholders.Image);
|
||||
stack.Item().AspectRatio(4 / 3f).Image(Placeholders.Image);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void PhotoDetails(IContainer container)
|
||||
{
|
||||
container.Stack(stack =>
|
||||
container.Border(0.75f).BorderColor(Colors.Grey.Medium).Grid(grid =>
|
||||
{
|
||||
stack.Element().Row(row =>
|
||||
{
|
||||
row.RelativeColumn().DarkCell().Text("Date", Typography.Normal);
|
||||
row.RelativeColumn(2).LightCell().Text(Model.Date?.ToString("g") ?? string.Empty, Typography.Normal);
|
||||
row.RelativeColumn().DarkCell().Text("Location", Typography.Normal);
|
||||
row.RelativeColumn(2).LightCell().Text(Model.Location.Format(), Typography.Normal);
|
||||
});
|
||||
grid.Columns(6);
|
||||
|
||||
stack.Element().Row(row =>
|
||||
{
|
||||
row.RelativeColumn().DarkCell().Text("Comments", Typography.Normal);
|
||||
row.RelativeColumn(5).LightCell().Text(Model.Comments, Typography.Normal);
|
||||
});
|
||||
grid.Element().LabelCell().Text("Date", Typography.Normal);
|
||||
grid.Element(2).ValueCell().Text(Model.Date?.ToString("g") ?? string.Empty, Typography.Normal);
|
||||
grid.Element().LabelCell().Text("Location", Typography.Normal);
|
||||
grid.Element(2).ValueCell().Text(Model.Location.Format(), Typography.Normal);
|
||||
|
||||
grid.Element().LabelCell().Text("Comments", Typography.Normal);
|
||||
grid.Element(5).ValueCell().Text(Model.Comments, Typography.Normal);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.ReportSample.Layouts
|
||||
@@ -17,31 +16,31 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
public void Compose(IContainer container)
|
||||
{
|
||||
container
|
||||
.MinHeight(100)
|
||||
.Section(section =>
|
||||
.EnsureSpace()
|
||||
.Decoration(section =>
|
||||
{
|
||||
section
|
||||
.Header()
|
||||
.PaddingBottom(5)
|
||||
.Text(Model.Title, Typography.Headline);
|
||||
|
||||
section.Content().PageableStack(stack =>
|
||||
section.Content().Border(0.75f).BorderColor(Colors.Grey.Medium).Stack(stack =>
|
||||
{
|
||||
foreach (var part in Model.Parts)
|
||||
{
|
||||
stack.Element().Row(row =>
|
||||
stack.Item().Row(row =>
|
||||
{
|
||||
row.ConstantColumn(150).DarkCell().Text(part.Label, Typography.Normal);
|
||||
var frame = row.RelativeColumn().LightCell();
|
||||
row.ConstantColumn(150).LabelCell().Text(part.Label, Typography.Normal);
|
||||
var frame = row.RelativeColumn().ValueCell();
|
||||
|
||||
if (part is ReportSectionText text)
|
||||
frame.Text(text.Text, Typography.Normal);
|
||||
|
||||
if (part is ReportSectionMap map)
|
||||
frame.Element(container => MapElement(container, map));
|
||||
frame.Element(x => MapElement(x, map));
|
||||
|
||||
if (part is ReportSectionPhotos photos)
|
||||
frame.Element(container => PhotosElement(container, photos));
|
||||
frame.Element(x => PhotosElement(x, photos));
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -56,12 +55,12 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
return;
|
||||
}
|
||||
|
||||
container.Stack(stack =>
|
||||
container.ShowEntire().Stack(stack =>
|
||||
{
|
||||
stack.Spacing(5);
|
||||
|
||||
stack.Element().Component(new ImageTemplate(model.ImageSource));
|
||||
stack.Element().Text(model.Location.Format(), Typography.Normal);
|
||||
stack.Item().MaxWidth(250).AspectRatio(4 / 3f).Image(Placeholders.Image);
|
||||
stack.Item().Text(model.Location.Format(), Typography.Normal);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,21 +72,12 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
return;
|
||||
}
|
||||
|
||||
var rowCount = (int) Math.Ceiling(model.Photos.Count / 3f);
|
||||
|
||||
container.Padding(-2).Stack(stack =>
|
||||
container.Debug("Photo gallery").Grid(grid =>
|
||||
{
|
||||
foreach (var rowId in Enumerable.Range(0, rowCount))
|
||||
{
|
||||
stack.Element().Row(row =>
|
||||
{
|
||||
foreach (var id in Enumerable.Range(0, 3))
|
||||
{
|
||||
var data = model.Photos.ElementAtOrDefault(rowId + id);
|
||||
row.RelativeColumn().Padding(2).Component(new ImageTemplate(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
grid.Spacing(5);
|
||||
grid.Columns(3);
|
||||
|
||||
model.Photos.ForEach(x => grid.Element().AspectRatio(4 / 3f).Image(Placeholders.Image));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
container
|
||||
.PaddingVertical(40)
|
||||
.PaddingHorizontal(50)
|
||||
|
||||
.Page(page =>
|
||||
{
|
||||
page.Header(ComposeHeader);
|
||||
@@ -39,58 +38,51 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
|
||||
private void ComposeHeader(IContainer container)
|
||||
{
|
||||
container.Row(row =>
|
||||
container.Stack(stack =>
|
||||
{
|
||||
row.RelativeColumn().MaxWidth(300).Stack(stack =>
|
||||
stack.Item().Row(row =>
|
||||
{
|
||||
stack.Spacing(5);
|
||||
row.Spacing(50);
|
||||
|
||||
stack
|
||||
.Element()
|
||||
.PaddingBottom(5)
|
||||
.Text(Model.Title, Typography.Title);
|
||||
|
||||
stack.Element().ShowOnce().Stack(table =>
|
||||
{
|
||||
table.Spacing(5);
|
||||
|
||||
foreach (var field in Model.HeaderFields)
|
||||
{
|
||||
table.Element().Row(row =>
|
||||
{
|
||||
row.ConstantColumn(50)
|
||||
.AlignLeft()
|
||||
.Text($"{field.Label}:", Typography.Normal);
|
||||
|
||||
row.RelativeColumn()
|
||||
.PaddingLeft(10)
|
||||
.Text(field.Value, Typography.Normal);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
row.RelativeColumn().PaddingTop(-10).Text(Model.Title, Typography.Title);
|
||||
row.ConstantColumn(150).ExternalLink("https://www.questpdf.com").Image(Model.LogoData);
|
||||
});
|
||||
|
||||
stack.Item().ShowOnce().PaddingVertical(15).Border(1f).BorderColor(Colors.Grey.Lighten1).ExtendHorizontal();
|
||||
|
||||
row.ConstantColumn(150).ExternalLink("https://www.questpdf.com").Image(Model.LogoData);
|
||||
stack.Item().ShowOnce().Grid(grid =>
|
||||
{
|
||||
grid.Columns(2);
|
||||
grid.Spacing(5);
|
||||
|
||||
foreach (var field in Model.HeaderFields)
|
||||
{
|
||||
grid.Element().Stack(row =>
|
||||
{
|
||||
row.Item().AlignLeft().Text(field.Label, Typography.Normal.SemiBold());
|
||||
row.Item().Text(field.Value, Typography.Normal);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void ComposeContent(IContainer container)
|
||||
{
|
||||
container.PaddingVertical(20).PageableStack(stack =>
|
||||
container.PaddingVertical(20).Stack(stack =>
|
||||
{
|
||||
stack.Spacing(20);
|
||||
|
||||
stack.Element().Component(new TableOfContentsTemplate(Model.Sections));
|
||||
stack.Item().Component(new TableOfContentsTemplate(Model.Sections));
|
||||
|
||||
foreach (var section in Model.Sections)
|
||||
stack.Element().Location(section.Title).Component(new SectionTemplate(section));
|
||||
stack.Item().Location(section.Title).Component(new SectionTemplate(section));
|
||||
|
||||
stack.Element().PageBreak();
|
||||
stack.Element().Location("Photos");
|
||||
stack.Item().PageBreak();
|
||||
stack.Item().Location("Photos");
|
||||
|
||||
foreach (var photo in Model.Photos)
|
||||
stack.Element().Component(new PhotoTemplate(photo));
|
||||
stack.Item().Component(new PhotoTemplate(photo));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
@@ -18,21 +16,21 @@ namespace QuestPDF.ReportSample.Layouts
|
||||
public void Compose(IContainer container)
|
||||
{
|
||||
container
|
||||
.Section(section =>
|
||||
.Decoration(section =>
|
||||
{
|
||||
section
|
||||
.Header()
|
||||
.PaddingBottom(5)
|
||||
.Text("Table of contents", Typography.Headline);
|
||||
|
||||
section.Content().PageableStack(stack =>
|
||||
section.Content().Stack(stack =>
|
||||
{
|
||||
stack.Spacing(5);
|
||||
|
||||
for (var i = 0; i < Sections.Count; i++)
|
||||
stack.Element(c => DrawLink(c, i+1, Sections[i].Title));
|
||||
stack.Item(c => DrawLink(c, i+1, Sections[i].Title));
|
||||
|
||||
stack.Element(c => DrawLink(c, Sections.Count+1, "Photos"));
|
||||
stack.Item(c => DrawLink(c, Sections.Count+1, "Photos"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\Photos\readme.txt" />
|
||||
<Content Include="Resources\**\**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -29,4 +24,8 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\QuestPDF\QuestPDF.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Logo.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
|
Before Width: | Height: | Size: 993 B After Width: | Height: | Size: 993 B |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 16 KiB |