Browse Source

Fix: Change default BackgroundColor to transparent and add white background for JPEG images

Marcin Ziąbek 7 months ago
parent
commit
88a262783b

+ 3 - 0
Source/QuestPDF/Drawing/DocumentCanvases/ImageDocumentCanvas.cs

@@ -64,6 +64,9 @@ namespace QuestPDF.Drawing.DocumentCanvases
             
             
             CurrentPageCanvas.Scale(scalingFactor, scalingFactor);
             CurrentPageCanvas.Scale(scalingFactor, scalingFactor);
             
             
+            if (Settings.ImageFormat == ImageFormat.Jpeg)
+                CurrentPageCanvas.DrawFilledRectangle(new SkRect(0, 0, size.Width, size.Height), Colors.White);
+            
             DrawingCanvas.Target = new SkiaDrawingCanvas(size.Width, size.Height);
             DrawingCanvas.Target = new SkiaDrawingCanvas(size.Width, size.Height);
             DrawingCanvas.SetZIndex(0);
             DrawingCanvas.SetZIndex(0);
         }
         }

+ 1 - 1
Source/QuestPDF/Elements/Page.cs

@@ -18,7 +18,7 @@ namespace QuestPDF.Elements
         public float MarginTop { get; set; }
         public float MarginTop { get; set; }
         public float MarginBottom { get; set; }
         public float MarginBottom { get; set; }
 
 
-        public Color BackgroundColor { get; set; } = Colors.White;
+        public Color BackgroundColor { get; set; } = Colors.Transparent;
         
         
         public Element Background { get; set; } = Empty.Instance;
         public Element Background { get; set; } = Empty.Instance;
         public Element Foreground { get; set; } = Empty.Instance;
         public Element Foreground { get; set; } = Empty.Instance;