如何使用asp.net在pdf文件中添加页脚 [英] how to add footer in pdf file using asp.net

查看:87
本文介绍了如何使用asp.net在pdf文件中添加页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在通过必须附加PDF的应用程序发送自动生成的邮件
归档到该邮件.我正在动态生成此文件.
但是我无法在此PDF中添加页脚.

请回复.
我的代码如下

Hello all,

I am sending autogenerated mail through my application in which I have to attach PDF
file to that mail. I am generation this file dynamically.
But I m unable to add footer in this PDF.

Please reply.
My code is as follows

HtmlForm form = new HtmlForm();
       form.Controls.Add(Grdpick);
       StringWriter sw = new StringWriter();
       HtmlTextWriter hTextWriter = new HtmlTextWriter(sw);
       form.Controls[0].RenderControl(hTextWriter);
       string html = sw.ToString();
       Document Doc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);

       PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\pickslip\\pickslip-" + profno + ".pdf", FileMode.Create));

       Doc.Open();

       Chunk chunk1 = new Chunk("Trident Services Pvt. Ltd. \n\n", FontFactory.GetFont("Verdana", 20));
       Paragraph p1 = new Paragraph();
       p1.Alignment = Element.ALIGN_CENTER;
       p1.Add(chunk1);
       string datenow = convertdate.changeformatDate(DateTime.Now);
       Chunk chunk2 = new Chunk(" Pick Slip No : " + profno + "                                                                       Date :" + datenow + " \n", FontFactory.GetFont("Verdana", 10));
       Paragraph p2 = new Paragraph();
       p2.Alignment = Element.ALIGN_LEFT;
       p2.Add(chunk2);
       //
       //Chunk chunk4 = new Chunk(" Date :" + datenow + " \n", FontFactory.GetFont("Verdana", 10));
       //Paragraph p4 = new Paragraph();
       //p4.Alignment = Element.ALIGN_RIGHT;
       //p4.Add(chunk4);

       Chunk chunk3 = new Chunk(" Customer : " + partyname + " \n  ESN : " + ESN + "                                                                       Branch : " + Session["BrnName"].ToString() + "\n", FontFactory.GetFont("Verdana", 10));
       Paragraph p3 = new Paragraph();
       p3.Alignment = Element.ALIGN_LEFT;
       p3.Add(chunk3);

       Doc.Add(p1);
       Doc.Add(p2);
       Doc.Add(p3);

     //  Doc.Add(p5);
    //  Doc.Footer  = new HeaderFooter(footerphrase, footerphrase);
    //  Doc.Add(footerphrase);
       System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(new StringReader(html));
       HtmlParser.Parse(Doc, xmlReader);
       Doc.Close();
       string Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\pickslip\\pickslip-" + profno + ".pdf";

推荐答案

如果您使用iTextSharp dll,则可以使用
If ur using iTextSharp dll then u can use
OnEndPage


PDF事件.

看到这个

http://www.mazsoft. com/blog/post/2008/04/30/Code-sample-for-using-iTextSharp-PDF-library.aspx [


event of PDF.

see this

http://www.mazsoft.com/blog/post/2008/04/30/Code-sample-for-using-iTextSharp-PDF-library.aspx[^]


这篇关于如何使用asp.net在pdf文件中添加页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆