diff --git a/QuestPDF.Examples/ElementExamples.cs b/QuestPDF.Examples/ElementExamples.cs index b7ca1ce..8910081 100644 --- a/QuestPDF.Examples/ElementExamples.cs +++ b/QuestPDF.Examples/ElementExamples.cs @@ -134,5 +134,37 @@ namespace QuestPDF.Examples .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); + }); + } } } \ No newline at end of file diff --git a/QuestPDF.Examples/Engine/ExampleTestBase.cs b/QuestPDF.Examples/Engine/ExampleTestBase.cs index 5914953..37cecb1 100644 --- a/QuestPDF.Examples/Engine/ExampleTestBase.cs +++ b/QuestPDF.Examples/Engine/ExampleTestBase.cs @@ -62,10 +62,17 @@ namespace QuestPDF.Examples.Engine methodInfo.Invoke(this, new object[] {container}); Func 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)); } diff --git a/QuestPDF.Examples/Engine/SimpleDocument.cs b/QuestPDF.Examples/Engine/SimpleDocument.cs index 9838252..c8fd33c 100644 --- a/QuestPDF.Examples/Engine/SimpleDocument.cs +++ b/QuestPDF.Examples/Engine/SimpleDocument.cs @@ -27,7 +27,7 @@ namespace QuestPDF.Examples.Engine public void Compose(IContainer container) { - container.Element(Container.Child); + container.Background("#FFF").Element(Container.Child); } } } \ No newline at end of file diff --git a/QuestPDF/Elements/AspectRatio.cs b/QuestPDF/Elements/AspectRatio.cs index dc86422..b512c75 100644 --- a/QuestPDF/Elements/AspectRatio.cs +++ b/QuestPDF/Elements/AspectRatio.cs @@ -31,11 +31,7 @@ namespace QuestPDF.Elements return; var size = GetTargetSize(availableSpace); - - if (size.Height > availableSpace.Height) - return; - - Child.Draw(canvas, size); + Child?.Draw(canvas, size); } private Size GetTargetSize(Size availableSpace) diff --git a/QuestPDF/Elements/Debug.cs b/QuestPDF/Elements/Debug.cs index d84ebe2..cfcaae8 100644 --- a/QuestPDF/Elements/Debug.cs +++ b/QuestPDF/Elements/Debug.cs @@ -15,6 +15,8 @@ namespace QuestPDF.Elements void DrawBoundingBox() { + // TODO: when layer element is done, move this code into fluent API + var container = new Container(); container diff --git a/QuestPDF/Elements/Placeholder.cs b/QuestPDF/Elements/Placeholder.cs index 45b7572..64476a8 100644 --- a/QuestPDF/Elements/Placeholder.cs +++ b/QuestPDF/Elements/Placeholder.cs @@ -14,12 +14,14 @@ namespace QuestPDF.Elements public void Compose(IContainer container) { + // TODO: consider moving this element into fluent API + container .Background("CCC") .AlignMiddle() .AlignCenter() .MaxHeight(32) - .Image(ImageData); + .Image(ImageData, ImageScaling.FitArea); } } } \ No newline at end of file diff --git a/QuestPDF/Elements/RowElement.cs b/QuestPDF/Elements/RowElement.cs index 75069aa..b0d883e 100644 --- a/QuestPDF/Elements/RowElement.cs +++ b/QuestPDF/Elements/RowElement.cs @@ -8,10 +8,7 @@ namespace QuestPDF.Elements internal override void Draw(ICanvas canvas, Size availableSpace) { - if (Child == null) - return; - - Child.Draw(canvas, availableSpace); + Child?.Draw(canvas, availableSpace); } }