From 68df390d0e9ec51d2e06b64bf87a8f1e5df5d304 Mon Sep 17 00:00:00 2001 From: MarcinZiabek Date: Mon, 21 Feb 2022 00:57:53 +0100 Subject: [PATCH] Element renaming + custom text format --- QuestPDF.ReportSample/Helpers.cs | 28 ++++++++ .../Layouts/StandardReport.cs | 4 +- .../Layouts/TableOfContentsTemplate.cs | 6 +- QuestPDF.UnitTests/ExternalLinkTests.cs | 2 +- QuestPDF.UnitTests/InternalLinkTests.cs | 2 +- QuestPDF.UnitTests/InternalLocationTests.cs | 2 +- QuestPDF.UnitTests/TestEngine/MockCanvas.cs | 8 +-- .../TestEngine/OperationRecordingCanvas.cs | 6 +- QuestPDF/Drawing/FreeCanvas.cs | 6 +- QuestPDF/Drawing/SkiaCanvasBase.cs | 10 +-- .../{ExternalLink.cs => Hyperlink.cs} | 4 +- .../{InternalLocation.cs => Section.cs} | 6 +- .../{InternalLink.cs => SectionLink.cs} | 6 +- ...kExternalLink.cs => TextBlockHyperlink.cs} | 4 +- ...ternalLink.cs => TextBlockSectionlLink.cs} | 6 +- QuestPDF/Fluent/ElementExtensions.cs | 30 ++++++-- QuestPDF/Fluent/TextExtensions.cs | 72 ++++++++++--------- QuestPDF/Infrastructure/ICanvas.cs | 6 +- QuestPDF/Infrastructure/IPageContext.cs | 2 +- QuestPDF/Infrastructure/PageContext.cs | 4 +- 20 files changed, 133 insertions(+), 81 deletions(-) rename QuestPDF/Elements/{ExternalLink.cs => Hyperlink.cs} (80%) rename QuestPDF/Elements/{InternalLocation.cs => Section.cs} (73%) rename QuestPDF/Elements/{InternalLink.cs => SectionLink.cs} (69%) rename QuestPDF/Elements/Text/Items/{TextBlockExternalLink.cs => TextBlockHyperlink.cs} (78%) rename QuestPDF/Elements/Text/Items/{TextBlockInternalLink.cs => TextBlockSectionlLink.cs} (72%) diff --git a/QuestPDF.ReportSample/Helpers.cs b/QuestPDF.ReportSample/Helpers.cs index cb9af62..572284f 100644 --- a/QuestPDF.ReportSample/Helpers.cs +++ b/QuestPDF.ReportSample/Helpers.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.IO; using SkiaSharp; @@ -24,5 +25,32 @@ namespace QuestPDF.ReportSample Latitude = Helpers.Random.NextDouble() * 180f - 90f }; } + + private static readonly ConcurrentDictionary RomanNumeralCache = new ConcurrentDictionary(); + + public static string FormatAsRomanNumeral(this int number) + { + if (number < 0 || number > 3999) + throw new ArgumentOutOfRangeException("Number should be in range from 1 to 3999"); + + return RomanNumeralCache.GetOrAdd(number, x => + { + if (x >= 1000) return "M" + FormatAsRomanNumeral(x - 1000); + if (x >= 900) return "CM" + FormatAsRomanNumeral(x - 900); + if (x >= 500) return "D" + FormatAsRomanNumeral(x - 500); + if (x >= 400) return "CD" + FormatAsRomanNumeral(x - 400); + if (x >= 100) return "C" + FormatAsRomanNumeral(x - 100); + if (x >= 90) return "XC" + FormatAsRomanNumeral(x - 90); + if (x >= 50) return "L" + FormatAsRomanNumeral(x - 50); + if (x >= 40) return "XL" + FormatAsRomanNumeral(x - 40); + if (x >= 10) return "X" + FormatAsRomanNumeral(x - 10); + if (x >= 9) return "IX" + FormatAsRomanNumeral(x - 9); + if (x >= 5) return "V" + FormatAsRomanNumeral(x - 5); + if (x >= 4) return "IV" + FormatAsRomanNumeral(x - 4); + if (x >= 1) return "I" + FormatAsRomanNumeral(x - 1); + + return string.Empty; + }); + } } } \ No newline at end of file diff --git a/QuestPDF.ReportSample/Layouts/StandardReport.cs b/QuestPDF.ReportSample/Layouts/StandardReport.cs index 2bba69a..143d5c9 100644 --- a/QuestPDF.ReportSample/Layouts/StandardReport.cs +++ b/QuestPDF.ReportSample/Layouts/StandardReport.cs @@ -39,9 +39,9 @@ namespace QuestPDF.ReportSample.Layouts page.Footer().AlignCenter().Text(text => { - text.CurrentPageNumber(); + text.CurrentPageNumber(format: x => x?.FormatAsRomanNumeral() ?? "-----"); text.Span(" / "); - text.TotalPages(); + text.TotalPages(format: x => x?.FormatAsRomanNumeral() ?? "-----"); }); }); } diff --git a/QuestPDF.ReportSample/Layouts/TableOfContentsTemplate.cs b/QuestPDF.ReportSample/Layouts/TableOfContentsTemplate.cs index 16444c0..62c02e3 100644 --- a/QuestPDF.ReportSample/Layouts/TableOfContentsTemplate.cs +++ b/QuestPDF.ReportSample/Layouts/TableOfContentsTemplate.cs @@ -47,14 +47,14 @@ namespace QuestPDF.ReportSample.Layouts row.RelativeItem().Text(locationName); row.ConstantItem(150).AlignRight().Text(text => { - text.BeginPageNumberOfLocation(locationName); + text.BeginPageNumberOfSection(locationName); text.Span(" - "); - text.EndPageNumberOfLocation(locationName); + text.EndPageNumberOfSection(locationName); var lengthStyle = TextStyle.Default.Color(Colors.Grey.Medium); text.Span(" (", lengthStyle); - text.PageLengthOfLocation(locationName, x => x == 1 ? "1 page long" : $"{x} pages long", lengthStyle); + text.TotalPagesWithinSection(locationName, lengthStyle, x => x == 1 ? "1 page long" : $"{x} pages long"); text.Span(")", lengthStyle); }); }); diff --git a/QuestPDF.UnitTests/ExternalLinkTests.cs b/QuestPDF.UnitTests/ExternalLinkTests.cs index cd6853d..5461cf2 100644 --- a/QuestPDF.UnitTests/ExternalLinkTests.cs +++ b/QuestPDF.UnitTests/ExternalLinkTests.cs @@ -8,7 +8,7 @@ namespace QuestPDF.UnitTests public class ExternalLinkTests { [Test] - public void Measure() => SimpleContainerTests.Measure(); + public void Measure() => SimpleContainerTests.Measure(); // TODO: consider tests for the Draw method } diff --git a/QuestPDF.UnitTests/InternalLinkTests.cs b/QuestPDF.UnitTests/InternalLinkTests.cs index bd52d1c..1ad9432 100644 --- a/QuestPDF.UnitTests/InternalLinkTests.cs +++ b/QuestPDF.UnitTests/InternalLinkTests.cs @@ -8,7 +8,7 @@ namespace QuestPDF.UnitTests public class InternalLinkTests { [Test] - public void Measure() => SimpleContainerTests.Measure(); + public void Measure() => SimpleContainerTests.Measure(); // TODO: consider tests for the Draw method } diff --git a/QuestPDF.UnitTests/InternalLocationTests.cs b/QuestPDF.UnitTests/InternalLocationTests.cs index 8a21fcb..5966c36 100644 --- a/QuestPDF.UnitTests/InternalLocationTests.cs +++ b/QuestPDF.UnitTests/InternalLocationTests.cs @@ -8,7 +8,7 @@ namespace QuestPDF.UnitTests public class InternalLocationTests { [Test] - public void Measure() => SimpleContainerTests.Measure(); + public void Measure() => SimpleContainerTests.Measure(); // TODO: consider tests for the Draw method } diff --git a/QuestPDF.UnitTests/TestEngine/MockCanvas.cs b/QuestPDF.UnitTests/TestEngine/MockCanvas.cs index fbed591..6e4926e 100644 --- a/QuestPDF.UnitTests/TestEngine/MockCanvas.cs +++ b/QuestPDF.UnitTests/TestEngine/MockCanvas.cs @@ -20,9 +20,9 @@ namespace QuestPDF.UnitTests.TestEngine public void DrawRectangle(Position vector, Size size, string color) => DrawRectFunc(vector, size, color); public void DrawText(string text, Position position, TextStyle style) => DrawTextFunc(text, position, style); public void DrawImage(SKImage image, Position position, Size size) => DrawImageFunc(image, position, size); - - public void DrawExternalLink(string url, Size size) => throw new NotImplementedException(); - public void DrawLocationLink(string locationName, Size size) => throw new NotImplementedException(); - public void DrawLocation(string locationName) => throw new NotImplementedException(); + + public void DrawHyperlink(string url, Size size) => throw new NotImplementedException(); + public void DrawSectionLink(string sectionName, Size size) => throw new NotImplementedException(); + public void DrawSection(string sectionName) => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/QuestPDF.UnitTests/TestEngine/OperationRecordingCanvas.cs b/QuestPDF.UnitTests/TestEngine/OperationRecordingCanvas.cs index 3617052..4fbedfe 100644 --- a/QuestPDF.UnitTests/TestEngine/OperationRecordingCanvas.cs +++ b/QuestPDF.UnitTests/TestEngine/OperationRecordingCanvas.cs @@ -18,8 +18,8 @@ namespace QuestPDF.UnitTests.TestEngine public void DrawText(string text, Position position, TextStyle style) => Operations.Add(new CanvasDrawTextOperation(text, position, style)); public void DrawImage(SKImage image, Position position, Size size) => Operations.Add(new CanvasDrawImageOperation(position, size)); - public void DrawExternalLink(string url, Size size) => throw new NotImplementedException(); - public void DrawLocationLink(string locationName, Size size) => throw new NotImplementedException(); - public void DrawLocation(string locationName) => throw new NotImplementedException(); + public void DrawHyperlink(string url, Size size) => throw new NotImplementedException(); + public void DrawSectionLink(string sectionName, Size size) => throw new NotImplementedException(); + public void DrawSection(string sectionName) => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/QuestPDF/Drawing/FreeCanvas.cs b/QuestPDF/Drawing/FreeCanvas.cs index 6716e9e..251c9d1 100644 --- a/QuestPDF/Drawing/FreeCanvas.cs +++ b/QuestPDF/Drawing/FreeCanvas.cs @@ -51,17 +51,17 @@ namespace QuestPDF.Drawing } - public void DrawExternalLink(string url, Size size) + public void DrawHyperlink(string url, Size size) { } - public void DrawLocationLink(string locationName, Size size) + public void DrawSectionLink(string sectionName, Size size) { } - public void DrawLocation(string locationName) + public void DrawSection(string sectionName) { } diff --git a/QuestPDF/Drawing/SkiaCanvasBase.cs b/QuestPDF/Drawing/SkiaCanvasBase.cs index 9ec37a8..aaf8e25 100644 --- a/QuestPDF/Drawing/SkiaCanvasBase.cs +++ b/QuestPDF/Drawing/SkiaCanvasBase.cs @@ -37,19 +37,19 @@ namespace QuestPDF.Drawing Canvas.DrawImage(image, new SKRect(vector.X, vector.Y, size.Width, size.Height)); } - public void DrawExternalLink(string url, Size size) + public void DrawHyperlink(string url, Size size) { Canvas.DrawUrlAnnotation(new SKRect(0, 0, size.Width, size.Height), url); } - public void DrawLocationLink(string locationName, Size size) + public void DrawSectionLink(string sectionName, Size size) { - Canvas.DrawLinkDestinationAnnotation(new SKRect(0, 0, size.Width, size.Height), locationName); + Canvas.DrawLinkDestinationAnnotation(new SKRect(0, 0, size.Width, size.Height), sectionName); } - public void DrawLocation(string locationName) + public void DrawSection(string sectionName) { - Canvas.DrawNamedDestinationAnnotation(new SKPoint(0, 0), locationName); + Canvas.DrawNamedDestinationAnnotation(new SKPoint(0, 0), sectionName); } public void Rotate(float angle) diff --git a/QuestPDF/Elements/ExternalLink.cs b/QuestPDF/Elements/Hyperlink.cs similarity index 80% rename from QuestPDF/Elements/ExternalLink.cs rename to QuestPDF/Elements/Hyperlink.cs index 67c2d84..73e9bce 100644 --- a/QuestPDF/Elements/ExternalLink.cs +++ b/QuestPDF/Elements/Hyperlink.cs @@ -3,7 +3,7 @@ using QuestPDF.Infrastructure; namespace QuestPDF.Elements { - internal class ExternalLink : ContainerElement + internal class Hyperlink : ContainerElement { public string Url { get; set; } = "https://www.questpdf.com"; @@ -14,7 +14,7 @@ namespace QuestPDF.Elements if (targetSize.Type == SpacePlanType.Wrap) return; - Canvas.DrawExternalLink(Url, targetSize); + Canvas.DrawHyperlink(Url, targetSize); base.Draw(availableSpace); } } diff --git a/QuestPDF/Elements/InternalLocation.cs b/QuestPDF/Elements/Section.cs similarity index 73% rename from QuestPDF/Elements/InternalLocation.cs rename to QuestPDF/Elements/Section.cs index ec21260..46fe3c0 100644 --- a/QuestPDF/Elements/InternalLocation.cs +++ b/QuestPDF/Elements/Section.cs @@ -2,7 +2,7 @@ namespace QuestPDF.Elements { - internal class InternalLocation : ContainerElement, IStateResettable + internal class Section : ContainerElement, IStateResettable { public string LocationName { get; set; } private bool IsRendered { get; set; } @@ -16,11 +16,11 @@ namespace QuestPDF.Elements { if (!IsRendered) { - Canvas.DrawLocation(LocationName); + Canvas.DrawSection(LocationName); IsRendered = true; } - PageContext.SetLocationPage(LocationName); + PageContext.SetSectionPage(LocationName); base.Draw(availableSpace); } } diff --git a/QuestPDF/Elements/InternalLink.cs b/QuestPDF/Elements/SectionLink.cs similarity index 69% rename from QuestPDF/Elements/InternalLink.cs rename to QuestPDF/Elements/SectionLink.cs index c6e2aba..f19713a 100644 --- a/QuestPDF/Elements/InternalLink.cs +++ b/QuestPDF/Elements/SectionLink.cs @@ -3,9 +3,9 @@ using QuestPDF.Infrastructure; namespace QuestPDF.Elements { - internal class InternalLink : ContainerElement + internal class SectionLink : ContainerElement { - public string LocationName { get; set; } + public string SectionName { get; set; } internal override void Draw(Size availableSpace) { @@ -14,7 +14,7 @@ namespace QuestPDF.Elements if (targetSize.Type == SpacePlanType.Wrap) return; - Canvas.DrawLocationLink(LocationName, targetSize); + Canvas.DrawSectionLink(SectionName, targetSize); base.Draw(availableSpace); } } diff --git a/QuestPDF/Elements/Text/Items/TextBlockExternalLink.cs b/QuestPDF/Elements/Text/Items/TextBlockHyperlink.cs similarity index 78% rename from QuestPDF/Elements/Text/Items/TextBlockExternalLink.cs rename to QuestPDF/Elements/Text/Items/TextBlockHyperlink.cs index 5337fca..bd8228b 100644 --- a/QuestPDF/Elements/Text/Items/TextBlockExternalLink.cs +++ b/QuestPDF/Elements/Text/Items/TextBlockHyperlink.cs @@ -3,7 +3,7 @@ using QuestPDF.Infrastructure; namespace QuestPDF.Elements.Text.Items { - internal class TextBlockExternalLink : TextBlockSpan + internal class TextBlockHyperlink : TextBlockSpan { public string Url { get; set; } @@ -15,7 +15,7 @@ namespace QuestPDF.Elements.Text.Items public override void Draw(TextDrawingRequest request) { request.Canvas.Translate(new Position(0, request.TotalAscent)); - request.Canvas.DrawExternalLink(Url, new Size(request.TextSize.Width, request.TextSize.Height)); + request.Canvas.DrawHyperlink(Url, new Size(request.TextSize.Width, request.TextSize.Height)); request.Canvas.Translate(new Position(0, -request.TotalAscent)); base.Draw(request); diff --git a/QuestPDF/Elements/Text/Items/TextBlockInternalLink.cs b/QuestPDF/Elements/Text/Items/TextBlockSectionlLink.cs similarity index 72% rename from QuestPDF/Elements/Text/Items/TextBlockInternalLink.cs rename to QuestPDF/Elements/Text/Items/TextBlockSectionlLink.cs index 6b28113..5c41ca0 100644 --- a/QuestPDF/Elements/Text/Items/TextBlockInternalLink.cs +++ b/QuestPDF/Elements/Text/Items/TextBlockSectionlLink.cs @@ -3,9 +3,9 @@ using QuestPDF.Infrastructure; namespace QuestPDF.Elements.Text.Items { - internal class TextBlockInternalLink : TextBlockSpan + internal class TextBlockSectionlLink : TextBlockSpan { - public string LocationName { get; set; } + public string SectionName { get; set; } public override TextMeasurementResult? Measure(TextMeasurementRequest request) { @@ -15,7 +15,7 @@ namespace QuestPDF.Elements.Text.Items public override void Draw(TextDrawingRequest request) { request.Canvas.Translate(new Position(0, request.TotalAscent)); - request.Canvas.DrawLocationLink(LocationName, new Size(request.TextSize.Width, request.TextSize.Height)); + request.Canvas.DrawSectionLink(SectionName, new Size(request.TextSize.Width, request.TextSize.Height)); request.Canvas.Translate(new Position(0, -request.TotalAscent)); base.Draw(request); diff --git a/QuestPDF/Fluent/ElementExtensions.cs b/QuestPDF/Fluent/ElementExtensions.cs index d9ce5fb..a85a2e4 100644 --- a/QuestPDF/Fluent/ElementExtensions.cs +++ b/QuestPDF/Fluent/ElementExtensions.cs @@ -60,7 +60,7 @@ namespace QuestPDF.Fluent public static void Placeholder(this IContainer element, string? text = null) { - element.Component(new Elements.Placeholder + element.Component(new Placeholder { Text = text ?? string.Empty }); @@ -99,27 +99,45 @@ namespace QuestPDF.Fluent return element.Element(new Container()); } + [Obsolete("This element has been renamed since version 2022.3. Please use the Hyperlink method.")] public static IContainer ExternalLink(this IContainer element, string url) { - return element.Element(new ExternalLink + return element.Hyperlink(url); + } + + public static IContainer Hyperlink(this IContainer element, string url) + { + return element.Element(new Hyperlink { Url = url }); } + [Obsolete("This element has been renamed since version 2022.3. Please use the Section method.")] public static IContainer Location(this IContainer element, string locationName) { - return element.Element(new InternalLocation + return element.Section(locationName); + } + + public static IContainer Section(this IContainer element, string sectionName) + { + return element.Element(new Section { - LocationName = locationName + LocationName = sectionName }); } + [Obsolete("This element has been renamed since version 2022.3. Please use the SectionLink method.")] public static IContainer InternalLink(this IContainer element, string locationName) { - return element.Element(new InternalLink + return element.SectionLink(locationName); + } + + public static IContainer SectionLink(this IContainer element, string sectionName) + { + return element.Element(new SectionLink { - LocationName = locationName + SectionName = sectionName }); } diff --git a/QuestPDF/Fluent/TextExtensions.cs b/QuestPDF/Fluent/TextExtensions.cs index eb2d680..e069871 100644 --- a/QuestPDF/Fluent/TextExtensions.cs +++ b/QuestPDF/Fluent/TextExtensions.cs @@ -90,81 +90,81 @@ namespace QuestPDF.Fluent Span(Environment.NewLine); } - private void PageNumber(Func source, TextStyle? style = null) + private static Func DefaultTextFormat = x => (x ?? 123).ToString(); + + private void PageNumber(Func pageNumber, TextStyle? style, Func? format) { style ??= TextStyle.Default; + format ??= DefaultTextFormat; AddItemToLastTextBlock(new TextBlockPageNumber() { - Source = source, + Source = context => format(pageNumber(context)), Style = style }); } - - public void CurrentPageNumber(Func format, TextStyle? style = null) + + public void CurrentPageNumber(TextStyle? style = null, Func? format = null) { - PageNumber(context => format(context.CurrentPage), style); + PageNumber(x => x.CurrentPage, style, format); } - public void CurrentPageNumber(TextStyle? style = null) + public void TotalPages(TextStyle? style = null, Func? format = null) { - CurrentPageNumber(x => x.ToString(), style); + PageNumber(x => x.GetLocation(PageContext.DocumentLocation)?.Length, style, format); } - public void TotalPages(Func format, TextStyle? style = null) - { - PageNumber(context => format(context.GetLocation(PageContext.DocumentLocation)?.Length), style); - } - - public void TotalPages(TextStyle? style = null) - { - TotalPages(x => x.ToString(), style); - } - + [Obsolete("This element has been renamed since version 2022.3. Please use the BeginPageNumberOfSection method.")] public void PageNumberOfLocation(string locationName, TextStyle? style = null) { - BeginPageNumberOfLocation(locationName); + BeginPageNumberOfSection(locationName); } - public void BeginPageNumberOfLocation(string locationName, TextStyle? style = null) + public void BeginPageNumberOfSection(string locationName, TextStyle? style = null, Func? format = null) { - PageNumber(context => (context.GetLocation(locationName)?.PageStart ?? 123).ToString(), style); + PageNumber(x => x.GetLocation(locationName)?.PageStart, style, format); } - public void EndPageNumberOfLocation(string locationName, TextStyle? style = null) + public void EndPageNumberOfSection(string locationName, TextStyle? style = null, Func? format = null) { - PageNumber(context => (context.GetLocation(locationName)?.PageEnd ?? 123).ToString(), style); + PageNumber(x => x.GetLocation(locationName)?.PageEnd, style, format); } - public void PageNumberWithinLocation(string locationName, Func format, TextStyle? style = null) + public void PageNumberWithinSection(string locationName, TextStyle? style = null, Func? format = null) { - PageNumber(context => format(context.CurrentPage + 1 - context.GetLocation(locationName)?.PageEnd), style); + PageNumber(x => x.CurrentPage + 1 - x.GetLocation(locationName)?.PageEnd, style, format); } - public void PageLengthOfLocation(string locationName, Func format, TextStyle? style = null) + public void TotalPagesWithinSection(string locationName, TextStyle? style = null, Func? format = null) { - PageNumber(context => format(context.GetLocation(locationName)?.Length), style); + PageNumber(x => x.GetLocation(locationName)?.Length, style, format); } - public void InternalLocation(string? text, string locationName, TextStyle? style = null) + public void SectionLink(string? text, string sectionName, TextStyle? style = null) { if (IsNullOrEmpty(text)) return; - if (IsNullOrEmpty(locationName)) - throw new ArgumentException(nameof(locationName)); + if (IsNullOrEmpty(sectionName)) + throw new ArgumentException(nameof(sectionName)); style ??= TextStyle.Default; - AddItemToLastTextBlock(new TextBlockInternalLink + AddItemToLastTextBlock(new TextBlockSectionlLink { Style = style, Text = text, - LocationName = locationName + SectionName = sectionName }); } - public void ExternalLocation(string? text, string url, TextStyle? style = null) + [Obsolete("This element has been renamed since version 2022.3. Please use the SectionLink method.")] + public void InternalLocation(string? text, string locationName, TextStyle? style = null) + { + SectionLink(text, locationName, style); + } + + public void Hyperlink(string? text, string url, TextStyle? style = null) { if (IsNullOrEmpty(text)) return; @@ -174,7 +174,7 @@ namespace QuestPDF.Fluent style ??= TextStyle.Default; - AddItemToLastTextBlock(new TextBlockExternalLink + AddItemToLastTextBlock(new TextBlockHyperlink { Style = style, Text = text, @@ -182,6 +182,12 @@ namespace QuestPDF.Fluent }); } + [Obsolete("This element has been renamed since version 2022.3. Please use the Hyperlink method.")] + public void ExternalLocation(string? text, string url, TextStyle? style = null) + { + Hyperlink(text, url, style); + } + public IContainer Element() { var container = new Container(); diff --git a/QuestPDF/Infrastructure/ICanvas.cs b/QuestPDF/Infrastructure/ICanvas.cs index e2bb3fb..65b470b 100644 --- a/QuestPDF/Infrastructure/ICanvas.cs +++ b/QuestPDF/Infrastructure/ICanvas.cs @@ -10,9 +10,9 @@ namespace QuestPDF.Infrastructure void DrawText(string text, Position position, TextStyle style); void DrawImage(SKImage image, Position position, Size size); - void DrawExternalLink(string url, Size size); - void DrawLocationLink(string locationName, Size size); - void DrawLocation(string locationName); + void DrawHyperlink(string url, Size size); + void DrawSectionLink(string sectionName, Size size); + void DrawSection(string sectionName); void Rotate(float angle); void Scale(float scaleX, float scaleY); diff --git a/QuestPDF/Infrastructure/IPageContext.cs b/QuestPDF/Infrastructure/IPageContext.cs index b9253bd..73b2c0a 100644 --- a/QuestPDF/Infrastructure/IPageContext.cs +++ b/QuestPDF/Infrastructure/IPageContext.cs @@ -13,7 +13,7 @@ namespace QuestPDF.Infrastructure internal interface IPageContext { int CurrentPage { get; } - void SetLocationPage(string name); + void SetSectionPage(string name); DocumentLocation? GetLocation(string name); } } \ No newline at end of file diff --git a/QuestPDF/Infrastructure/PageContext.cs b/QuestPDF/Infrastructure/PageContext.cs index 1497a3c..385dcfb 100644 --- a/QuestPDF/Infrastructure/PageContext.cs +++ b/QuestPDF/Infrastructure/PageContext.cs @@ -14,10 +14,10 @@ namespace QuestPDF.Infrastructure internal void SetPageNumber(int number) { CurrentPage = number; - SetLocationPage(DocumentLocation); + SetSectionPage(DocumentLocation); } - public void SetLocationPage(string name) + public void SetSectionPage(string name) { var location = GetLocation(name);