|
-
Sep 30th, 2009, 01:57 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Got error while export aspx page to pdf
Hi friends,
I resolved forum that export aspx page to pdf. Its working fine when some paragraph inside table. If image file is appear the error is coming.
Export aspx page to pdf. The below code workin in this type.ie.,<table>some para </table>
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.tblpdf.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
But inside the table the image source file is appear it will give exception.
<table width="680" border="0" cellspacing="0" cellpadding="0" align="center" id="print_doc" runat="server">
<tr>
<td height="25" colspan="2" valign="bottom" class="title1">ACCOUNTS</td>
</tr>
<tr><td colspan="2" style="border-bottom:2px solid #a70c29"><img src="images/space.gif" width="1" height="10" /></td></tr>
<tr><td><img src="images/space.gif" width="1" height="25" /></td></tr>
</table>
Error is "Could not find a part of the path 'C:\images\space.gif"
Please suggest me. How can we rectify this problem??
Hopes your reply
Thanks
Failing to plan is Planning to fail 
-
Sep 30th, 2009, 03:01 PM
#2
Re: Got error while export aspx page to pdf
Hey,
Where does the image file live on your web server? I would suspect that it isn't at that location, so where does it live?
Gary
-
Oct 1st, 2009, 12:13 AM
#3
Thread Starter
Addicted Member
Re: Got error while export aspx page to pdf
This image placed on my D:/ But this code htmlparser.parse(sr) always giving this error while put image src . If i remove image but i put like <img src="" />
Its giving error that is c:/ not find part of the path.
Please suggest me.
Thanks
Failing to plan is Planning to fail 
-
Oct 1st, 2009, 01:43 AM
#4
Re: Got error while export aspx page to pdf
Hey,
I would suggest that you take a look at this thread:
http://www.vbforums.com/showthread.p...&highlight=PDF
And use the method suggested there.
Hope that helps!!
Gary
-
Oct 1st, 2009, 04:38 AM
#5
Thread Starter
Addicted Member
Re: Got error while export aspx page to pdf
Hi gep,
I got the solution. Thanks dude for your help.
Thanks
Failing to plan is Planning to fail 
-
Oct 1st, 2009, 05:30 AM
#6
Re: [RESOLVED] Got error while export aspx page to pdf
Hey,
What was the solution?
It would be good if you could post it here so that others can learn.
Gary
-
Oct 1st, 2009, 06:04 AM
#7
Thread Starter
Addicted Member
Re: [RESOLVED] Got error while export aspx page to pdf
Hey gep,
Yeah you are right i do. The only exporting I will be changing the URL of the image handler from relative to absolute URL. For example in the previous example the URL was
Images/space.gif
Now it will be changed to
http://localhost/Images/space.gif
Since Word, Excel or PDF files need complete URL of the image so that they
can download the image from the server
Thanks
Failing to plan is Planning to fail 
-
Oct 1st, 2009, 12:41 PM
#8
Re: [RESOLVED] Got error while export aspx page to pdf
Hey,
Glad to hear you got it working!!
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|