drawPdfTemplate method

void drawPdfTemplate(
  1. PdfTemplate template,
  2. Offset location, [
  3. Size? size
])

Draws a template at the specified location and size.

//Creates a new PDF document.
PdfDocument doc = PdfDocument();
//Create a PDF Template.
PdfTemplate template = PdfTemplate(200, 100)
  ..graphics!.drawRectangle(
      brush: PdfSolidBrush(PdfColor(255, 0, 0)),
      bounds: Rect.fromLTWH(0, 20, 200, 50))
  ..graphics!.drawString(
      'This is PDF template.', PdfStandardFont(PdfFontFamily.courier, 14));
//Draws the template into the page graphics of the document.
doc.pages.add().graphics.drawPdfTemplate(template, Offset(100, 100));
//Saves the document.
List<int> bytes = doc.save();
//Dispose the document.
doc.dispose();

Implementation

void drawPdfTemplate(PdfTemplate template, Offset location, [Size? size]) {
  size ??= template.size;
  _drawTemplate(template, location, size);
}