如何让NReco.PdfGenerator.LT使用Linux二进制文件?

时间:2017-01-17 14:52:42

标签: linux .net-core

我使用NReco.PdfGenerator.LT从HTML页面创建PDF文档。如果我只是将它指向wkhtmltopdf.exe可执行文件,这在Windows上运行正常,但这对Linux没有相同的效果。

HtmlToPdfConverter cvt = new HtmlToPdfConverter();

cvt.PdfToolPath = GetPdfToolPath();
// Windows: <current-dir>\wkhtmltopdf\win32\bin
// Linux: <current-dir>/wkhtmltopdf/linux/bin

cvt.WkHtmlToPdfExeName = GetPdfToolName();
// Windows: wkhtmltopdf.exe
// Linux: wkhtmltopdf

我刚收到此错误:

  

无法生成PDF:权限被拒绝

1 个答案:

答案 0 :(得分:1)

此错误的可能原因:

  • 启动.net核心程序的linux用户无权运行&#34; wkhtmltopdf&#34;。同时确保&#34; wkhtmltopdf&#34;文件标记为&#34;可执行文件&#34; (x)的
  • 有时Path.GetTempPath()返回的临时文件夹不可访问;可以使用HtmlToPdfConverter.TempFilesPath属性
  • 指定临时文件的另一个位置