Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hey All ..
 
when i try to export Datalist or gridview to pdf..ie exported without images !!!
 
this is my code :
 
Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition",
         "attachment;filename=Products.pdf");
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
 
        DataList1.DataBind();
        
        DataList1.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();
Posted 8-Jul-11 3:54am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You may need to make sure that your images are referenced by absolute and not relative paths in your html. This is due to the fact that most pdf writers create a temporary copy of your html input in a temp directory before parsing which then causes the relative paths to fail.
  Permalink  
Comments
shms_rony at 8-Jul-11 9:05am
   
datalist images get from path in database
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I want to export datalist with image to pdf with asp.net c#
  Permalink  
Comments
ThePhantomUpvoter at 19-Apr-13 7:25am
   
This is not an answer to this 2 year old question. This would not even qualify as a question if you asked it yourself. You need to post this as your own question and include the code that you have tried and describe the problem that you are having with the code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 565
1 Maciej Los 319
2 Richard MacCutchan 220
3 BillWoodruff 164
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100