2016-05-16 136 views
2

我使用的代碼,用戶可以下載使用ROTATIVA保存生成的PDF服務器上

public ActionResult StandartPDF() 
    { 
     var makeCvSession = Session["makeCV"]; 
     var something = new Rotativa.ViewAsPdf("StandartPDF", makeCvSession) { FileName = "cv.pdf" }; 
     return something; 

    } 

產生從查看PDF。但起初我想在服​​務器上。我怎樣才能做到這一點?

回答

3

我解決了使用SaveOnServerPath財產Rotativa

public ActionResult StandartPDF() 
    { 

     var makeCvSession = Session["makeCV"]; 

     var root = Server.MapPath("~/PDF/"); 
     var pdfname = String.Format("{0}.pdf", Guid.NewGuid().ToString()); 
     var path = Path.Combine(root, pdfname); 
     path = Path.GetFullPath(path); 

     var something = new Rotativa.ViewAsPdf("StandartPDF", makeCvSession) { FileName = "cv.pdf", SaveOnServerPath = path }; 
     return something; 

    }