drawString method

void drawString(
  1. PdfFont font,
  2. double size,
  3. String s,
  4. double x,
  5. double y, {
  6. double? charSpace,
  7. double? wordSpace,
  8. double? scale,
  9. PdfTextRenderingMode mode = PdfTextRenderingMode.fill,
  10. double? rise,
})

This draws a string.

Implementation

void drawString(
  PdfFont font,
  double size,
  String s,
  double x,
  double y, {
  double? charSpace,
  double? wordSpace,
  double? scale,
  PdfTextRenderingMode mode = PdfTextRenderingMode.fill,
  double? rise,
}) {
  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      _buf.putString(' ' * (_indent));
    }
    return true;
  }());

  _buf.putString('BT ');

  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      _buf.putString(' ' * (_commentIndent - 3 - _indent));
      _buf.putComment('beginText()');
      _indent += _indentAmount;
    }
    return true;
  }());

  setFont(font, size,
      charSpace: charSpace,
      mode: mode,
      rise: rise,
      scale: scale,
      wordSpace: wordSpace);

  var o = 0;
  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      o = _buf.offset;
      _buf.putString(' ' * (_indent));
    }
    return true;
  }());

  PdfNumList([x, y]).output(_page, _buf);
  _buf.putString(' Td ');

  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
      _buf.putComment('moveCursor($x, $y)');
      o = _buf.offset;
      _buf.putString(' ' * (_indent));
    }
    return true;
  }());

  _buf.putString('[');
  font.putText(_buf, s);
  _buf.putString(']TJ ');

  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
      _buf.putComment('drawString("$s")');
      o = _buf.offset;
      _indent -= _indentAmount;
      _buf.putString(' ' * (_indent));
    }
    return true;
  }());

  _buf.putString('ET ');

  assert(() {
    if (_page.pdfDocument.settings.verbose) {
      _buf.putString(' ' * (_commentIndent - 3 - _indent));
      _buf.putComment('endText()');
    }
    return true;
  }());

  _page.altered = true;
}