wkhtmltopdf ErrorCode 1 ConnectionRefusedError

时间:2018-10-09 08:13:11

标签: asp.net asp.net-mvc iis wkhtmltopdf rotativa

我正在使用asp.net mvc和rotativa将当前的html页面转换为pdf。 Rotativa使用wkhtmltopdf。

该网站将是Intranet应用程序。

我将网站发布到服务器上,当我使用内部IP地址和专用端口连接我的网站时,一切正常,

但是我的问题是,每当我使用外部IP和端口连接到网站时,当用户进行转换为pdf程序时都会遇到错误 错误如下:

enter image description here

我对此错误进行了一些研究,但是当我尝试这些解决方案时,没有一个对我有用。 我尝试过:

  • 对inetpub中的整个文件夹具有完全权限
  • 关闭防火墙
  • 更改样式表的基本网址。
  • 还尝试了--load-error-handling忽略

我的代码:

    public ActionResult PrintAllReport()
{
    var root = Server.MapPath("~/PDF/");
    var pdfname = "asd"+".pdf";
    var path = Path.Combine(root, pdfname);
    path = Path.GetFullPath(path);
    var report = new ActionAsPdf("Test", new { id = id });
    report.PageSize = Rotativa.Options.Size.A4;
    report.PageOrientation = Rotativa.Options.Orientation.Portrait;
   var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write);
    fileStream.Write(binary, 0, binary.Length);
    fileStream.Close();
    return report;


}

希望你们能帮助我解决这个问题。 预先感谢。

0 个答案:

没有答案