Webforms页面代码背后
XSettings.InstallRedistributionLicense("REDACTED");
var theDoc = new Doc();
theDoc.HtmlOptions.Engine = EngineType.Gecko;
theDoc.Rect.Inset(72, 144);
theDoc.Page = theDoc.AddPage();
int theID = theDoc.AddImageUrl("http://www.woot.com/");
while (true)
{
theDoc.FrameRect(); // add a black border
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();
}
Response.Buffer = false;
Response.AddHeader("Content-Disposition", "inline; filename=\"rept.pdf\"");
Response.ContentType = "application/pdf";
theDoc.Save(Response.OutputStream);
Response.Flush();
应该工作得很好..但得到
Failed to add HTML: RPC to Gecko engine process failed.Remote process terminated unexpectedly.
在bin文件夹中运行完全信任
打包/发布此项目文件夹中的所有文件
您不能在Windows Azure Website中运行外部流程,因为这会在共享基础架构中造成风险。
请参阅MSFT员工或this post的that post,其中同一员工谈论与本机API相关的其他限制。
您可以通过不将HTML图像添加到文档来验证问题是否与外部启动的Gecko相关。对我来说,PDF的创建进一步发展但由于缺少许可证而失败。
看起来您必须找到完全托管/ .NET HTML呈现引擎(如果将网站转换为PDF是您的用例),或希望保留模式网站获得执行本机/外部进程的权限。
这里有完整的ABCpdf Azure部署指南: