2015-06-12 25 views
1

我使用TuesPechkin(wkhtmltopdf的C#包裝),並讓它從HTML生成PDF文件。如何設置PagePhont的週二皮金

不過,我想設置--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); 
    } 
} 

回答

1

--disable-smart-shrinking選項不會在API中存在的 - 嗯,這的做法,但在它的形式是相反的兄弟姐妹:--enable-smart-shrinking

該屬性的TuesPechkin API爲WebSettings.EnableIntelligentShrinkingas seen in the TuesPechkin source code中獲得。它的名字就是在週二Pechkin中的名字,因爲它是在wkhtmltopdf的API as seen in the wkhtmltopdf source code中命名的。

您還可以在那裏看到默認值爲true(來自wkhtmltopdf),所以如果您將WebSettings.EnableIntelligentShrinking設置爲false,則應該得到您要達到的結果。

0

看來這個功能還沒有在週二推出。我找不到它here,其中大部分頁面選項都位於此處。

我猜他忘了執行該選項,因此最好請求功能here。或者你也可以自己添加該功能。 :)