如何在pdf的所有页面上添加标题 [英] how to add header on all page of pdf
问题描述
hii all,
i希望使用itextsharp.dll以pdf格式导出gridview数据..
我的gridview数据正确导出为PDF格式..但我想在PDF的所有页面上标题和页码。请给我建议。
我的代码是。用于pdf中的导出:
hii all,
i want to export gridview data in pdf using itextsharp.dll..
my gridview data is export in pdf correctly..but i want to header and page number on all page of PDF.. PLEASE give me suggestion.
my code is. for export in pdf:
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
//To Export all pages
GridView2.AllowPaging = false;
this.GetChildList();
GridView2.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10, 10, 10, 50);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
}
请帮帮我
提前感谢..
please help me
thanks in advance..
推荐答案
如果你想手动更改使用
http://www.pdfforge.org/download [ ^ ]
If you want to change manually use
http://www.pdfforge.org/download[^]
如果要创建PDf,请使用itextSahrp。
if you want to create PDf please use itextSahrp.
Font font_heading1 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10f, Font.BOLD, BaseColor.WHITE);
PdfPTable table40 = new PdfPTable(8);
table40.TotalWidth = 480f;
table40.LockedWidth = true;
//relative col widths in proportions - 1/3 and 2/3
float[] widths = new float[] { 1.8f, 2.2f, 2.5f, 1.2f, 1f, 1f, 1.2f, 1f };
table40.SetWidths(widths);
table40.HorizontalAlignment = 1;
PdfPCell cel = new PdfPCell(new Phrase("Sample Id", font_heading1));
cel.BackgroundColor = new iTextSharp.text.BaseColor(51, 79, 100);
cel.HorizontalAlignment = 1;
table40.AddCell(cel);
看看
< a href =http://www.mikesdotnetting.com/Article/205/Exporting-The-Razor-WebGrid-To-PDF-Using-iTextSharp> www.mikesdotnetting.com/Article/205/Exporting-The-Razor -WebGrid-To-PDF-Using-iTextSharp [ ^ ]
http://stackoverflow.com/questions/4553220/ how-can-i-add-a-header-to-a-pdf-file-using-itext-in-c?rq = 1. [ ^ ]
have a look
www.mikesdotnetting.com/Article/205/Exporting-The-Razor-WebGrid-To-PDF-Using-iTextSharp[^]
http://stackoverflow.com/questions/4553220/how-can-i-add-a-header-to-a-pdf-file-using-itext-in-c?rq=1.[^]
这篇关于如何在pdf的所有页面上添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!