drawPath method

void drawPath(
  1. PdfPath path, {
  2. PdfPen? pen,
  3. PdfBrush? brush,
})

Draws a GraphicsPath defined by a pen, a brush and path.

//Creates a new PDF document.
PdfDocument doc = PdfDocument()
  ..pages
      .add()
      .graphics
      //Draw Paths
      .drawPath(
          PdfPath()
            ..addRectangle(Rect.fromLTWH(10, 10, 100, 100))
            ..addEllipse(Rect.fromLTWH(100, 100, 100, 100)),
          pen: PdfPens.black,
          brush: PdfBrushes.red);
//Saves the document.
List<int> bytes = doc.save();
//Dispose the document.
doc.dispose();

Implementation

void drawPath(PdfPath path, {PdfPen? pen, PdfBrush? brush}) {
  _helper._beginMarkContent();
  _helper._stateControl(pen, brush, null, null);
  _buildUpPath(PdfPathHelper.getHelper(path).points,
      PdfPathHelper.getHelper(path).pathTypes);
  _drawPath(pen, brush, PdfPathHelper.getHelper(path).fillMode, false);
  _helper.endMarkContent();
}