4
Answers

PDF Issues...

Sumit Banglorkar

Sumit Banglorkar

11y
1.1k
1
Hi Friends,
Using Asp.net & C#.
I am generating PDF (through ITextsharp Liabrary) from Gridview, In gridview i have last three columns which is button like View,Update & Delete. I don't need that button columns is to be generate in PDF, pls give me solutions how to do this.
Thanks in advanced...
Here is my code...(.cs)
if (GridViewWorkDisciplineMaster.Rows.Count == AppConstants.EMPTY_STRING_LEN)
            {
                ChangeLabelColor(lblerror, "No Records Found to Export", AppConstants.BOOL_TRUE);
                return;
            }
            else
            {
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=WorkDisciplineMaster_" + DateTime.Now.ToString("dd/MM/yyyy") + ".pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                StringWriter sw = new StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                if (isAllDataExport == AppConstants.BOOL_TRUE)
                {
                    BindData();
                }
                else if (isSearchDataExport == AppConstants.BOOL_TRUE)
                {
                    btnSearch_Click(sender, e);
                }
                else if (isLikeDataExport == AppConstants.BOOL_TRUE)
                {
                    btnLike_Click(sender, e);
                }
                GridViewWorkDisciplineMaster.AllowPaging = AppConstants.BOOL_FALSE;
                GridViewWorkDisciplineMaster.DataBind();
                GridViewWorkDisciplineMaster.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();
            }



And also i need to give heading like
1. name of company
2. name of report
3. print date
4. page no.

Pls help me out...

Regards,
Sumit...

Answers (4)