1

I want to create a simple pdf with RazorPDF.

I installed it from Nuget Package. (itexsharp and razorpdf appear in reference)

Here's my controller:

public ActionResult Index()
{
    return new RazorPDF.PdfResult();
}

And, I have a simple view that shows "hello".

When I use return view(), everything is ok and "hello" is displayed, but when I use return new RazorPDF.PdfResult();, the following error occurs:

The view 'Pdf' or its master was not found or no view engine supports the searched locations. The following locations were searched: view/home/pdf.aspx

ataravati
  • 8,891
  • 9
  • 57
  • 89

2 Answers2

0

Actually you have to create your own separate masterpage for the PDF view. Just add one partial view masterpage in shared folder and in that page just copy paste below code.

    <itext creationdate="@DateTime.Now.ToString()" producer="RazorPDF">
          @RenderBody()
    </itext>
RohannG
  • 669
  • 7
  • 12
-1

Try to have a look at how to return a file in MVC. See this question and its answer.

Not sure what PdfResult returns but you would convert your return statement to something like this:

return File(new RazorPDF.PdfResult(), "application/pdf");
Community
  • 1
  • 1
Jakub Holovsky
  • 6,543
  • 10
  • 54
  • 98