2013-12-17 4 views
2

MVC 4 응용 프로그램을 만들고 있습니다. 나는 PDF 파일 복잡한 모델을 ActionAsPDF에 전달하는 방법은 무엇입니까?

를 생성하는 Rotativa을 사용하고 그들은라는 방법

public ActionAsPdf(string action, object routeValues); 

내가

즉 routeValues ​​

에 복잡한 객체를 전달 문제가 데 있습니다

내가 가지고있는 ViewModel

public class FullName 
{ 
    public string FirstName { get; set; } 
    public string Surname { get; set; } 
} 

public ActionResult Index(FullName name) 
{ 
    ViewBag.Message = string.Format("Hello {0} to ASP.NET MVC!", name); 
    return View(); 
} 

public ActionResult Test() 
{ 
    var fullname = new FullName(); 
    fullname.FirstName = "John"; 
    fullname.Surname = "Smith"; 

    return new ActionAsPdf("Index", new { name = fullname }) { FileName = "Test.pdf" }; 
} 

내가 걸을 때, Index 조치 이름이 null ... 복잡한 모델을 어떻게 통과합니까?

답변

4

확인이

return new ActionAsPdf("Index", fullname) { FileName = "Test.pdf" }; 
+0

멋진 덕분에 .. – user2206329

+0

어떻게 내가 ActionAsPdf 두 viewmodels을 통과 할 호출? – user2206329

1
public ActionResult viewForPDFFile(int id) 
{ 
    Data data = new Manager().GetData(id); 
    return View(data); // this view content will show in PDF File 
} 

는 단순히

return new ActionAsPdf("viewForPDFFile", new { id = id}) { FileName = String.Format("File_{0}.pdf",id) }; 
관련 문제