|
|
@@ -1,6 +1,6 @@
|
|
|
+using QuestPDF.Helpers;
|
|
|
using QuestPDF.Infrastructure;
|
|
|
using SkiaSharp;
|
|
|
-using SkiaSharp.HarfBuzz;
|
|
|
|
|
|
namespace QuestPDF.Drawing
|
|
|
{
|
|
|
@@ -8,13 +8,55 @@ namespace QuestPDF.Drawing
|
|
|
{
|
|
|
internal SKCanvas Canvas { get; set; }
|
|
|
|
|
|
+ #region IRenderingCanvas
|
|
|
+
|
|
|
public bool DocumentContentHasLayoutOverflowIssues { get; set; }
|
|
|
|
|
|
+ private Size CurrentPageSize { get; set; } = Size.Zero;
|
|
|
+ private bool CurrentPageHasLayoutIssues { get; set; }
|
|
|
+
|
|
|
public abstract void BeginDocument();
|
|
|
public abstract void EndDocument();
|
|
|
+
|
|
|
+ public virtual void BeginPage(Size size)
|
|
|
+ {
|
|
|
+ CurrentPageSize = size;
|
|
|
+ CurrentPageHasLayoutIssues = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public virtual void EndPage()
|
|
|
+ {
|
|
|
+ if (CurrentPageHasLayoutIssues)
|
|
|
+ DrawLayoutIssuesIndicatorOnCurrentPage();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void MarkCurrentPageAsHavingLayoutIssues()
|
|
|
+ {
|
|
|
+ CurrentPageHasLayoutIssues = true;
|
|
|
+ DocumentContentHasLayoutOverflowIssues = true;
|
|
|
+ }
|
|
|
|
|
|
- public abstract void BeginPage(Size size);
|
|
|
- public abstract void EndPage();
|
|
|
+ private void DrawLayoutIssuesIndicatorOnCurrentPage()
|
|
|
+ {
|
|
|
+ // visual configuration
|
|
|
+ const string lineColor = Colors.Red.Medium;
|
|
|
+ const byte lineOpacity = 64;
|
|
|
+ const float borderThickness = 24f;
|
|
|
+
|
|
|
+ // implementation
|
|
|
+ using var indicatorPaint = new SKPaint
|
|
|
+ {
|
|
|
+ StrokeWidth = borderThickness * 2, // half of the width will be outside of the page area
|
|
|
+ Color = SKColor.Parse(lineColor).WithAlpha(lineOpacity),
|
|
|
+ IsStroke = true
|
|
|
+ };
|
|
|
+
|
|
|
+ Canvas.DrawRect(0, 0, CurrentPageSize.Width, CurrentPageSize.Height, indicatorPaint);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region ICanvas
|
|
|
|
|
|
public void Translate(Position vector)
|
|
|
{
|
|
|
@@ -64,5 +106,7 @@ namespace QuestPDF.Drawing
|
|
|
{
|
|
|
Canvas.Scale(scaleX, scaleY);
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|