本文整理匯總了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);
}
示例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
);
}
示例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
);
}