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 - - + + + + + + + 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();