【发布时间】:2014-09-15 11:49:45
【问题描述】:
我想将 html 导出为 pdf,文档已生成但只有第一页
Doc theDoc = new Doc();
theDoc.HtmlOptions.UseScript = true;
theDoc.HtmlOptions.Media = MediaType.Print;
theDoc.HtmlOptions.InitialWidth = 1048;
theDoc.HtmlOptions.ImageQuality = 101;
theDoc.HtmlOptions.UseScript = true;
theDoc.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 55000); })();";
theDoc.HtmlOptions.Engine = EngineType.Gecko;
theDoc.HtmlOptions.PageLoadMethod = PageLoadMethodType.WebBrowserNavigate;
theDoc.HtmlOptions.ForMSHtml.UseScript = true;
int theID = theDoc.AddImageHtml(htmlContent);
while (true)
{
theDoc.FrameRect();
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
theDoc.Save(HttpContext.Current.Server.MapPath("htmlimport.pdf"));
theDoc.Clear();
如何使用 Gecko 添加所有页面?如果我从页面中使用 MSHtml 样式就不好看了
【问题讨论】:
-
你有没有让这个工作?我有同样的问题,下面接受的答案似乎没有添加任何内容。谢谢