Results 1 to 3 of 3

Thread: Unable to cast object of type 'iTextSharp.text.List' to type 'iTextSharp.text.Paragra

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Angry Unable to cast object of type 'iTextSharp.text.List' to type 'iTextSharp.text.Paragra

    Error:
    Unable to cast object of type 'iTextSharp.text.List' to type 'iTextSharp.text.Paragraph'.

    c# Code:
    1. StringReader SR = new StringReader(strText);
    2.        
    3.         List<IElement> HTML_List = HTMLWorker.ParseToList(SR, null);
    4.  
    5.         for (int k = 0; k < HTML_List.Count; k++)
    6.         {
    7.             doc.Add((IElement)HTML_List[k]);
    8.         }
    9.  
    10.         doc.Close();
    11.     }

    the value in strTest:
    html Code:
    1. "\r\n\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n\t<title>\r\n    Convert html to pdf using iTextSharp\r\n : The Official Microsoft ASP.NET Forums</title>\r\n\t<meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\" />\r\n    \r\n\t<link href=\"http://i3.asp.net/common/www-css/i/favicon.ico?cdn_id=20110616-003\" rel=\"shortcut icon\" />    \r\n    <link href=\"http://i1.asp.net/fan-cheetah/style/prod-site.min.css?cdn_id=20110616-003\" rel=\"Stylesheet\" type=\"text/css\" media=\"screen\" />\r\n    <!--[if lte IE 7]>\r\n    <link href=\"http://i1.asp.net/fan-cheetah/style/prod-lt ..... The list goes on

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Unable to cast object of type 'iTextSharp.text.List' to type 'iTextSharp.text.Par

    Hello,

    Which line is throwing the error? And where is doc defined? What type is it?

    Gary

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Unable to cast object of type 'iTextSharp.text.List' to type 'iTextSharp.text.Par


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width