From 73aa261727c1e626622471bc4cc9c96f0ffa48e3 Mon Sep 17 00:00:00 2001 From: Daniel Isenmann Date: Fri, 9 Oct 2020 08:20:39 +0200 Subject: [PATCH 1/2] Add ImageQuality and ImageDPI to ConvertOptions --- .../Options/ConvertOptionsTests.cs | 4 +++- Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs b/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs index 45d8acf..6afa293 100644 --- a/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs +++ b/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs @@ -44,7 +44,9 @@ public void ConvertsAll() {"one", "1"}, {"two", "2"} }, - new[] {"--replace \"one\" \"1\"", "--replace \"two\" \"2\""}) + new[] {"--replace \"one\" \"1\"", "--replace \"two\" \"2\""}), + ImageDpi = AddWithFormat(++counter, "--image-dpi {0}"), + ImageQuality = AddWithFormat(++counter, "--image-quality {0}") }; var result = options.GetConvertOptions(); diff --git a/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs b/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs index 43136de..7a9b421 100644 --- a/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs +++ b/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs @@ -105,6 +105,18 @@ protected string GetContentType() [OptionFlag("--replace")] public Dictionary Replacements { get; set; } + /// + /// Sets the compression quality of the images + /// + [OptionFlag("--image-quality")] + public int? ImageQuality { get; set; } + + /// + /// Sets the dpi of the images + /// + [OptionFlag("--image-dpi")] + public int? ImageDpi { get; set; } + /* */ public string GetConvertOptions() { From 0ce6118687f9ce8f0a30e3d8ff29be1b1b202ef8 Mon Sep 17 00:00:00 2001 From: Daniel Isenmann Date: Fri, 9 Oct 2020 10:46:36 +0200 Subject: [PATCH 2/2] Add DisableSmartShrinking to ConvertOptions --- Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs | 1 + Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs b/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs index 6afa293..af5ca5a 100644 --- a/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs +++ b/Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs @@ -39,6 +39,7 @@ public void ConvertsAll() PageWidth = AddWithFormat(++counter + 0.5, "--page-width {0}"), IsGrayScale = AddWithValue(true, "-g"), IsLowQuality = AddWithValue(true, "-l"), + DisableSmartShrinking = AddWithValue(true, "--disable-smart-shrinking"), Replacements = AddWithValues(new Dictionary { {"one", "1"}, diff --git a/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs b/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs index 7a9b421..376b3c4 100644 --- a/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs +++ b/Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs @@ -117,6 +117,12 @@ protected string GetContentType() [OptionFlag("--image-dpi")] public int? ImageDpi { get; set; } + /// + /// Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio non-constant + /// + [OptionFlag("--disable-smart-shrinking")] + public bool DisableSmartShrinking { get; set; } + /* */ public string GetConvertOptions() {