Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Add ImageQuality, ImageDPI and DisableSmartShrinking to ConvertOptions #43

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Wkhtmltopdf.NetCore.Test/Options/ConvertOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ 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<string, string>
{
{"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();
Expand Down
18 changes: 18 additions & 0 deletions Wkhtmltopdf.NetCore/Implementation/ConvertOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ protected string GetContentType()
[OptionFlag("--replace")]
public Dictionary<string, string> Replacements { get; set; }

/// <summary>
/// Sets the compression quality of the images
/// </summary>
[OptionFlag("--image-quality")]
public int? ImageQuality { get; set; }

/// <summary>
/// Sets the dpi of the images
/// </summary>
[OptionFlag("--image-dpi")]
public int? ImageDpi { get; set; }

/// <summary>
/// Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio non-constant
/// </summary>
[OptionFlag("--disable-smart-shrinking")]
public bool DisableSmartShrinking { get; set; }

/* <inheritDoc /> */
public string GetConvertOptions()
{
Expand Down