Enum PdfAlignmentStyle
Specifies how the page template is aligned relative to the template area.
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public enum PdfAlignmentStyle
Remarks
This enumeration is used in PdfPageTemplateElement class.
Examples
//Create a PDF document
PdfDocument doc = new PdfDocument();
//Create a page
PdfPage page = doc.Pages.Add();
RectangleF rect = new RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
//Create a page template
PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);
//set the dock style
footer.Dock = PdfDockStyle.Right;
//Set the template alignment as top right
footer.Alignment = PdfAlignmentStyle.TopRight;
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
PdfSolidBrush brush = new PdfSolidBrush(Color.Gray);
//Create page number field
PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);
//Create page count field
PdfPageCountField count = new PdfPageCountField(font, brush);
PdfCompositeField compositeField = new PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count);
compositeField.Bounds = footer.Bounds;
compositeField.Draw(footer.Graphics, new PointF(40, footer.Height - 50));
//Add the footer template at the bottom
doc.Template.Right = footer;
doc.Save("Template.pdf");
doc.Close(true);
'Create a PDF document
Dim doc As New PdfDocument()
'Create a page
Dim page As PdfPage = doc.Pages.Add()
Dim rect As New RectangleF(0, 0, page.GetClientSize().Width, page.GetClientSize().Height)
'Create a page template
Dim footer As New PdfPageTemplateElement(rect)
'set the dock style
footer.Dock = PdfDockStyle.Right
'Set the template alignment as top right
footer.Alignment = PdfAlignmentStyle.TopRight
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 8)
Dim brush As New PdfSolidBrush(Color.Gray)
'Create page number field
Dim pageNumber As New PdfPageNumberField(font, brush)
'Create page count field
Dim count As New PdfPageCountField(font, brush)
Dim compositeField As New PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count)
compositeField.Bounds = footer.Bounds
compositeField.Draw(footer.Graphics, New PointF(40, footer.Height - 50))
'Add the footer template at the bottom
doc.Template.Right = footer
doc.Save("Template.pdf")
doc.Close(True)
Fields
Name | Description |
---|---|
BottomCenter | The template is bottom center aligned. |
BottomLeft | The template is bottom left aligned. |
BottomRight | The template is bottom right aligned. |
MiddleCenter | The template is middle center aligned. |
MiddleLeft | The template is middle left aligned. |
MiddleRight | The template is middle right aligned. |
None | Specifies no alignment. |
TopCenter | The template is top center aligned. |
TopLeft | The template is top left aligned. |
TopRight | The template is top right aligned. |