Reputation: 881
I have tried to make Pdf from razor views.But it always error me. I have used Visual studio 2013, .net framework 4.5 & asp.net mvc5.
For creating i have used to install RazorPdf version 1.0.0.0 package & itextsharp 5.5.2.0 version.
Code snapshot----------
//controller code
public PdfResult Pdf()
{
return new PdfResult();
}
//razor view
@{
Layout = null;
}
<itext creationdate="@DateTime.Now.ToString()" producer="RazorPDF">
<table width="100%" cellpadding="0.5" cellspacing="0.5" widths="30;70" borderwidth="1.0" left="false" right="false" top="false" bottom="false" red="0" green="0" blue="0">
<row>
<cell>
<chunk style="font-weight:bold;">Today:</chunk>
</cell>
<cell>
<chunk style="">@DateTime.Now.ToString("MM/dd/yyyy")</chunk>
</cell>
</row>
<row>
<cell>
<chunk style="font-weight:bold;">Yesterday:</chunk>
</cell>
<cell>
<chunk style="">@DateTime.Now.AddDays(-1).ToString("MM/dd/yyyy")</chunk>
</cell>
</row>
</table>
----------------------Error Details---------------
Could not load type 'iTextSharp.text.html.HtmlParser' from assembly 'itextsharp, Version=5.5.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca'
Upvotes: 1
Views: 621
Reputation: 669
<itext creationdate="@DateTime.Now.ToString()" producer="RazorPDF"> @RenderBody() </itext>
Then set Layout = "~/Views/Shared/NewlyCreatedLayout.cshtml";
Hope this will help.
Upvotes: 1