Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi..

how to add tha same heading in pdf if the pdf consists more than oone page in c# + itextsharp????
Posted
Comments
What have you tried?
Member 10276220 14-Dec-13 1:18am    
i have created a pdf of more than one page. and i want the heading at every page..but i cant do it...how to do this???please help me out....
Member 10276220 14-Dec-13 1:20am    
my code is...

imgPDF.Visible = true;
Label1.Visible = true;
label16.Visible = true;
label17.Visible = true;
string txt1 = txtfromdate.Text;
DateTime dt1 = Convert.ToDateTime(txt1);
string txt2 = txttodate.Text;
DateTime dt2 = Convert.ToDateTime(txt2);
decimal ttsl = 0, ttrbt = 0;
// int membrcnt=0;
DataTable dt = objComapniesBL.FetchOtherReportsByDate(Convert.ToInt32(Session["ID"]), dt1.ToString("yyyy-MM-dd"), dt2.ToString("yyyy-MM-dd"));
int membrcnt = dt.Rows.Count;
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{

ttsl = ttsl + Convert.ToDecimal(dt.Rows[i]["salesAmount"]);
ttrbt = ttrbt + Convert.ToDecimal(dt.Rows[i]["rebateamount"]);
}
lblmember.Text = membrcnt.ToString();
grdsupplierothers.DataSource = dt;
grdsupplierothers.DataBind();

lblTotalSales.Text = ttsl.ToString();
lblTotalRebate.Text = ttrbt.ToString();

}
}

protected void imgPDF_Click(object sender, ImageClickEventArgs e)
{

string txt1 = txtfromdate.Text;
DateTime dt1 = Convert.ToDateTime(txt1);
string txt2 = txttodate.Text;
DateTime dt2 = Convert.ToDateTime(txt2);
DataTable dt = objComapniesBL.FetchOtherReportsByDate(Convert.ToInt32(Session["ID"]), dt1.ToString("yyyy-MM-dd"), dt2.ToString("yyyy-MM-dd"));

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attchment;filename=" + dt1.ToString("yyyy-MM-dd") + "through" + dt2.ToString("yyyy-MM-dd") + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);

Document myDoc = new Document(PageSize.A4);

PdfWriter.GetInstance(myDoc, HttpContext.Current.Response.OutputStream);
myDoc.Open();

Phrase phrase1 = new Phrase(Environment.NewLine);
myDoc.Add(phrase1);

Paragraph p1 = new Paragraph("Evergreen Marketing Group - Marketing Allowance Report", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 18, Font.NORMAL, new BaseColor(255, 0, 0)));
p1.Alignment = Element.ALIGN_CENTER;
myDoc.Add(p1);

Paragraph p2 = new Paragraph("Detailed Sales Report for" + " " + dt1.ToString("yyyy-MM-dd") + "through" + dt2.ToString("yyyy-MM-dd"), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL));
p2.Alignment = Element.ALIGN_CENTER;
myDoc.Add(p2);

Paragraph p3 = new Paragraph(Session["CompanyName"].ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14, Font.NORMAL));
p3.Alignment = Element.ALIGN_CENTER;
myDoc.Add(p3);

myDoc.Add(phrase1);










BaseFont fonsize = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
Font newFont = new Font(fonsize, 12, Font.BOLD, BaseColor.DARK_GRAY);

BaseFont fonsize2 = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
Font newFont1 = new Font(fonsize2, 12, Font.BOLD, BaseColor.DARK_GRAY);
myDoc.Add(new Paragraph());
myDoc.Add(new Paragraph());
myDoc.Add(phrase1);

PdfPTable gridTable = new PdfPTable(grdsupplierothers.Columns.Count);

StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
StringReader sr = new StringReader(sw.ToString());

grdsupplierothers.Style.Add("width", "800px");
grdsupplierothers.HeaderRow.Style.Add("font-size", "14px");
grdsupplierothers.HeaderRow.Style.Add("font-weight", "bold");
grdsupplierothers.Style.Add("border", "1px solid bla

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