Could not load file or assembly 'itextsharp, Version=, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies. The system cannot find the file specified. 

I have added reference to ItextSharp 5.4. and got this error.

I have a dropdown created when selected that render as pdf or word.

            string sDirPath = Server.MapPath("~/PDF_WORD/Docs");
            var ObjSearchDir = new DirectoryInfo(sDirPath);
            if (!ObjSearchDir.Exists)
            string strFileName =
                HttpContext.Current.Server.MapPath("~/PDF_WORD/Docs/Test." + DropDownListDownloadCv0.SelectedValue.ToString() +
            var objfileinfo = new FileInfo(strFileName);
            // step 1: creation of a document-object
            var document = new Document();

            if (objfileinfo.Exists)
                PdfWriter.GetInstance(document, new FileStream(strFileName, FileMode.Create));
                PdfWriter.GetInstance(document, new FileStream(strFileName, FileMode.Create));
            // step 2:
            // we create a writer that listens to the document
            //StringBuilder strB = new StringBuilder();
            var sw = new StringWriter();

            var hTextWriter = new HtmlTextWriter(sw);

            String strHtml1 = sw.ToString();

            var styles = new iTextSharp.text.html.simpleparser.StyleSheet();
            var hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
            hw.Parse(new StringReader(strHtml1));



Make sure you add the Itextsharp dll to the global assembly cache (GAC) on your server.

For 2010 the GAC is found under


For 2013


(But to add an DLL for 2013, please follow the instructions on MSDN, you can not just drag and drop as in 2010)

  • were do i find the global assembly cache (GAC) – Batistuta Apr 19 '13 at 7:39
  • Ammended my answer – Robert Lindgren Apr 19 '13 at 7:41
  • Please mark this as an answer if it helped you out – Robert Lindgren Apr 19 '13 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.