Results 1 to 8 of 8

Thread: [RESOLVED] Got error while export aspx page to pdf

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Resolved [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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up 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

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up 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

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up 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

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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
  •  



Click Here to Expand Forum to Full Width