Raja A

Raja A

  • NA
  • 26
  • 68.5k

How to add footer and header pdf dynamic page using c#

Jan 13 2014 6:25 AM
Hi,
          I need to add header and footer in dynamic pdf

My code is ...


BaseFont bf = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\Arial.ttf", BaseFont.IDENTITY_H, true);
      
        divexcel.Visible = true;
        Response.ContentType = "application/pdf";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.AddHeader("content-disposition", "attachment;filename={0}_Final_Entry.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);         
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        divexcel.RenderControl(hw);       
        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4, 80f, 80f, -2f, 35f);
        
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();       

Here i need to add header and footer