From 22a696fab9421dc79190922417e8f76153b2351f Mon Sep 17 00:00:00 2001 From: MarcinZiabek Date: Mon, 17 Apr 2023 00:01:32 +0200 Subject: [PATCH] Fix(#470): the inlined element is shown only once in the header but should be repeated on each page --- Source/QuestPDF.Examples/InlinedExamples.cs | 37 +++++++++++++++++++++ Source/QuestPDF/Elements/Inlined.cs | 3 ++ 2 files changed, 40 insertions(+) diff --git a/Source/QuestPDF.Examples/InlinedExamples.cs b/Source/QuestPDF.Examples/InlinedExamples.cs index 8f4adda..8bdda8e 100644 --- a/Source/QuestPDF.Examples/InlinedExamples.cs +++ b/Source/QuestPDF.Examples/InlinedExamples.cs @@ -120,5 +120,42 @@ namespace QuestPDF.Examples .Background(Placeholders.BackgroundColor()); } } + + [Test] + public void RepeatingInlinedInHeader_Test() + { + RenderingTest + .Create() + .ProduceImages() + .ShowResults() + .RenderDocument(document => + { + document.Page(page => + { + page.Size(PageSizes.A4); + page.Margin(1, Unit.Inch); + page.PageColor(Colors.White); + + page.Header() + .Inlined(inlined => + { + inlined.Spacing(10); + + foreach (var i in Enumerable.Range(5, 5)) + inlined.Item().Width(i * 10).Height(20).Background(Colors.Red.Medium); + }); + + page.Content() + .PaddingVertical(20) + .Column(column => + { + column.Spacing(25); + + foreach (var i in Enumerable.Range(10, 20)) + column.Item().Width(i * 10).Height(50).Background(Colors.Grey.Lighten2); + }); + }); + }); + } } } \ No newline at end of file diff --git a/Source/QuestPDF/Elements/Inlined.cs b/Source/QuestPDF/Elements/Inlined.cs index dabab48..b32a4a4 100644 --- a/Source/QuestPDF/Elements/Inlined.cs +++ b/Source/QuestPDF/Elements/Inlined.cs @@ -102,6 +102,9 @@ namespace QuestPDF.Elements Canvas.Translate(new Position(0, -topOffset)); lines.SelectMany(x => x).ToList().ForEach(x => ChildrenQueue.Dequeue()); + + if (!ChildrenQueue.Any()) + ResetState(); void DrawLine(ICollection lineMeasurements) {