【发布时间】:2016-12-06 08:28:16
【问题描述】:
我正在使用 Select.HtmltoPdf。 下面是我的代码:
var directory = @"D:\Folder\";
html = html.Replace("/Content", HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Request.ApplicationPath + "/Content");
var filePath = directory + Guid.NewGuid() + ".pdf";
var converter = new HtmlToPdf(1536,1536);
converter.Options.EmbedFonts = false;
converter.Options.ExternalLinksEnabled = true;
converter.Options.InternalLinksEnabled = true;
converter.Options.KeepTextsTogether = false;
converter.Options.KeepImagesTogether = false;
converter.Options.JavaScriptEnabled = true;
var pdf = converter.ConvertHtmlString(html, Request.Url.Scheme + "://" + Request.Url.Authority +
Request.ApplicationPath.TrimEnd('/') + "/");
pdf.Save(filePath);
我的 CSS 在 Content/Site.css 上 要获取 html,我只需使用 $("#printpage").html();然后通过 Scripts/xx/custom/common.js 上的 ajax 调用将其传递给控制器。问题是它看起来不像在浏览器上那样。没有加载任何 CSS。我如何也使用 select.htmltopdf 来呈现 css?或者,如果有任何其他可用的软件包可以做到这一点。谢谢
【问题讨论】:
标签: jquery html css ajax model-view-controller