reset method

void reset([
  1. double? width,
  2. double? height
])

Resets an instance.

//Create a new PDF document.
PdfDocument document = PdfDocument();
//Create a PDF Template.
PdfTemplate template = PdfTemplate(100, 50);
//Draw a rectangle on the template graphics
template.graphics!.drawRectangle(
    brush: PdfBrushes.burlyWood, bounds: Rect.fromLTWH(0, 0, 100, 50));
//Add a new page and draw the template on the page graphics of the document.
document.pages.add().graphics.drawPdfTemplate(template, Offset(0, 0));
//Reset PDF template
template.reset();
//Draw a string using the graphics of the template.
template.graphics!.drawString(
    'Hello World', PdfStandardFont(PdfFontFamily.helvetica, 14),
    brush: PdfBrushes.black, bounds: Rect.fromLTWH(5, 5, 0, 0));
//Add a new page and draw the template on the page graphics of the document.
document.pages.add().graphics.drawPdfTemplate(template, Offset(0, 0));
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

void reset([double? width, double? height]) {
  if (width != null && height != null) {
    _setSize(width, height);
    reset();
  } else {
    if (_helper._resources != null) {
      _helper._resources = null;
      _helper.content.remove(PdfDictionaryProperties.resources);
    }
    if (_graphics != null) {
      PdfGraphicsHelper.getHelper(_graphics!).reset(size);
    }
  }
}