PdfPageCountField class

Represents total PDF document page count automatic field. Represents an automatic field to display total number of pages in section(if set isSectionPageCount as true).

//Create a new pdf document
PdfDocument document = PdfDocument();
//Add the pages to the document
for (int i = 1; i <= 5; i++) {
  document.pages.add().graphics.drawString(
      'page$i', PdfStandardFont(PdfFontFamily.timesRoman, 11),
      bounds: Rect.fromLTWH(250, 0, 615, 100));
}
//Create the footer with specific bounds
PdfPageTemplateElement footer = PdfPageTemplateElement(
    Rect.fromLTWH(0, 0, document.pages[0].getClientSize().width, 50));
//Create the page count field
PdfPageCountField count = PdfPageCountField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)));
//set the number style for page count
count.numberStyle = PdfNumberStyle.upperRoman;
//Create the composite field with page number page count
PdfCompositeField compositeField = PdfCompositeField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)),
    text: 'Page Count: {0}',
    fields: <PdfAutomaticField>[count]);
compositeField.bounds = footer.bounds;
//Add the composite field in footer
compositeField.draw(
    footer.graphics,
    Offset(
        290, 50 - PdfStandardFont(PdfFontFamily.timesRoman, 19).height));
//Add the footer at the bottom of the document
document.template.bottom = footer;
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
Inheritance

Constructors

PdfPageCountField({PdfFont? font, PdfBrush? brush, Rect? bounds, bool? isSectionPageCount})
Initializes a new instance of the PdfPageCountField class and may also with the classes are PdfFont, PdfBrush and Rect.

Properties

bounds Rect
Gets or sets the bounds of the field.
getter/setter pairinherited
brush PdfBrush
Gets or sets the brush of the field.
getter/setter pairinherited
font PdfFont
Gets or sets the font of the field.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
numberStyle PdfNumberStyle
Gets or sets the specific number style.
getter/setter pair
pen PdfPen?
Gets or sets the pen of the field.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringFormat PdfStringFormat?
Gets or sets the stringFormat of the field.
getter/setter pairinherited

Methods

draw(PdfGraphics graphics, [Offset? location]) → void
Draws an element on the Graphics. Graphics context where the element should be printed. location has contains X co-ordinate of the element, Y co-ordinate of the element.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited