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 文件夹中
打包/发布 Web 此项目文件夹中的所有文件
最佳答案
您不能从 Windows Azure Website 内部运行外部进程。因为这会给共享基础设施带来风险。
见 this post由 MSFT 员工或 that post同一位员工谈论与 native API 相关的其他限制。
可以验证问题是否与外部启动的Gecko有关。通过不将 HTML 图像添加到文档中。对我来说,PDF 的创建取得了进一步进展,但由于缺少许可证而失败。
看起来您必须找到一个完全托管的/.NET HTML 渲染引擎(如果将网站转换为 PDF 是您的用例),或者希望保留模式的网站获得执行 native /外部进程的权利。
关于abcpdf - 有没有人能够在 azure 网站上使用 ABCPDF(HTML 转换),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13631232/