1
我目前正在使用Azure服务结构(将替换网络和辅助角色的新产品的种类)托管打印服务。我使用wkhtmltopdf和NReco.PDFGenerator.LT作为它的包装,它在本地开发集群中工作正常,但在联机时失败。NReco PDFGenerator在Azure服务结构上失败
我得到的唯一例外是Exception thrown: 'System.Exception' in NReco.PdfGenerator.LT.dll
,我觉得它很难调试,因为它没有告诉什么是失败。
阅读this我在想,也许有些东西不见了集群上,但当地环境suposed是一个在线的翻版。而且我是用在同一个集群NReco包装phantomjs切换到前wkhtmltopdf,它在线和本地工作,我相信他们都使用相同的核心引擎(虽然不同的叉)?
这是我的代码,而在远程调试中,我检查了许可证,.exe路径和文件的值是否正确。
[HttpGet]
public ActionResult Get(string target)
{
var wktohtmlPath = Path.Combine(_hostingEnvironment.WebRootPath, "lib");
var htmlToPdf = new HtmlToPdfConverter() {
Quiet = false,
CustomWkHtmlArgs = "--print-media-type",
PdfToolPath = wktohtmlPath,
Margins = new PageMargins() { Left = 17, Right = 17, Top = 17, Bottom = 17 }
};
htmlToPdf.License.SetLicenseKey(
_optionsAccessor.Value.LicenceOwner,
_optionsAccessor.Value.LicenceKey
);
try
{
var fileBytes = htmlToPdf.GeneratePdfFromFile(target, null);
var fileStream = new MemoryStream(fileBytes);
return new FileStreamResult(fileStream, "application/pdf");
}
catch
{
return BadRequest();
}
}
谢谢您的回答