Enum PdfAlignmentStyle
- Namespace
- Syncfusion.Pdf
- Assembly
- Syncfusion.Pdf.Portable.dll
Specifies how the page template is aligned relative to the template area.
public enum PdfAlignmentStyle
Fields
BottomCenter = 8
The template is bottom center aligned.
BottomLeft = 7
The template is bottom left aligned.
BottomRight = 9
The template is bottom right aligned.
MiddleCenter = 5
The template is middle center aligned.
MiddleLeft = 4
The template is middle left aligned.
MiddleRight = 6
The template is middle right aligned.
None = 0
Specifies no alignment.
TopCenter = 2
The template is top center aligned.
TopLeft = 1
The template is top left aligned.
TopRight = 3
The template is top right aligned.
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)
Remarks
This enumeration is used in PdfPageTemplateElement class.