From 4c47e4e65af065cef56fee0c26e59ec336a6b39b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 30 Oct 2025 19:21:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20PaperFormat=20?= =?UTF-8?q?=E7=AD=89=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/DefaultPdfService.cs | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.Html2Pdf/Services/DefaultPdfService.cs b/src/components/BootstrapBlazor.Html2Pdf/Services/DefaultPdfService.cs index cf60fc51..8eefa50b 100644 --- a/src/components/BootstrapBlazor.Html2Pdf/Services/DefaultPdfService.cs +++ b/src/components/BootstrapBlazor.Html2Pdf/Services/DefaultPdfService.cs @@ -97,10 +97,75 @@ private static PuppeteerSharp.PdfOptions GetOptions(PdfOptions? options) { return options == null ? new PuppeteerSharp.PdfOptions() : new PuppeteerSharp.PdfOptions { - Landscape = options.Landscape + Landscape = options.Landscape, + PrintBackground = options.PrintBackground, + Format = GetFormat(options.Format), + MarginOptions = GetMarginOptions(options.MarginOptions), + DisplayHeaderFooter = options.DisplayHeaderFooter, + Scale = options.Scale }; } + private static PuppeteerSharp.Media.MarginOptions? GetMarginOptions(MarginOptions options) => new PuppeteerSharp.Media.MarginOptions + { + Top = options.Top, + Bottom = options.Bottom, + Left = options.Left, + Right = options.Right + }; + + private static PuppeteerSharp.Media.PaperFormat GetFormat(PaperFormat format) + { + if (format == PaperFormat.A0) + { + return PuppeteerSharp.Media.PaperFormat.A0; + } + else if (format == PaperFormat.A1) + { + return PuppeteerSharp.Media.PaperFormat.A1; + } + else if (format == PaperFormat.A2) + { + return PuppeteerSharp.Media.PaperFormat.A2; + } + else if (format == PaperFormat.A3) + { + return PuppeteerSharp.Media.PaperFormat.A3; + } + else if (format == PaperFormat.A4) + { + return PuppeteerSharp.Media.PaperFormat.A4; + } + else if (format == PaperFormat.A5) + { + return PuppeteerSharp.Media.PaperFormat.A5; + } + else if (format == PaperFormat.A6) + { + return PuppeteerSharp.Media.PaperFormat.A6; + } + else if (format == PaperFormat.Letter) + { + return PuppeteerSharp.Media.PaperFormat.Letter; + } + else if (format == PaperFormat.Legal) + { + return PuppeteerSharp.Media.PaperFormat.Legal; + } + else if (format == PaperFormat.Tabloid) + { + return PuppeteerSharp.Media.PaperFormat.Tabloid; + } + else if (format == PaperFormat.Ledger) + { + return PuppeteerSharp.Media.PaperFormat.Ledger; + } + else + { + return new PuppeteerSharp.Media.PaperFormat(format.Width, format.Height); + } + } + private static async Task AddStyleTagAsync(IPage page, IEnumerable? links = null) { var styles = new List(); From 3c66dcb8c736b34364b5420d7631fecfe67851b5 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 30 Oct 2025 19:25:53 +0800 Subject: [PATCH 2/2] chore: bump version 9.0.6-beta02 --- .../BootstrapBlazor.Html2Pdf.csproj | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/BootstrapBlazor.Html2Pdf/BootstrapBlazor.Html2Pdf.csproj b/src/components/BootstrapBlazor.Html2Pdf/BootstrapBlazor.Html2Pdf.csproj index bca9d00b..3741b045 100644 --- a/src/components/BootstrapBlazor.Html2Pdf/BootstrapBlazor.Html2Pdf.csproj +++ b/src/components/BootstrapBlazor.Html2Pdf/BootstrapBlazor.Html2Pdf.csproj @@ -1,7 +1,11 @@  - - 9.0.6-beta01 + + 9.0.6-beta02 + + + + 10.0.0-rc.2.1.2 @@ -9,8 +13,13 @@ Bootstrap UI components extensions of Html2Pdf use PuppeteerSharp lib - - + + + + + + +