diff --git a/source/Append.Blazor.Printing/PrintOptions.cs b/source/Append.Blazor.Printing/PrintOptions.cs index d8ab0b8..98b64a7 100644 --- a/source/Append.Blazor.Printing/PrintOptions.cs +++ b/source/Append.Blazor.Printing/PrintOptions.cs @@ -14,12 +14,13 @@ public PrintOptions(string printable) Printable = printable; } - public PrintOptions(string printable, string modalMessage, PrintType printType = PrintType.Pdf) + public PrintOptions(string printable, string modalMessage, PrintType printType = PrintType.Pdf, bool useFontSizeWorkaround = false) { Printable = printable; ModalMessage = modalMessage; ShowModal = true; Type = printType; + UseFontSizeWorkaround = useFontSizeWorkaround; } /// /// Document source: pdf url or base64. @@ -41,5 +42,10 @@ public PrintOptions(string printable, string modalMessage, PrintType printType = /// Used when printing PDF documents passed as base64 data. /// public bool Base64 { get; set; } + + /// + /// Uses empty font_size parameter as a workaround for issue https://github.com/crabbly/Print.js/issues/534. + /// + public bool UseFontSizeWorkaround { get; set; } } } diff --git a/source/Append.Blazor.Printing/PrintOptionsAdapter.cs b/source/Append.Blazor.Printing/PrintOptionsAdapter.cs index ea31d79..dbdcf4d 100644 --- a/source/Append.Blazor.Printing/PrintOptionsAdapter.cs +++ b/source/Append.Blazor.Printing/PrintOptionsAdapter.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Serialization; namespace Append.Blazor.Printing { @@ -13,6 +14,9 @@ internal record PrintOptionsAdapter public string ModalMessage { get; init; } = "Retrieving Document..."; public bool? Base64 { get; set; } public string TargetStyles { get; set; } = "['*']"; + [JsonPropertyName("font_size")] + //HACK: This is a hack to get around the fact that the PrintJS is dead and issue https://github.com/crabbly/Print.js/issues/534 is not getting fixed anytime soon. + public string FontSize { get; set; } public PrintOptionsAdapter(PrintOptions options) { @@ -21,6 +25,7 @@ public PrintOptionsAdapter(PrintOptions options) ShowModal = options.ShowModal; ModalMessage = options.ModalMessage; Base64 = options.Base64 == true ? true : null; + FontSize = options.UseFontSizeWorkaround ? "" : "12px"; //12px is the default value in PrintJS } } }