addPageNo method

Future<void> addPageNo()

Add a page no. at the top of the page. We add the svg elements at the very end of the file.

Implementation

Future<void> addPageNo() async {
  await _addInkscapeNamespace(pathTo);

  const xPos = 40;
  final yPos = size!.height + 20;
  final svgPageNo = '''
  <text
   xml:space="preserve"
   style="font-style:normal;font-weight:normal;font-size:30px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75"
   x="$xPos"
   y="$yPos"
   id="text288"><tspan
     sodipodi:role="line"
     id="tspan286"
     x="$xPos"
     y="$yPos"
     style="font-size:12px;stroke-width:0.75">Page: $pageNo</tspan></text>
</svg>
''';

  await replace(pathTo, '</svg>', svgPageNo);

  final newPageSize = Size.copyFrom(size!)..height = yPos + 10;
  await updatePageHeight(pathTo, size!, newPageSize);
}