PdfDateTimeField constructor

PdfDateTimeField({
  1. PdfFont? font,
  2. PdfBrush? brush,
  3. Rect? bounds,
})

Initializes a new instance of the PdfDateTimeField class.

font - Specifies the PdfFont to use. brush - The object that is used to fill the string. bounds - Specifies the location and size of the field.

//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(const Rect.fromLTWH(0, 0, 515, 50));
//Create the composite field
PdfCompositeField compositeField = PdfCompositeField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)),
    text: 'Time:{0}');
//Create the date and time field
PdfDateTimeField dateTimeField = PdfDateTimeField(
    font: PdfStandardFont(PdfFontFamily.timesRoman, 19),
    brush: PdfSolidBrush(PdfColor(0, 0, 0)));
//Add date&time field to composite fields
compositeField.fields.add(dateTimeField);
//Set bounds to composite field.
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();

Implementation

PdfDateTimeField({super.font, super.brush, super.bounds});