Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. iTextSharp html image parsing issue

iTextSharp html image parsing issue

Scheduled Pinned Locked Moved C#
helpcsharphtmlasp-netsysadmin
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cape Town Developer
    wrote on last edited by
    #1

    The problem Using itextSharp to convert an html file to pdf and emailing it, I am unable to successfully parse an html file on the web server backend even when doing "absolute" or "relative" image referencing itextSharp fails and says "unable to find file c:\my_image.jpg" this is crazy didn’t specify c:\my_image.jpg as a path !!! The madness of all this is it works well on my local file system, when the html file is located on asp.net using an IIS webserver i get the above described error. Here is my code. // Simple copy of the html ![](logo.gif) asp.net code behind private void SendEmail(string attachmentName, string pdfDocumentHtml, string mailSubject, string mailBody, MailAddress fromEmailAddress, List toMailAddressCollection) { Document doc = null; XmlTextReader reader = null; MemoryStream ms = null; MemoryStream msPdf = null; MemoryStream msHtml = null; try { /* Convert to PDF */ doc = new Document(PageSize.A4, 10, 10, 10, 10); msPdf = new MemoryStream(); PdfWriter.GetInstance(doc, msPdf); /* Create a pdf document listner to the memory data strean */ msHtml = new MemoryStream(new ASCIIEncoding().GetBytes(pdfDocumentHtml)); reader = new XmlTextReader(msHtml); reader.WhitespaceHandling = WhitespaceHandling.None; HtmlParser.Parse(doc, reader); ms = new MemoryStream(msPdf.ToArray()); /* Mail and add PDF as Attachment*/ var attachment = new Attachment(ms, new ContentType("application/pdf")); attachment.Name = attachmentName; attachment.NameEncoding = Encoding.UTF8; MailMessage email = new MailMessage(); email.From = fromEmailAddress; foreach (MailAddress address in toMailAddressCollection) { email.To.Add(address); } email.Attachmen

    C 1 Reply Last reply
    0
    • C Cape Town Developer

      The problem Using itextSharp to convert an html file to pdf and emailing it, I am unable to successfully parse an html file on the web server backend even when doing "absolute" or "relative" image referencing itextSharp fails and says "unable to find file c:\my_image.jpg" this is crazy didn’t specify c:\my_image.jpg as a path !!! The madness of all this is it works well on my local file system, when the html file is located on asp.net using an IIS webserver i get the above described error. Here is my code. // Simple copy of the html ![](logo.gif) asp.net code behind private void SendEmail(string attachmentName, string pdfDocumentHtml, string mailSubject, string mailBody, MailAddress fromEmailAddress, List toMailAddressCollection) { Document doc = null; XmlTextReader reader = null; MemoryStream ms = null; MemoryStream msPdf = null; MemoryStream msHtml = null; try { /* Convert to PDF */ doc = new Document(PageSize.A4, 10, 10, 10, 10); msPdf = new MemoryStream(); PdfWriter.GetInstance(doc, msPdf); /* Create a pdf document listner to the memory data strean */ msHtml = new MemoryStream(new ASCIIEncoding().GetBytes(pdfDocumentHtml)); reader = new XmlTextReader(msHtml); reader.WhitespaceHandling = WhitespaceHandling.None; HtmlParser.Parse(doc, reader); ms = new MemoryStream(msPdf.ToArray()); /* Mail and add PDF as Attachment*/ var attachment = new Attachment(ms, new ContentType("application/pdf")); attachment.Name = attachmentName; attachment.NameEncoding = Encoding.UTF8; MailMessage email = new MailMessage(); email.From = fromEmailAddress; foreach (MailAddress address in toMailAddressCollection) { email.To.Add(address); } email.Attachmen

      C Offline
      C Offline
      Cape Town Developer
      wrote on last edited by
      #2

      Anyone??

      Wisdom is often meant as the ability and desire to make choices that can gain approval in a long-term examination by many people.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups