PdfCompositeField class
Represents class which can concatenate multiple automatic fields into single string.
//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 header with specific bounds
PdfPageTemplateElement header = PdfPageTemplateElement(
Rect.fromLTWH(0, 0, document.pages[0].getClientSize().width, 300));
//Create the date and time field
PdfDateTimeField dateAndTimeField = PdfDateTimeField(
font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
brush: PdfSolidBrush(PdfColor(0, 0, 0)));
//Create the composite field with date field
PdfCompositeField compositefields = PdfCompositeField(
font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
brush: PdfSolidBrush(PdfColor(0, 0, 0)),
text: '{0} Header',
fields: <PdfAutomaticField>[dateAndTimeField]);
//Add composite field in header
compositefields.draw(header.graphics,
Offset(0, 50 - PdfStandardFont(PdfFontFamily.timesRoman, 11).height));
//Add the header at top of the document
document.template.top = header;
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
- Inheritance
-
- Object
- PdfAutomaticField
- PdfCompositeField
Constructors
-
PdfCompositeField({PdfFont? font, PdfBrush? brush, String? text, List<
PdfAutomaticField> ? fields}) - Initializes the new instance of the PdfCompositeField class.
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
-
fields
↔ List<
PdfAutomaticField> -
Gets or sets the automatic fields(like page number, page count and etc.,)
getter/setter pair
- font ↔ PdfFont
-
Gets or sets the font of the field.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
- text ↔ String
-
Get or set the text for user format to display the page details
(eg. Input text:page {0} of {1} as dispalyed to page 1 of 5)
getter/setter pair
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