Mi problema es el siguiente:
Al momento de asignar el html a convertir a pdf, me marca un error con las rutas de las imagenes. tengo algo como esto:
Código:
El error que me sale es una web exeption que dice asi:String strSelectUserListBuilder = ""; //string UrlDirectory = Server.MapPath("images"); MemoryStream MStream = new MemoryStream(); Document document = new Document(PageSize.A4, 80, 50, 30, 65); try { PdfWriter writer = PdfWriter.GetInstance(document, MStream); document.Open(); strSelectUserListBuilder = "<table border='0' width='600' cellspacing='0' cellpadding='0'>" + "<tr>" + "<td>" + "<p align='center'><img border='0' src='images/image_x_psd.png' ><br>" + "<font face='Arial' size='3' color='#876E3A'><b>Consultants<br></b></font>" + "<img border='0' src='images/image_x_psd.png' >" + "</td>" + "</tr>" + " <tr><td>" + "</td></tr>" + // FOOTER "<tr>" + "<td>" + "<p align='center'><img border='0' src='images/image_x_psd.png'>" + "</td>" + "</tr>" + "</table>" + "<br><br><br>"; //Here is where your HTML source goes................ String htmlText = strSelectUserListBuilder.ToString(); //make an arraylist ....with STRINGREADER since its no IO reading file... List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null); //add the collection to the document for (int k = 0; k < htmlarraylist.Count; k++) { IElement x = (IElement)htmlarraylist[k]; //Response.Write(x.Type.ToString() + "#<br>"); document.Add((IElement)htmlarraylist[k]); } //document.Add(new Paragraph("And the same with indentation....")); // or add the collection to an paragraph // if you add it to an existing non emtpy paragraph it will insert it from //the point youwrite - Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder" mypara.IndentationLeft = 36; //mypara.InsertRange(0, htmlarraylist); document.Add(mypara); document.Close(); } catch (Exception e) { throw e; } HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=myPDFNew.pdf"); HttpContext.Current.Response.BinaryWrite(MStream.GetBuffer()); HttpContext.Current.Response.End();
"No se puede encontrar una parte de la ruta de acceso 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\src='images\image_x_psd.png' '."
y la ruta de la imagen no es esa, yo le especifico la del proyecto.
solo con texto me funciona de maravilla, pero el html que quiero exportar lleva imagenes, si me podrian ayudar a solucionar este pequeño inconveniente, se los agradeceria mucho.