Rotativa在服务器中生成空白PDF [英] Rotativa generating blank PDF in Server

查看:119
本文介绍了Rotativa在服务器中生成空白PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在.Net MVC 5项目中使用Rotativa。它在本地工作就像魅力,并在部署到服务器时失败(生成空白PDF)。但是,如果我登录到服务器并以localhost身份访问该网站,则生成PDF就好了。



因此,它看起来像运行应用程序池的权限问题。因此,出于测试目的,我更改为运行App Pool以在本地系统上运行。还是一样的问题。



我们也试过:



ViewasPDF

应用程序设置如下所示:< add key =WkhtmltopdfPathvalue =<文件夹的路径>>

以下是代码:



返回新的ActionAsPdf(ActionMethod,新{id = id,partSelected = part,selectedTab = selectedTab,isDownload = true})

{

FileName = fileName,

PageMargins = {Left = 0,Right = 0},

CustomSwitches = - disable-external-links --disable-internal- links --disable-smart-shrinking --viewport-size 1600x900 - load-error-handling ignore,

PageOrientation = Rotativa.Options.Orientation.Portrait,

PageSize = Rotativa.Options.Size.A4,

PageWidth = 210,

PageHeight = 297

};

We are using Rotativa in a .Net MVC 5 project. it works like a charm locally and fails (generates a blank PDF) equally when deployed to server. However, if I login to server and access the website as localhost it generates PDF just fine.

So it looked like a permission issue with which Application pool is running on. So, for testing purpose, I changed to run the App Pool to run on "Local System". Still same issue.

We have also tried:

"ViewasPDF"
App settings which looks like: <add key="WkhtmltopdfPath" value="<path to the folder>">
Below is the code:

return new ActionAsPdf("ActionMethod",new { id = id, partSelected = part, selectedTab = selectedTab, isDownload = true })
{
FileName = fileName,
PageMargins = { Left = 0, Right = 0 },
CustomSwitches = "--disable-external-links --disable-internal-links --disable-smart-shrinking --viewport-size 1600x900 --load-error-handling ignore",
PageOrientation = Rotativa.Options.Orientation.Portrait,
PageSize = Rotativa.Options.Size.A4,
PageWidth = 210,
PageHeight = 297
};

推荐答案

查看您传递的视图/ html是否呈现为空。哪个服务器正在使用?
See Whether that view/html you are passing is rendering as Empty. Which server are using?


这篇关于Rotativa在服务器中生成空白PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆