亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Y期第X頁

Y期第X頁

守著一只汪 2019-11-19 10:08:40
我嘗試了3種顯示頁碼的方法,頁面 OnCloseDocument中未顯示內容,但沒有一種有效。我的目的是顯示頁碼這樣的10 12 10 0F..........................在每一頁上的10 10我知道怎么顯示1234....10但不知道如何顯示總頁數我正在使用 OnCloseDocument 顯示頁數,但其中的內容未顯示。public class MyPdfPageEventHelpPageNo : iTextSharp.text.pdf.PdfPageEventHelper{    protected PdfTemplate total;    protected BaseFont helv;    private bool settingFont = false;    public override void OnOpenDocument(PdfWriter writer, Document document)    {        template= writer.DirectContent.CreateTemplate(100, 100);               bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);    }    public override void OnCloseDocument(PdfWriter writer, Document document)    {    //See below    }第一種方式:    public override void OnCloseDocument(PdfWriter writer, Document document)         {        //I create a table with one column like below.        PdfPTable pageNumber2 = new PdfPTable(1);        pageNumber2.TotalWidth = 50;        pageNumber2.HorizontalAlignment = Element.ALIGN_RIGHT;        pageNumber2.AddCell(BuildTable2RightCells("Page " + writer.PageNumber));        pageNumber.AddCell(BuildTable2LeftCells(writer.PageCount));        pageNumber2.WriteSelectedRows(0, -1, 500,         (document.PageSize.GetBottom(140)), cb);    }    第二路:    public override void OnCloseDocument(PdfWriter writer, Document document)         {        ColumnText.ShowTextAligned(template,Element.ALIGN_CENTER,new        Phrase(writer.PageNumber.ToString()), 500, 140, 0);    }第三種方式:    public override void OnCloseDocument(PdfWriter writer, Document document)         {        template.BeginText();        template.SetFontAndSize(bf, 8);        template.SetTextMatrix(500, 140);        template.ShowText(Convert.ToString((writer.PageNumber - 1)));        template.EndText();    }我做錯什么了嗎?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 397 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號