Question

Locked

ASPX to PDF conversion image path problem

By vilas.gurav7777 ·
HI i am trying to convert aspx to pdf but while converting if images are on aspx page means its searching the images path on hard disk instead of serching on root directory ...and if i place the images on specified path like F:\img.jpg then its not giving any problem...so please let me know if any good answer/solution for this issue...i am using following code to solve the above issue


string attachment = "attachment; filename=Article.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
form1.RenderControl(htextw);// (this is the error part)
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
//iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance(imagepath + "/mikesdotnetting.gif");
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);//Here is the error
document.Close();
Response.Write(document);
Response.End();


please give soltion waiting for reply..many thanks in advance

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

I don't see where you declared/defined your imagepath variable

by robo_dev In reply to ASPX to PDF conversion im ...

e.g.:
string imagepath = Server.MapPath("Images");

And imagepath depends on the Server.MapPath method.

Don't forget that the Server.MapPath method is relative or absolute depending on whether there's a slash there or not.

Server.MapPath Method
"Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash (\), the MapPath method returns a path as if Path were a full, virtual path. If Path doesn't start with a slash, the MapPath method returns a path relative to the directory of the .asp file being processed."

http://msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx

Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums