drawLine method

void drawLine(
  1. PdfPen pen,
  2. Offset point1,
  3. Offset point2
)

Draws a line connecting the two points specified by the coordinate pairs.

//Create a new PDF document.
PdfDocument doc = PdfDocument()
  ..pages
      .add()
      .graphics
      //Draw line.
      .drawLine(PdfPens.black, Offset(100, 100), Offset(200, 100));
// Save the document.
List<int> bytes = doc.save();
// Dispose the document.
doc.dispose();

Implementation

void drawLine(PdfPen pen, Offset point1, Offset point2) {
  _helper._beginMarkContent();
  _helper._stateControl(pen, null, null, null);
  _helper.streamWriter!.beginPath(point1.dx, point1.dy);
  _helper.streamWriter!.appendLineSegment(point2.dx, point2.dy);
  _helper.streamWriter!.strokePath();
  _helper.endMarkContent();
  (_helper._getResources!() as PdfResources)
      .requireProcset(PdfDictionaryProperties.pdf);
}