如何将WkHtmlToXSharp PDF的页面大小更改为字母?默认情况下,它输出8.26 x 11.69英寸,我需要它是8.5 x 11。
答案 0 :(得分:0)
这是known issue,提交了拉取请求但未合并。
从GitHub项目页面添加拉取请求:https://github.com/tylerabahr/WkHtmlToXSharp/blob/ad9a935ea01c852133071fabbaf1b7d5a551e517/WkHtmlToXSharp/PdfGlobalSettings.cs
然后写下这段代码:
MultiplexingConverter mc = new MultiplexingConverter();
mc.GlobalSettings.Dpi = 300;
mc.GlobalSettings.Size.PageSize = PdfPageSize.Letter;
PdfMarginSettings pms = new PdfMarginSettings();
string halfInch = ".5in";
mc.GlobalSettings.Margin.Bottom = halfInch;
mc.GlobalSettings.Margin.Left = halfInch;
mc.GlobalSettings.Margin.Right = halfInch;
mc.GlobalSettings.Margin.Top = halfInch;