output method

  1. @override
void output(
  1. PdfObjectBase<PdfDataType> o,
  2. PdfStream s, [
  3. int? indent
])
override

Implementation

@override
void output(PdfObjectBase o, PdfStream s, [int? indent]) {
  if (indent != null) {
    s.putBytes(List<int>.filled(indent, 0x20));
  }
  s.putBytes(const <int>[0x3c, 0x3c]);
  var len = 0;
  var n = 1;
  if (indent != null) {
    s.putByte(0x0a);
    indent += kIndentSize;
    len = values.keys.fold<int>(0, (p, e) => math.max(p, e.length));
  }
  values.forEach((String k, T v) {
    if (indent != null) {
      s.putBytes(List<int>.filled(indent, 0x20));
      n = len - k.length + 1;
    }
    s.putString(k);
    if (indent != null) {
      if (v is PdfDict || v is PdfArray) {
        s.putByte(0x0a);
      } else {
        s.putBytes(List<int>.filled(n, 0x20));
      }
    } else {
      if (v is PdfNum || v is PdfBool || v is PdfNull || v is PdfIndirect) {
        s.putByte(0x20);
      }
    }
    v.output(o, s, indent);
    if (indent != null) {
      s.putByte(0x0a);
    }
  });
  if (indent != null) {
    indent -= kIndentSize;
    s.putBytes(List<int>.filled(indent, 0x20));
  }
  s.putBytes(const <int>[0x3e, 0x3e]);
}