Click here to Skip to main content
15,906,329 members
Home / Discussions / C#
   

C#

 
GeneralRe: can not find file vjslib.dll Pin
nesfrank19-Nov-08 8:10
nesfrank19-Nov-08 8:10 
GeneralRe: can not find file vjslib.dll Pin
nesfrank19-Nov-08 4:01
nesfrank19-Nov-08 4:01 
Question[Message Deleted] Pin
droig19-Nov-08 3:24
droig19-Nov-08 3:24 
AnswerRe: Binging DataGridView to a Generic List of interfaces Pin
leppie19-Nov-08 3:45
leppie19-Nov-08 3:45 
GeneralRe: Binging DataGridView to a Generic List of interfaces Pin
Pedram Behroozi19-Nov-08 5:32
Pedram Behroozi19-Nov-08 5:32 
GeneralRe: Binging DataGridView to a Generic List of interfaces Pin
droig19-Nov-08 5:53
droig19-Nov-08 5:53 
GeneralRe: Binging DataGridView to a Generic List of interfaces Pin
Pedram Behroozi19-Nov-08 6:01
Pedram Behroozi19-Nov-08 6:01 
QuestioniTextSharp html image parsing issue Pin
Cape Town Developer19-Nov-08 2:49
Cape Town Developer19-Nov-08 2:49 
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<br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
	<title></title><br />
</head><br />
<body><br />
<table width="100%" border="0" cellpadding="1" cellspacing="5" style="font-size:10pt font-family:Arial, Tahoma"><br />
    <tr><br />
        <td colspan="2" align="right"><br />
            <img src="logo.gif" /><br />
        </td><br />
    </tr><br />
</table><br />
</body><br />
</html><br />
<br />
<br />
asp.net code behind <br />
<br />
 private void SendEmail(string attachmentName, string pdfDocumentHtml, <br />
                               string mailSubject, string mailBody,  MailAddress fromEmailAddress, <br />
                               List<mailaddress> toMailAddressCollection)<br />
        {<br />
            Document doc = null;<br />
            XmlTextReader reader = null;<br />
            MemoryStream ms = null;<br />
            MemoryStream msPdf = null;<br />
            MemoryStream msHtml = null;<br />
            try<br />
            {<br />
                /* Convert to PDF */<br />
                doc = new Document(PageSize.A4, 10, 10, 10, 10);<br />
<br />
                msPdf = new MemoryStream();<br />
                PdfWriter.GetInstance(doc, msPdf); /* Create a pdf document listner to the memory data strean */<br />
                msHtml = new MemoryStream(new ASCIIEncoding().GetBytes(pdfDocumentHtml)); <br />
<br />
                reader = new XmlTextReader(msHtml);<br />
                reader.WhitespaceHandling = WhitespaceHandling.None;<br />
                HtmlParser.Parse(doc, reader);<br />
                ms = new MemoryStream(msPdf.ToArray());<br />
<br />
                /* Mail and add PDF as Attachment*/<br />
                var attachment = new Attachment(ms, new ContentType("application/pdf"));<br />
                attachment.Name = attachmentName;<br />
                attachment.NameEncoding = Encoding.UTF8;<br />
                MailMessage email = new MailMessage();<br />
                email.From = fromEmailAddress;<br />
<br />
                foreach (MailAddress address in toMailAddressCollection)<br />
                {<br />
                    email.To.Add(address);<br />
                }<br />
<br />
                email.Attachments.Add(attachment); /* Assumes one attachment of type pdf from the memory stream */ <br />
                email.Subject = mailSubject;<br />
                email.Body = mailBody;<br />
                email.IsBodyHtml = true;<br />
                SmtpClient client = new SmtpClient();<br />
                client.Send(email);<br />
            }<br />
            finally<br />
            {<br />
                /* Clean up */<br />
                if (reader != null)<br />
                    reader.Close();<br />
                if (ms != null)<br />
                    ms.Close();<br />
                if (msPdf != null)<br />
                    msPdf.Close();<br />
                if (msHtml != null)<br />
                    msHtml.Close();<br />
                //if (doc != null && doc.IsOpen())<br />
                //    doc.Close();<br />
            }<br />
        }<br />
</mailaddress>





Frown | :(
Thanks in advance

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

AnswerRe: iTextSharp html image parsing issue Pin
Cape Town Developer19-Nov-08 21:49
Cape Town Developer19-Nov-08 21:49 
QuestionTrimEnd? Pin
dec8219-Nov-08 2:34
dec8219-Nov-08 2:34 
AnswerRe: TrimEnd? Pin
V.19-Nov-08 2:40
professionalV.19-Nov-08 2:40 
GeneralRe: TrimEnd? Pin
dec8219-Nov-08 2:55
dec8219-Nov-08 2:55 
GeneralRe: TrimEnd? Pin
J4amieC19-Nov-08 3:02
J4amieC19-Nov-08 3:02 
GeneralRe: TrimEnd? Pin
V.19-Nov-08 3:25
professionalV.19-Nov-08 3:25 
AnswerRe: TrimEnd? Pin
Andrew Rissing19-Nov-08 3:12
Andrew Rissing19-Nov-08 3:12 
AnswerRe: TrimEnd? Pin
Ashfield19-Nov-08 3:45
Ashfield19-Nov-08 3:45 
GeneralRe: TrimEnd? Pin
Ennis Ray Lynch, Jr.19-Nov-08 4:03
Ennis Ray Lynch, Jr.19-Nov-08 4:03 
GeneralRe: TrimEnd? Pin
Wendelius19-Nov-08 4:34
mentorWendelius19-Nov-08 4:34 
GeneralRe: TrimEnd? Pin
Ennis Ray Lynch, Jr.19-Nov-08 4:38
Ennis Ray Lynch, Jr.19-Nov-08 4:38 
GeneralRe: TrimEnd? Pin
Wendelius19-Nov-08 4:48
mentorWendelius19-Nov-08 4:48 
QuestionWCF Proxy Settings When Calling WebService Method... Pin
DotNetCoderJunior19-Nov-08 2:01
DotNetCoderJunior19-Nov-08 2:01 
AnswerCross Post. Pin
Pete O'Hanlon19-Nov-08 2:03
mvePete O'Hanlon19-Nov-08 2:03 
GeneralRe: Cross Post. Pin
DotNetCoderJunior19-Nov-08 2:38
DotNetCoderJunior19-Nov-08 2:38 
GeneralRe: Cross Post. Pin
J4amieC19-Nov-08 3:00
J4amieC19-Nov-08 3:00 
GeneralRe: Cross Post. Pin
Simon P Stevens19-Nov-08 3:03
Simon P Stevens19-Nov-08 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.