David PHAM-VAN

Improve verbose output

@@ -78,7 +78,8 @@ class PdfDocument { @@ -78,7 +78,8 @@ class PdfDocument {
78 PdfPageMode pageMode = PdfPageMode.none, 78 PdfPageMode pageMode = PdfPageMode.none,
79 DeflateCallback? deflate, 79 DeflateCallback? deflate,
80 bool compress = true, 80 bool compress = true,
81 - this.version = PdfVersion.pdf_1_4, 81 + this.verbose = false,
  82 + this.version = PdfVersion.pdf_1_5,
82 }) : deflate = compress ? (deflate ?? defaultDeflate) : null, 83 }) : deflate = compress ? (deflate ?? defaultDeflate) : null,
83 prev = null, 84 prev = null,
84 _objser = 1 { 85 _objser = 1 {
@@ -93,6 +94,7 @@ class PdfDocument { @@ -93,6 +94,7 @@ class PdfDocument {
93 PdfPageMode pageMode = PdfPageMode.none, 94 PdfPageMode pageMode = PdfPageMode.none,
94 DeflateCallback? deflate, 95 DeflateCallback? deflate,
95 bool compress = true, 96 bool compress = true,
  97 + this.verbose = false,
96 }) : deflate = compress ? (deflate ?? defaultDeflate) : null, 98 }) : deflate = compress ? (deflate ?? defaultDeflate) : null,
97 _objser = prev!.size, 99 _objser = prev!.size,
98 version = prev.version { 100 version = prev.version {
@@ -163,6 +165,8 @@ class PdfDocument { @@ -163,6 +165,8 @@ class PdfDocument {
163 165
164 bool get compress => deflate != null; 166 bool get compress => deflate != null;
165 167
  168 + final bool verbose;
  169 +
166 /// Generates the document ID 170 /// Generates the document ID
167 Uint8List get documentID { 171 Uint8List get documentID {
168 if (_documentID == null) { 172 if (_documentID == null) {
@@ -205,7 +209,7 @@ class PdfDocument { @@ -205,7 +209,7 @@ class PdfDocument {
205 209
206 /// This writes the document to an OutputStream. 210 /// This writes the document to an OutputStream.
207 Future<void> _write(PdfStream os) async { 211 Future<void> _write(PdfStream os) async {
208 - final pos = PdfOutput(os, version, compress); 212 + final pos = PdfOutput(os, version, verbose);
209 213
210 // Write each object to the [PdfStream]. We call via the output 214 // Write each object to the [PdfStream]. We call via the output
211 // as that builds the xref table 215 // as that builds the xref table
@@ -123,7 +123,7 @@ class PdfGraphics { @@ -123,7 +123,7 @@ class PdfGraphics {
123 /// set evenOdd to false to use the nonzero winding number rule to determine the region to fill and to true to use the even-odd rule to determine the region to fill 123 /// set evenOdd to false to use the nonzero winding number rule to determine the region to fill and to true to use the even-odd rule to determine the region to fill
124 void fillPath({bool evenOdd = false}) { 124 void fillPath({bool evenOdd = false}) {
125 assert(() { 125 assert(() {
126 - if (!_page.pdfDocument.compress) { 126 + if (_page.pdfDocument.verbose) {
127 _buf.putComment('fillPath evenOdd:$evenOdd'); 127 _buf.putComment('fillPath evenOdd:$evenOdd');
128 } 128 }
129 return true; 129 return true;
@@ -135,7 +135,7 @@ class PdfGraphics { @@ -135,7 +135,7 @@ class PdfGraphics {
135 /// Draw the contour of the previously defined shape 135 /// Draw the contour of the previously defined shape
136 void strokePath({bool close = false}) { 136 void strokePath({bool close = false}) {
137 assert(() { 137 assert(() {
138 - if (!_page.pdfDocument.compress) { 138 + if (_page.pdfDocument.verbose) {
139 _buf.putComment('strokePath close:$close'); 139 _buf.putComment('strokePath close:$close');
140 } 140 }
141 return true; 141 return true;
@@ -147,7 +147,7 @@ class PdfGraphics { @@ -147,7 +147,7 @@ class PdfGraphics {
147 /// Close the path with a line 147 /// Close the path with a line
148 void closePath() { 148 void closePath() {
149 assert(() { 149 assert(() {
150 - if (!_page.pdfDocument.compress) { 150 + if (_page.pdfDocument.verbose) {
151 _buf.putComment('closePath'); 151 _buf.putComment('closePath');
152 } 152 }
153 return true; 153 return true;
@@ -160,7 +160,7 @@ class PdfGraphics { @@ -160,7 +160,7 @@ class PdfGraphics {
160 /// to prevent any further drawing outside 160 /// to prevent any further drawing outside
161 void clipPath({bool evenOdd = false, bool end = true}) { 161 void clipPath({bool evenOdd = false, bool end = true}) {
162 assert(() { 162 assert(() {
163 - if (!_page.pdfDocument.compress) { 163 + if (_page.pdfDocument.verbose) {
164 _buf.putComment('clipPath evenOdd:$evenOdd end:$end'); 164 _buf.putComment('clipPath evenOdd:$evenOdd end:$end');
165 } 165 }
166 return true; 166 return true;
@@ -173,7 +173,7 @@ class PdfGraphics { @@ -173,7 +173,7 @@ class PdfGraphics {
173 /// set evenOdd to false to use the nonzero winding number rule to determine the region to fill and to true to use the even-odd rule to determine the region to fill 173 /// set evenOdd to false to use the nonzero winding number rule to determine the region to fill and to true to use the even-odd rule to determine the region to fill
174 void fillAndStrokePath({bool evenOdd = false, bool close = false}) { 174 void fillAndStrokePath({bool evenOdd = false, bool close = false}) {
175 assert(() { 175 assert(() {
176 - if (!_page.pdfDocument.compress) { 176 + if (_page.pdfDocument.verbose) {
177 _buf.putComment('fillAndStrokePath evenOdd:$evenOdd close:$close'); 177 _buf.putComment('fillAndStrokePath evenOdd:$evenOdd close:$close');
178 } 178 }
179 return true; 179 return true;
@@ -185,7 +185,7 @@ class PdfGraphics { @@ -185,7 +185,7 @@ class PdfGraphics {
185 /// Apply a shader 185 /// Apply a shader
186 void applyShader(PdfShading shader) { 186 void applyShader(PdfShading shader) {
187 assert(() { 187 assert(() {
188 - if (!_page.pdfDocument.compress) { 188 + if (_page.pdfDocument.verbose) {
189 _buf.putComment('applyShader'); 189 _buf.putComment('applyShader');
190 } 190 }
191 return true; 191 return true;
@@ -203,7 +203,7 @@ class PdfGraphics { @@ -203,7 +203,7 @@ class PdfGraphics {
203 /// which will draw over this one. 203 /// which will draw over this one.
204 void restoreContext() { 204 void restoreContext() {
205 assert(() { 205 assert(() {
206 - if (!_page.pdfDocument.compress) { 206 + if (_page.pdfDocument.verbose) {
207 _buf.putComment('restoreContext'); 207 _buf.putComment('restoreContext');
208 } 208 }
209 return true; 209 return true;
@@ -219,7 +219,7 @@ class PdfGraphics { @@ -219,7 +219,7 @@ class PdfGraphics {
219 /// Save the graphc context 219 /// Save the graphc context
220 void saveContext() { 220 void saveContext() {
221 assert(() { 221 assert(() {
222 - if (!_page.pdfDocument.compress) { 222 + if (_page.pdfDocument.verbose) {
223 _buf.putComment('saveContext'); 223 _buf.putComment('saveContext');
224 } 224 }
225 return true; 225 return true;
@@ -232,7 +232,7 @@ class PdfGraphics { @@ -232,7 +232,7 @@ class PdfGraphics {
232 /// Draws an image onto the page. 232 /// Draws an image onto the page.
233 void drawImage(PdfImage img, double x, double y, [double? w, double? h]) { 233 void drawImage(PdfImage img, double x, double y, [double? w, double? h]) {
234 assert(() { 234 assert(() {
235 - if (!_page.pdfDocument.compress) { 235 + if (_page.pdfDocument.verbose) {
236 _buf.putComment('drawImage x:$x y:$y'); 236 _buf.putComment('drawImage x:$x y:$y');
237 } 237 }
238 return true; 238 return true;
@@ -279,7 +279,7 @@ class PdfGraphics { @@ -279,7 +279,7 @@ class PdfGraphics {
279 /// Draws a line between two coordinates. 279 /// Draws a line between two coordinates.
280 void drawLine(double x1, double y1, double x2, double y2) { 280 void drawLine(double x1, double y1, double x2, double y2) {
281 assert(() { 281 assert(() {
282 - if (!_page.pdfDocument.compress) { 282 + if (_page.pdfDocument.verbose) {
283 _buf.putComment('drawLine x1:$x1 y1:$y1 x2:$x2 y2:$y2'); 283 _buf.putComment('drawLine x1:$x1 y1:$y1 x2:$x2 y2:$y2');
284 } 284 }
285 return true; 285 return true;
@@ -295,7 +295,7 @@ class PdfGraphics { @@ -295,7 +295,7 @@ class PdfGraphics {
295 void drawEllipse(double x, double y, double r1, double r2, 295 void drawEllipse(double x, double y, double r1, double r2,
296 {bool clockwise = true}) { 296 {bool clockwise = true}) {
297 assert(() { 297 assert(() {
298 - if (!_page.pdfDocument.compress) { 298 + if (_page.pdfDocument.verbose) {
299 _buf.putComment('drawEllipse x:$x y:$y r1:$r1 r2:$r2'); 299 _buf.putComment('drawEllipse x:$x y:$y r1:$r1 r2:$r2');
300 } 300 }
301 return true; 301 return true;
@@ -323,7 +323,7 @@ class PdfGraphics { @@ -323,7 +323,7 @@ class PdfGraphics {
323 double h, 323 double h,
324 ) { 324 ) {
325 assert(() { 325 assert(() {
326 - if (!_page.pdfDocument.compress) { 326 + if (_page.pdfDocument.verbose) {
327 _buf.putComment('drawRect x:$x y:$y w:$w h:$h'); 327 _buf.putComment('drawRect x:$x y:$y w:$w h:$h');
328 } 328 }
329 return true; 329 return true;
@@ -341,7 +341,7 @@ class PdfGraphics { @@ -341,7 +341,7 @@ class PdfGraphics {
341 /// Draws a Rounded Rectangle 341 /// Draws a Rounded Rectangle
342 void drawRRect(double x, double y, double w, double h, double rv, double rh) { 342 void drawRRect(double x, double y, double w, double h, double rv, double rh) {
343 assert(() { 343 assert(() {
344 - if (!_page.pdfDocument.compress) { 344 + if (_page.pdfDocument.verbose) {
345 _buf.putComment('drawRRect x:$x y:$y w:$w h:$h rv:$rv rh:$rh'); 345 _buf.putComment('drawRRect x:$x y:$y w:$w h:$h rv:$rv rh:$rh');
346 } 346 }
347 return true; 347 return true;
@@ -370,7 +370,7 @@ class PdfGraphics { @@ -370,7 +370,7 @@ class PdfGraphics {
370 double? rise, 370 double? rise,
371 }) { 371 }) {
372 assert(() { 372 assert(() {
373 - if (!_page.pdfDocument.compress) { 373 + if (_page.pdfDocument.verbose) {
374 _buf.putComment('setFont'); 374 _buf.putComment('setFont');
375 } 375 }
376 return true; 376 return true;
@@ -414,7 +414,7 @@ class PdfGraphics { @@ -414,7 +414,7 @@ class PdfGraphics {
414 double rise = 0, 414 double rise = 0,
415 }) { 415 }) {
416 assert(() { 416 assert(() {
417 - if (!_page.pdfDocument.compress) { 417 + if (_page.pdfDocument.verbose) {
418 _buf.putComment('drawString x:$x y:$y size:$size "$s"'); 418 _buf.putComment('drawString x:$x y:$y size:$size "$s"');
419 } 419 }
420 return true; 420 return true;
@@ -438,7 +438,7 @@ class PdfGraphics { @@ -438,7 +438,7 @@ class PdfGraphics {
438 438
439 void reset() { 439 void reset() {
440 assert(() { 440 assert(() {
441 - if (!_page.pdfDocument.compress) { 441 + if (_page.pdfDocument.verbose) {
442 _buf.putComment('reset'); 442 _buf.putComment('reset');
443 } 443 }
444 return true; 444 return true;
@@ -456,7 +456,7 @@ class PdfGraphics { @@ -456,7 +456,7 @@ class PdfGraphics {
456 /// Sets the fill color for drawing 456 /// Sets the fill color for drawing
457 void setFillColor(PdfColor? color) { 457 void setFillColor(PdfColor? color) {
458 assert(() { 458 assert(() {
459 - if (!_page.pdfDocument.compress) { 459 + if (_page.pdfDocument.verbose) {
460 _buf.putComment('setFillColor ${color?.toHex()}'); 460 _buf.putComment('setFillColor ${color?.toHex()}');
461 } 461 }
462 return true; 462 return true;
@@ -475,7 +475,7 @@ class PdfGraphics { @@ -475,7 +475,7 @@ class PdfGraphics {
475 /// Sets the stroke color for drawing 475 /// Sets the stroke color for drawing
476 void setStrokeColor(PdfColor? color) { 476 void setStrokeColor(PdfColor? color) {
477 assert(() { 477 assert(() {
478 - if (!_page.pdfDocument.compress) { 478 + if (_page.pdfDocument.verbose) {
479 _buf.putComment('setStrokeColor ${color?.toHex()}'); 479 _buf.putComment('setStrokeColor ${color?.toHex()}');
480 } 480 }
481 return true; 481 return true;
@@ -494,7 +494,7 @@ class PdfGraphics { @@ -494,7 +494,7 @@ class PdfGraphics {
494 /// Sets the fill pattern for drawing 494 /// Sets the fill pattern for drawing
495 void setFillPattern(PdfPattern pattern) { 495 void setFillPattern(PdfPattern pattern) {
496 assert(() { 496 assert(() {
497 - if (!_page.pdfDocument.compress) { 497 + if (_page.pdfDocument.verbose) {
498 _buf.putComment('setFillPattern'); 498 _buf.putComment('setFillPattern');
499 } 499 }
500 return true; 500 return true;
@@ -508,7 +508,7 @@ class PdfGraphics { @@ -508,7 +508,7 @@ class PdfGraphics {
508 /// Sets the stroke pattern for drawing 508 /// Sets the stroke pattern for drawing
509 void setStrokePattern(PdfPattern pattern) { 509 void setStrokePattern(PdfPattern pattern) {
510 assert(() { 510 assert(() {
511 - if (!_page.pdfDocument.compress) { 511 + if (_page.pdfDocument.verbose) {
512 _buf.putComment('setStrokePattern'); 512 _buf.putComment('setStrokePattern');
513 } 513 }
514 return true; 514 return true;
@@ -522,7 +522,7 @@ class PdfGraphics { @@ -522,7 +522,7 @@ class PdfGraphics {
522 /// Set the graphic state for drawing 522 /// Set the graphic state for drawing
523 void setGraphicState(PdfGraphicState state) { 523 void setGraphicState(PdfGraphicState state) {
524 assert(() { 524 assert(() {
525 - if (!_page.pdfDocument.compress) { 525 + if (_page.pdfDocument.verbose) {
526 _buf.putComment('setGraphicState $state'); 526 _buf.putComment('setGraphicState $state');
527 } 527 }
528 return true; 528 return true;
@@ -535,7 +535,7 @@ class PdfGraphics { @@ -535,7 +535,7 @@ class PdfGraphics {
535 /// Set the transformation Matrix 535 /// Set the transformation Matrix
536 void setTransform(Matrix4 t) { 536 void setTransform(Matrix4 t) {
537 assert(() { 537 assert(() {
538 - if (!_page.pdfDocument.compress) { 538 + if (_page.pdfDocument.verbose) {
539 _buf.putComment('setTransform\n$t'); 539 _buf.putComment('setTransform\n$t');
540 } 540 }
541 return true; 541 return true;
@@ -555,7 +555,7 @@ class PdfGraphics { @@ -555,7 +555,7 @@ class PdfGraphics {
555 /// This adds a line segment to the current path 555 /// This adds a line segment to the current path
556 void lineTo(double x, double y) { 556 void lineTo(double x, double y) {
557 assert(() { 557 assert(() {
558 - if (!_page.pdfDocument.compress) { 558 + if (_page.pdfDocument.verbose) {
559 _buf.putComment('lineTo x:$x y:$y'); 559 _buf.putComment('lineTo x:$x y:$y');
560 } 560 }
561 return true; 561 return true;
@@ -568,7 +568,7 @@ class PdfGraphics { @@ -568,7 +568,7 @@ class PdfGraphics {
568 /// This moves the current drawing point. 568 /// This moves the current drawing point.
569 void moveTo(double x, double y) { 569 void moveTo(double x, double y) {
570 assert(() { 570 assert(() {
571 - if (!_page.pdfDocument.compress) { 571 + if (_page.pdfDocument.verbose) {
572 _buf.putComment('moveTo x:$x y:$y'); 572 _buf.putComment('moveTo x:$x y:$y');
573 } 573 }
574 return true; 574 return true;
@@ -584,7 +584,7 @@ class PdfGraphics { @@ -584,7 +584,7 @@ class PdfGraphics {
584 void curveTo( 584 void curveTo(
585 double x1, double y1, double x2, double y2, double x3, double y3) { 585 double x1, double y1, double x2, double y2, double x3, double y3) {
586 assert(() { 586 assert(() {
587 - if (!_page.pdfDocument.compress) { 587 + if (_page.pdfDocument.verbose) {
588 _buf.putComment('curveTo x1:$x1 y1:$y1 x2:$x2 y2:$y2 x3:$x3 y3:$y3'); 588 _buf.putComment('curveTo x1:$x1 y1:$y1 x2:$x2 y2:$y2 x3:$x3 y3:$y3');
589 } 589 }
590 return true; 590 return true;
@@ -752,7 +752,7 @@ class PdfGraphics { @@ -752,7 +752,7 @@ class PdfGraphics {
752 /// Set line starting and ending cap type 752 /// Set line starting and ending cap type
753 void setLineCap(PdfLineCap cap) { 753 void setLineCap(PdfLineCap cap) {
754 assert(() { 754 assert(() {
755 - if (!_page.pdfDocument.compress) { 755 + if (_page.pdfDocument.verbose) {
756 _buf.putComment('setLineCap $cap'); 756 _buf.putComment('setLineCap $cap');
757 } 757 }
758 return true; 758 return true;
@@ -764,7 +764,7 @@ class PdfGraphics { @@ -764,7 +764,7 @@ class PdfGraphics {
764 /// Set line join type 764 /// Set line join type
765 void setLineJoin(PdfLineJoin join) { 765 void setLineJoin(PdfLineJoin join) {
766 assert(() { 766 assert(() {
767 - if (!_page.pdfDocument.compress) { 767 + if (_page.pdfDocument.verbose) {
768 _buf.putComment('setLineJoin $join'); 768 _buf.putComment('setLineJoin $join');
769 } 769 }
770 return true; 770 return true;
@@ -776,7 +776,7 @@ class PdfGraphics { @@ -776,7 +776,7 @@ class PdfGraphics {
776 /// Set line width 776 /// Set line width
777 void setLineWidth(double width) { 777 void setLineWidth(double width) {
778 assert(() { 778 assert(() {
779 - if (!_page.pdfDocument.compress) { 779 + if (_page.pdfDocument.verbose) {
780 _buf.putComment('setLineWidth $width'); 780 _buf.putComment('setLineWidth $width');
781 } 781 }
782 return true; 782 return true;
@@ -789,7 +789,7 @@ class PdfGraphics { @@ -789,7 +789,7 @@ class PdfGraphics {
789 /// Set line joint miter limit, applies if the 789 /// Set line joint miter limit, applies if the
790 void setMiterLimit(double limit) { 790 void setMiterLimit(double limit) {
791 assert(() { 791 assert(() {
792 - if (!_page.pdfDocument.compress) { 792 + if (_page.pdfDocument.verbose) {
793 _buf.putComment('setMiterLimit $limit'); 793 _buf.putComment('setMiterLimit $limit');
794 } 794 }
795 return true; 795 return true;
@@ -806,7 +806,7 @@ class PdfGraphics { @@ -806,7 +806,7 @@ class PdfGraphics {
806 /// Example: [2 1] will create a dash pattern with 2 on, 1 off, 2 on, 1 off, ... 806 /// Example: [2 1] will create a dash pattern with 2 on, 1 off, 2 on, 1 off, ...
807 void setLineDashPattern([List<num> array = const <num>[], int phase = 0]) { 807 void setLineDashPattern([List<num> array = const <num>[], int phase = 0]) {
808 assert(() { 808 assert(() {
809 - if (!_page.pdfDocument.compress) { 809 + if (_page.pdfDocument.verbose) {
810 _buf.putComment('setLineDashPattern $array phase:$phase'); 810 _buf.putComment('setLineDashPattern $array phase:$phase');
811 } 811 }
812 return true; 812 return true;
@@ -818,7 +818,7 @@ class PdfGraphics { @@ -818,7 +818,7 @@ class PdfGraphics {
818 818
819 void markContentBegin(PdfName tag) { 819 void markContentBegin(PdfName tag) {
820 assert(() { 820 assert(() {
821 - if (!_page.pdfDocument.compress) { 821 + if (_page.pdfDocument.verbose) {
822 _buf.putComment('markContentBegin'); 822 _buf.putComment('markContentBegin');
823 } 823 }
824 return true; 824 return true;
@@ -830,7 +830,7 @@ class PdfGraphics { @@ -830,7 +830,7 @@ class PdfGraphics {
830 830
831 void markContentEnd() { 831 void markContentEnd() {
832 assert(() { 832 assert(() {
833 - if (!_page.pdfDocument.compress) { 833 + if (_page.pdfDocument.verbose) {
834 _buf.putComment('markContentEnd'); 834 _buf.putComment('markContentEnd');
835 } 835 }
836 return true; 836 return true;
@@ -61,7 +61,7 @@ abstract class PdfObject<T extends PdfDataType> { @@ -61,7 +61,7 @@ abstract class PdfObject<T extends PdfDataType> {
61 /// OutputStream. This will send the standard header for each object. 61 /// OutputStream. This will send the standard header for each object.
62 void _writeStart(PdfStream os) { 62 void _writeStart(PdfStream os) {
63 assert(() { 63 assert(() {
64 - if (!pdfDocument.compress) { 64 + if (pdfDocument.verbose) {
65 os.putComment(''); 65 os.putComment('');
66 os.putComment('-' * 78); 66 os.putComment('-' * 78);
67 os.putComment('$runtimeType'); 67 os.putComment('$runtimeType');
@@ -73,7 +73,7 @@ abstract class PdfObject<T extends PdfDataType> { @@ -73,7 +73,7 @@ abstract class PdfObject<T extends PdfDataType> {
73 } 73 }
74 74
75 void writeContent(PdfStream os) { 75 void writeContent(PdfStream os) {
76 - params.output(os, pdfDocument.compress ? null : 0); 76 + params.output(os, pdfDocument.verbose ? 0 : null);
77 os.putByte(0x0a); 77 os.putByte(0x0a);
78 } 78 }
79 79
@@ -37,7 +37,7 @@ class PdfObjectDict extends PdfObject<PdfDict> { @@ -37,7 +37,7 @@ class PdfObjectDict extends PdfObject<PdfDict> {
37 @override 37 @override
38 void writeContent(PdfStream os) { 38 void writeContent(PdfStream os) {
39 if (params.isNotEmpty) { 39 if (params.isNotEmpty) {
40 - params.output(os, pdfDocument.compress ? null : 0); 40 + params.output(os, pdfDocument.verbose ? 0 : null);
41 os.putByte(0x0a); 41 os.putByte(0x0a);
42 } 42 }
43 } 43 }
@@ -41,6 +41,6 @@ class PdfObjectStream extends PdfObjectDict { @@ -41,6 +41,6 @@ class PdfObjectStream extends PdfObjectDict {
41 isBinary: isBinary, 41 isBinary: isBinary,
42 values: params.values, 42 values: params.values,
43 data: buf.output(), 43 data: buf.output(),
44 - ).output(os, pdfDocument.compress ? null : 0); 44 + ).output(os, pdfDocument.verbose ? 0 : null);
45 } 45 }
46 } 46 }
@@ -27,7 +27,7 @@ import 'xref.dart'; @@ -27,7 +27,7 @@ import 'xref.dart';
27 /// PDF document writer 27 /// PDF document writer
28 class PdfOutput { 28 class PdfOutput {
29 /// This creates a Pdf [PdfStream] 29 /// This creates a Pdf [PdfStream]
30 - PdfOutput(this.os, this.version, bool compress) { 30 + PdfOutput(this.os, this.version, this.verbose) {
31 String v; 31 String v;
32 switch (version) { 32 switch (version) {
33 case PdfVersion.pdf_1_4: 33 case PdfVersion.pdf_1_4:
@@ -41,7 +41,7 @@ class PdfOutput { @@ -41,7 +41,7 @@ class PdfOutput {
41 os.putString('%PDF-$v\n'); 41 os.putString('%PDF-$v\n');
42 os.putBytes(const <int>[0x25, 0xC2, 0xA5, 0xC2, 0xB1, 0xC3, 0xAB, 0x0A]); 42 os.putBytes(const <int>[0x25, 0xC2, 0xA5, 0xC2, 0xB1, 0xC3, 0xAB, 0x0A]);
43 assert(() { 43 assert(() {
44 - if (!compress) { 44 + if (verbose) {
45 _stopwatch = Stopwatch()..start(); 45 _stopwatch = Stopwatch()..start();
46 os.putComment(''); 46 os.putComment('');
47 os.putComment('Verbose dart_pdf'); 47 os.putComment('Verbose dart_pdf');
@@ -80,6 +80,9 @@ class PdfOutput { @@ -80,6 +80,9 @@ class PdfOutput {
80 /// Generate a compressed cross reference table 80 /// Generate a compressed cross reference table
81 bool get isCompressed => version.index > PdfVersion.pdf_1_4.index; 81 bool get isCompressed => version.index > PdfVersion.pdf_1_4.index;
82 82
  83 + /// Verbose output
  84 + final bool verbose;
  85 +
83 /// This method writes a [PdfObject] to the stream. 86 /// This method writes a [PdfObject] to the stream.
84 void write(PdfObject ob) { 87 void write(PdfObject ob) {
85 // Check the object to see if it's one that is needed later 88 // Check the object to see if it's one that is needed later
@@ -133,18 +136,26 @@ class PdfOutput { @@ -133,18 +136,26 @@ class PdfOutput {
133 if (isCompressed) { 136 if (isCompressed) {
134 xref.outputCompressed(rootID!, os, params); 137 xref.outputCompressed(rootID!, os, params);
135 } else { 138 } else {
  139 + assert(() {
  140 + os.putComment('');
  141 + os.putComment('-' * 78);
  142 + return true;
  143 + }());
136 xref.output(os); 144 xref.output(os);
137 - }  
138 145
139 - if (!isCompressed) {  
140 // the trailer object 146 // the trailer object
  147 + assert(() {
  148 + os.putComment('');
  149 + os.putComment('-' * 78);
  150 + return true;
  151 + }());
141 os.putString('trailer\n'); 152 os.putString('trailer\n');
142 - params.output(os); 153 + params.output(os, verbose ? 0 : null);
143 os.putByte(0x0a); 154 os.putByte(0x0a);
144 } 155 }
145 156
146 assert(() { 157 assert(() {
147 - if (!rootID!.pdfDocument.compress) { 158 + if (rootID!.pdfDocument.verbose) {
148 os.putComment(''); 159 os.putComment('');
149 os.putComment('-' * 78); 160 os.putComment('-' * 78);
150 } 161 }
@@ -155,7 +166,7 @@ class PdfOutput { @@ -155,7 +166,7 @@ class PdfOutput {
155 os.putString('startxref\n$_xref\n%%EOF\n'); 166 os.putString('startxref\n$_xref\n%%EOF\n');
156 167
157 assert(() { 168 assert(() {
158 - if (!rootID!.pdfDocument.compress) { 169 + if (verbose) {
159 _stopwatch.stop(); 170 _stopwatch.stop();
160 final h = PdfStream(); 171 final h = PdfStream();
161 h.putComment( 172 h.putComment(
@@ -199,7 +199,7 @@ class PdfXrefTable extends PdfDataType { @@ -199,7 +199,7 @@ class PdfXrefTable extends PdfDataType {
199 199
200 // Write the object 200 // Write the object
201 assert(() { 201 assert(() {
202 - if (!object.pdfDocument.compress) { 202 + if (object.pdfDocument.verbose) {
203 s.putComment(''); 203 s.putComment('');
204 s.putComment('-' * 78); 204 s.putComment('-' * 78);
205 s.putComment('$runtimeType $this'); 205 s.putComment('$runtimeType $this');
@@ -214,6 +214,6 @@ class PdfXrefTable extends PdfDataType { @@ -214,6 +214,6 @@ class PdfXrefTable extends PdfDataType {
214 isBinary: false, 214 isBinary: false,
215 encrypt: false, 215 encrypt: false,
216 values: params.values, 216 values: params.values,
217 - ).output(s, object.pdfDocument.compress ? null : 0); 217 + ).output(s, object.pdfDocument.verbose ? 0 : null);
218 } 218 }
219 } 219 }
@@ -27,7 +27,8 @@ class Document { @@ -27,7 +27,8 @@ class Document {
27 PdfPageMode pageMode = PdfPageMode.none, 27 PdfPageMode pageMode = PdfPageMode.none,
28 DeflateCallback? deflate, 28 DeflateCallback? deflate,
29 bool compress = true, 29 bool compress = true,
30 - PdfVersion version = PdfVersion.pdf_1_4, 30 + bool verbose = false,
  31 + PdfVersion version = PdfVersion.pdf_1_5,
31 this.theme, 32 this.theme,
32 String? title, 33 String? title,
33 String? author, 34 String? author,
@@ -40,6 +41,7 @@ class Document { @@ -40,6 +41,7 @@ class Document {
40 pageMode: pageMode, 41 pageMode: pageMode,
41 deflate: deflate, 42 deflate: deflate,
42 compress: compress, 43 compress: compress,
  44 + verbose: verbose,
43 version: version, 45 version: version,
44 ) { 46 ) {
45 if (title != null || 47 if (title != null ||
@@ -68,6 +70,7 @@ class Document { @@ -68,6 +70,7 @@ class Document {
68 PdfPageMode pageMode = PdfPageMode.none, 70 PdfPageMode pageMode = PdfPageMode.none,
69 DeflateCallback? deflate, 71 DeflateCallback? deflate,
70 bool compress = true, 72 bool compress = true,
  73 + bool verbose = false,
71 this.theme, 74 this.theme,
72 String? title, 75 String? title,
73 String? author, 76 String? author,
@@ -80,6 +83,7 @@ class Document { @@ -80,6 +83,7 @@ class Document {
80 pageMode: pageMode, 83 pageMode: pageMode,
81 deflate: deflate, 84 deflate: deflate,
82 compress: compress, 85 compress: compress,
  86 + verbose: verbose,
83 ) { 87 ) {
84 if (title != null || 88 if (title != null ||
85 author != null || 89 author != null ||
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 class print_job { 28 class print_job {
29 private: 29 private:
30 const int index; 30 const int index;
31 - GtkPrintJob* printJob; 31 + GtkPrintJob* printJob = nullptr;
32 32
33 public: 33 public:
34 GtkPrintUnixDialog* dialog = nullptr; 34 GtkPrintUnixDialog* dialog = nullptr;