David PHAM-VAN

Reset graphic context

@@ -321,6 +321,10 @@ class PdfGraphics { @@ -321,6 +321,10 @@ class PdfGraphics {
321 buf.putString(']TJ ET\n'); 321 buf.putString(']TJ ET\n');
322 } 322 }
323 323
  324 + void reset() {
  325 + buf.putString('0 Tr\n');
  326 + }
  327 +
324 /// Sets the color for drawing 328 /// Sets the color for drawing
325 void setColor(PdfColor color) { 329 void setColor(PdfColor color) {
326 setFillColor(color); 330 setFillColor(color);
@@ -212,8 +212,9 @@ class MultiPage extends Page { @@ -212,8 +212,9 @@ class MultiPage extends Page {
212 pageFormat: pageFormat, 212 pageFormat: pageFormat,
213 index: index == null ? null : (index++), 213 index: index == null ? null : (index++),
214 ); 214 );
215 - context =  
216 - baseContext.copyWith(page: pdfPage, canvas: pdfPage.getGraphics()); 215 + final canvas = pdfPage.getGraphics();
  216 + canvas.reset();
  217 + context = baseContext.copyWith(page: pdfPage, canvas: canvas);
217 218
218 assert(() { 219 assert(() {
219 if (Document.debug) { 220 if (Document.debug) {
@@ -111,6 +111,7 @@ class Page { @@ -111,6 +111,7 @@ class Page {
111 111
112 void postProcess(Document document) { 112 void postProcess(Document document) {
113 final canvas = _pdfPage.getGraphics(); 113 final canvas = _pdfPage.getGraphics();
  114 + canvas.reset();
114 final _margin = margin; 115 final _margin = margin;
115 var constraints = mustRotate 116 var constraints = mustRotate
116 ? BoxConstraints( 117 ? BoxConstraints(