Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to export div content in pdf on button click.

i am facing problem while exporting div data in pdf

i have div in .aspx page like this..

<div id="FoodTokenDiv" runat="server">





<asp:Label ID="lblTab" runat="server">br mode="hold" />


.......
in .cs page i create table on this label and whatever i want to show on label after that i do the process of exporting div content in pdf like this...

Response.ContentType = "application/pdf";

Response.AddHeader("content-disposition", "attachment;filename=TokenForFoodTN" + did + ".pdf");

Response.Cache.SetCacheability(HttpCacheability.NoCache);

StringWriter stringWriter = new StringWriter();

HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

FoodTokenDiv.RenderControl(htmlTextWriter);

StringReader stringReader = new StringReader(stringWriter.ToString());

Document Doc = new Document(new RectangleReadOnly(350, (i*10)+200), 5f, 5f, 5f, 5f);

HTMLWorker htmlparser = new HTMLWorker(Doc);

PdfWriter.GetInstance(Doc, Response.OutputStream);

Doc.Open();

htmlparser.Parse(stringReader);

Doc.Close();

Response.Write(Doc);

Response.End();

.......
here in Document Doc line i increase height of the according to data so i use i*10 here 10 is 10px which increase according to i.

please help me...
thanks...
Posted
Comments
Sibasisjena 24-Dec-14 2:59am    
Hi krrazyumesh,

i have added 2 links. Please check those. You can an idea how to get out the issue.
If any specific issue, then please put.

1 solution

 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900