Failed to load type 'iTextSharp.text.html.HtmlParser' from the assembly 'itextsharp, Version = 5.5.3.0, Culture = neutral, PublicKeyToken = 8354ae6d2174ddca'

I am new to asp.net mvc 4.

I made a simple application using RazorPDF.

The application is a regular page in PDF format. I created a new application and it works fine. But the same thing when I implement in my project, it does not work and gives an error , because it was not possible to load the type "iTextSharp.text.html.HtmlParser" from the assembly 'itextsharp, Version = 5.5.3.0, Culture = neutral, PublicKeyToken = 8354ae6d2174ddca '.

I researched about this and found a concept why it displays this error, since bcoz when installing RazorPDF does not install HtmlParser inside iTextSharp.

The point that I don’t get is that I do the same in the new application, it installs everything, and the code works fine, if I do the same in my project, it doesn’t install all the things through I ma getting this mistakes.

The code is working fine, no doubt. The problem is installing RazorPDF in my project, it does not install all 9 subpackages inside iTextSharp (HtmlEncoder, HtmlTags, HtmlUtilities, WebColors, HtmlParser, Markup, ITextmyHtmlHandler, HtmlWriter, HtmlTagMap), it only installs 4 HtmlTtml, .

Since HtmlParser is not installed, does this issue display? Does anyone have knowledge in this (RazorPDF). Can any1 help me solve this problem?

Encoding Controller

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.Mvc;
 using pdf.Models;
 namespace pdf.Controllers
  {
   public class StudentsController : Controller
     {
         public ActionResult Index()
        {
          var studentMarks = new List<MarksCard>()
           {
                        new MarksCard(){ RollNo = 101, Subject = "C#",FullMarks = 100, Obtained = 90},
                        new MarksCard() {RollNo = 101, Subject = "asp.net", FullMarks = 100, Obtained = 80},
                        new MarksCard() {RollNo = 101, Subject = "MVC", FullMarks = 100,Obtained = 100},
                        new MarksCard() {RollNo = 101, Subject = "SQL Server", FullMarks = 100, Obtained = 75},
            };
            return new RazorPDF.PdfResult(studentMarks, "Index");
         } 
   }
 }

Model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace pdf.Models
  {
    public class MarksCard
     {
        public int RollNo
         {
           get;
           set;
         }
        public string Subject
        {
         get;
         set;
        }
      public int FullMarks
        {
         get;
         set;
       }
     public int Obtained { get; set; }
   }
}

View

 @model IEnumerable<pdf.Models.MarksCard>
  @{
    Layout = null;
   }
  <!DOCTYPE html>
   <html>
  <body>
     <table border="1" width='500' bordercolor="RED"><tr><td colspan="3" bgcolor="LightGreen"  
            align="center" valign="top">
         SSLC Marks Sheet 2013</td></tr><tr><td>
          @{ var rollNumber = Model.Select(z => z.RollNo).Take(1).ToArray();}
          Riyaz Akhter<br />RollNo:@rollNumber[0]</td></tr>
         <tr>
          <td bgcolor="lightblue">@Html.DisplayNameFor(moel => moel.Subject)</td>
         <td bgcolor="lightblue">@Html.DisplayNameFor(model => model.FullMarks)</td>
        <td bgcolor="lightblue">@Html.DisplayNameFor(model => model.Obtained)</td></tr>
        @{
          int total = 0;
        }
       @foreach (var item in Model)
         {
          <tr><td>@Html.DisplayFor(modelItem => item.Subject)</td>
              <td>@Html.DisplayFor(modelItem => item.FullMarks)</td>
              <td>@Html.DisplayFor(modelItem => item.Obtained)</td>
             </tr>total += item.Obtained;
       }
      <tr><td>
         </td>
          <td>
             <strong><font color="GREEN">Total</font></strong>
           </td>
         <td>@total</td></tr>
       </table>
    </body>
  </html>
+4

All Articles