我使用TuesPechkin(wkhtmltopdf的C#包装器)并让它从HTML生成PDF文件。
但是,我想设置--disable-smart-shrinking
选项,该选项在wkhtmltopdf documentation中列为PageOption
我该怎么做?
public sealed class PdfConverter
{
static readonly PdfConverter instance = new PdfConverter();
private IConverter converter;
static PdfConverter()
{
}
PdfConverter()
{
// Keep the converter somewhere static, or as a singleton instance! Do NOT run this code more than once in the application lifecycle!
this.converter = new ThreadSafeConverter( new RemotingToolset<PdfToolset>( new Win32EmbeddedDeployment( new TempFolderDeployment())));
}
public static PdfConverter Instance
{
get { return instance; }
}
public byte[] ConvertHtmlToPdf(string html)
{
var document = new HtmlToPdfDocument
{
Objects = { new ObjectSettings { HtmlText = html } }
// Where are PageOptions? Thats where --disable-smart-shrinking is
};
return converter.Convert(document);
}
}
答案 0 :(得分:1)
API中不存在--disable-smart-shrinking
选项 - 嗯,类似,但它的形式是相反的兄弟:--enable-smart-shrinking
。
该属性在TuesPechkin API中以WebSettings.EnableIntelligentShrinking
as seen in the TuesPechkin source code的形式提供。它在TuesPechkin中以这种方式命名,因为它是在wkhtmltopdf的API as seen in the wkhtmltopdf source code中命名的。
你也可以看到默认值为true(来自wkhtmltopdf),所以如果你将WebSettings.EnableIntelligentShrinking
设置为false
,你应该得到你想要的结果。
答案 1 :(得分:0)