Parcourir la source

Previewer fix: clip canvas when drawing page snapshot

Marcin Ziąbek il y a 2 ans
Parent
commit
5ee71152c6

+ 9 - 1
Source/QuestPDF.Previewer/InteractiveCanvas.cs

@@ -133,13 +133,21 @@ class InteractiveCanvas : ICustomDrawOperation
         {
         {
             canvas.Translate(-page.Width / 2f, 0);
             canvas.Translate(-page.Width / 2f, 0);
             DrawBlankPage(canvas, page.Width, page.Height);
             DrawBlankPage(canvas, page.Width, page.Height);
-            canvas.DrawPicture(page.Picture);
+            DrawPageSnapshot(canvas, page);
             canvas.Translate(page.Width / 2f, page.Height + PageSpacing);
             canvas.Translate(page.Width / 2f, page.Height + PageSpacing);
         }
         }
 
 
         canvas.SetMatrix(originalMatrix);
         canvas.SetMatrix(originalMatrix);
         DrawInnerGradient(canvas);
         DrawInnerGradient(canvas);
     }
     }
+
+    private static void DrawPageSnapshot(SKCanvas canvas, DocumentSnapshot.PageSnapshot pageSnapshot)
+    {
+        canvas.Save();
+        canvas.ClipRect(new SKRect(0, 0, pageSnapshot.Width, pageSnapshot.Height));
+        canvas.DrawPicture(pageSnapshot.Picture);
+        canvas.Restore();
+    }
     
     
     public void Dispose() { }
     public void Dispose() { }
     public bool Equals(ICustomDrawOperation? other) => false;
     public bool Equals(ICustomDrawOperation? other) => false;

+ 2 - 2
Source/QuestPDF/Previewer/ExceptionDocument.cs

@@ -34,7 +34,7 @@ namespace QuestPDF.Previewer
                 page.Margin(50);
                 page.Margin(50);
                 page.DefaultTextStyle(x => x.FontSize(16));
                 page.DefaultTextStyle(x => x.FontSize(16));
 
 
-                page.Foreground().PaddingTop(5).Border(10).BorderColor(Colors.Red.Medium);
+                page.Foreground().Border(12).BorderColor(Colors.Red.Medium);
                 
                 
                 page.Header()
                 page.Header()
                     .ShowOnce()
                     .ShowOnce()
@@ -66,7 +66,7 @@ namespace QuestPDF.Previewer
                             .Column(column =>
                             .Column(column =>
                             {
                             {
                                 column.Item().Text("Exception").FontSize(36).FontColor(Colors.Red.Medium).Bold();
                                 column.Item().Text("Exception").FontSize(36).FontColor(Colors.Red.Medium).Bold();
-                                column.Item().PaddingTop(-10).Text("Please refer to the details for further insight and troubleshooting.").FontSize(18).FontColor(Colors.Red.Medium).Bold();
+                                column.Item().PaddingTop(-5).Text("Please refer to the details for further insight and troubleshooting.").FontSize(18).FontColor(Colors.Red.Medium).Bold();
                             }); 
                             }); 
                     });
                     });