當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfWriter.GetBoxSize方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfWriter.GetBoxSize方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfWriter.GetBoxSize方法的具體用法?C# PdfWriter.GetBoxSize怎麽用?C# PdfWriter.GetBoxSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfWriter的用法示例。


在下文中一共展示了PdfWriter.GetBoxSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnEndPage

        public override void OnEndPage(PdfWriter writer, Document document)
        {
            var art = writer.GetBoxSize("art");

            ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_CENTER, new Phrase(this.config.Header1, new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD)), document.PageSize.Width / 2, document.PageSize.Height - 36, 0);
            ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_CENTER, new Phrase(this.config.Header2, new Font(Font.FontFamily.HELVETICA, 14, Font.NORMAL, BaseColor.GRAY)), document.PageSize.Width / 2, document.PageSize.Height - 56, 0);

            //writer.DirectContent.RestoreState();
            writer.DirectContent.SetLineWidth(1);
            writer.DirectContent.SetColorFill(BaseColor.BLACK);
            writer.DirectContent.SetColorStroke(BaseColor.BLACK);
            writer.DirectContent.MoveTo(document.LeftMargin, document.PageSize.Height - document.TopMargin + 15);
            writer.DirectContent.LineTo(document.PageSize.Width - document.RightMargin, document.PageSize.Height - document.TopMargin + 15);
            writer.DirectContent.Stroke();

            writer.DirectContent.MoveTo(document.LeftMargin, document.BottomMargin - 15);
            writer.DirectContent.LineTo(document.PageSize.Width - document.RightMargin, document.BottomMargin - 15);
            writer.DirectContent.Stroke();

            // footer left 1
            ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_LEFT, new Phrase(this.config.FooterLeft1, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD)), document.LeftMargin, document.BottomMargin - 30, 0);

            // footer left 2
            ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_LEFT, new Phrase(this.config.FooterLeft2, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD)), document.LeftMargin, document.BottomMargin - 42, 0);

            // footer right 1
            ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_RIGHT, new Phrase(this.config.FooterRight1, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD)), document.PageSize.Width - document.RightMargin, document.BottomMargin - 30, 0);

            // footer right 2
            ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_RIGHT, new Phrase(this.config.FooterRight2, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD)), document.PageSize.Width - document.RightMargin, document.BottomMargin - 42, 0);

            base.OnEndPage(writer, document);
        }
開發者ID:andrerpena,項目名稱:Cerebello,代碼行數:33,代碼來源:PdfHeaderFooter.cs

示例2: OnEndPage

 /**
  * Adds the header and the footer.
  * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
  *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
  */
 public override void OnEndPage(PdfWriter writer, Document document)
 {
     Rectangle rect = writer.GetBoxSize("art");
     switch (writer.PageNumber % 2)
     {
         case 0:
             ColumnText.ShowTextAligned(writer.DirectContent,
               Element.ALIGN_RIGHT,
               header[0],
               rect.Right, rect.Top, 0
             );
             break;
         case 1:
             ColumnText.ShowTextAligned(
               writer.DirectContent,
               Element.ALIGN_LEFT,
               header[1],
               rect.Left, rect.Top, 0
             );
             break;
     }
     ColumnText.ShowTextAligned(
       writer.DirectContent,
       Element.ALIGN_CENTER,
       new Phrase(String.Format("page {0}", pagenumber)),
       (rect.Left + rect.Right) / 2,
       rect.Bottom - 18, 0
     );
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:34,代碼來源:MovieHistory2.cs

示例3: OnEndPage

        /**
         * Adds the header and the footer.
         * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
         *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
         */
        public override void OnEndPage(PdfWriter writer, Document document)
        {
            Rectangle rect = writer.GetBoxSize("art");
            ColumnText.ShowTextAligned(writer.DirectContent,
                     Element.ALIGN_LEFT,
                     header,
                     rect.Left, rect.Bottom, 0);

            ColumnText.ShowTextAligned(
               writer.DirectContent,
               Element.ALIGN_LEFT,
               new Phrase(String.Format("|  page {0}", pagenumber)),
               (rect.Left + rect.Right),
               rect.Bottom, 0
            );
        }
開發者ID:SofEng22016,項目名稱:gom_makatichapter,代碼行數:21,代碼來源:Form9-GeneratePDF.cs


注:本文中的iTextSharp.text.pdf.PdfWriter.GetBoxSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。