I have grid which binds some barcodes from databas. This barcodes I want to generate in pdf. How can I do this? Sorry I dont have any idea how to do this so there is no sample code to show. My gridview name "GrdBarcode".Please help me.Below is my grid with barcodes
<asp:GridView ID="grdBarcode" CssClass="table"
OnRowDataBound="grdBarcode_RowDataBound" AutoGenerateColumns="false"
GridLines="None" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table style="width:100%">
<tr>
<p>Date:<asp:Label runat="server" ID="Label5" Text='<%#Eval("Date") %>'>
</asp:Label> </p></td>
<td align="center"></td> <td><p>No Of QP: <asp:Label runat="server"
ID="Label6" Text='<%#Eval("NoOfQP") %>'></asp:Label></p>
<p>Time: <asp:Label runat="server" ID="Label7" Text='<%#Eval("Timing") %>'>
</asp:Label></p>
<p>Durations: <asp:Label runat="server" ID="Label8"
Text='<%#Eval("Duration") %>'></asp:Label>)</p>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:DataList ID="datalistBarcode" RepeatColumns="3"
RepeatDirection="Horizontal" GridLines="None"
OnItemDataBound="datalistBarcode_ItemDataBound" runat="server">
<ItemTemplate> <asp:Label ID="lblBarCode" runat="server"
Text='<%#Eval("BarCode") %>' Visible="false"></asp:Label>
<table class="table">
<tr> <td >
<asp:Panel ID="pnlBarCode" HorizontalAlign="center" runat="server">
</asp:Panel>
</tr>
<tr>
<td align="center"><asp:Label ID="lblStudCode" runat="server"
Text='<%#Eval("StudCode") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ItemTemplate></asp:TemplateField>
</Columns>
</asp:GridView>
I tried like elow mentioned methode.but it shows error Document has no pages
protected void btnPrint_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in grdBarcode.Rows)
{
DataList dl = (DataList)row.FindControl("datalistBarcode");
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);
dl .DataBind();
dl .RenderControl(htextw);
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);
document.Close();
Response.Write(document);
Response.End();
}