Rotativa pdf does not work on server

谁说我不能喝 提交于 2021-02-20 05:13:16

问题


I am using Rotativa to generate a pdf of my view. on my local computer this works. On my online server, it says cannot locate file or directory. It is probably a permission problem. Any idea how to fix it?

Thanx in advance


回答1:


Rotativa uses wkhtmltopdf at its' core, which starting from >0.12.0.0 relies on distributable VC++ lib (msvcp120.dll)

You may need to download the installer from here rather than just copy dll over to the server http://wkhtmltopdf.org/downloads.html

Simple test if server wkhtmltopdf works:

C:\[path to the wkhtmltopdf]\wkhtmltopdf.exe https://google.com test.pdf



回答2:


The solution was to substitute Rotativa.Mvc.ActionasPdf() with Rotativa.Mvc.ViewasPdf

public ActionResult DetailPdf(int? id)
    {
        Progetto Progetti = db.Progetti.Find(id);
        return new Rotativa.MVC.ViewAsPdf("DetailPdf", Progetti);
    }

I don't know what the problem with ActionAsPdf was though




回答3:


step 1 : go to server folder where your pdf file store
step 2 : on the folder properties change security, disable read only check box and change to full control or give write control.
step 3 : In web.config change as

<system.web>   
<authentication mode="None" /> /// or bring the suitable authentication
.......................




回答4:


We had the same issue on a windows server. Found out that Reports is used by sql server reporting services. So we just had to rename all instances of Reports to something else in our application.



来源:https://stackoverflow.com/questions/27818766/rotativa-pdf-does-not-work-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!