translateTransform method

void translateTransform(
  1. double offsetX,
  2. double offsetY
)

Changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this Graphics.

//Creates a new PDF document.
PdfDocument doc = PdfDocument();
//Create PDF graphics for the page
doc.pages.add().graphics
  ..save()
  //Set graphics translate transform.
  ..translateTransform(100, 100)
  ..drawString('Hello world!', PdfStandardFont(PdfFontFamily.helvetica, 12),
      brush: PdfBrushes.red)
  ..restore();
//Saves the document.
List<int> bytes = doc.save();
//Dispose the document.
doc.dispose();

Implementation

void translateTransform(double offsetX, double offsetY) {
  final PdfTransformationMatrix matrix = PdfTransformationMatrix();
  matrix.translate(offsetX, -offsetY);
  _helper.streamWriter!.modifyCurrentMatrix(matrix);
  _helper.matrix.multiply(matrix);
}