David PHAM-VAN

Move Pdf generation settings to PdfSettings

@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 - Reorganize data types 14 - Reorganize data types
15 - Improve Documents conformity 15 - Improve Documents conformity
16 - Make PdfXref a PdfIndirect descendent 16 - Make PdfXref a PdfIndirect descendent
  17 +- Move Pdf generation settings to PdfSettings
17 18
18 ## 3.9.0 19 ## 3.9.0
19 20
@@ -71,11 +71,17 @@ class PdfDocument { @@ -71,11 +71,17 @@ class PdfDocument {
71 PdfPageMode pageMode = PdfPageMode.none, 71 PdfPageMode pageMode = PdfPageMode.none,
72 DeflateCallback? deflate, 72 DeflateCallback? deflate,
73 bool compress = true, 73 bool compress = true,
74 - this.verbose = false,  
75 - this.version = PdfVersion.pdf_1_5,  
76 - }) : deflate = compress ? (deflate ?? defaultDeflate) : null,  
77 - prev = null, 74 + bool verbose = false,
  75 + PdfVersion version = PdfVersion.pdf_1_5,
  76 + }) : prev = null,
78 _objser = 1 { 77 _objser = 1 {
  78 + settings = PdfSettings(
  79 + deflate: compress ? (deflate ?? defaultDeflate) : null,
  80 + verbose: verbose,
  81 + version: version,
  82 + encryptCallback: (input, object) =>
  83 + encryption?.encrypt(input, object) ?? input,
  84 + );
79 // create the catalog 85 // create the catalog
80 catalog = PdfCatalog(this, PdfPageList(this), pageMode: pageMode); 86 catalog = PdfCatalog(this, PdfPageList(this), pageMode: pageMode);
81 } 87 }
@@ -84,10 +90,16 @@ class PdfDocument { @@ -84,10 +90,16 @@ class PdfDocument {
84 this.prev, { 90 this.prev, {
85 DeflateCallback? deflate, 91 DeflateCallback? deflate,
86 bool compress = true, 92 bool compress = true,
87 - this.verbose = false,  
88 - }) : deflate = compress ? (deflate ?? defaultDeflate) : null,  
89 - _objser = prev!.size,  
90 - version = prev.version { 93 + bool verbose = false,
  94 + }) : _objser = prev!.size {
  95 + settings = PdfSettings(
  96 + deflate: compress ? (deflate ?? defaultDeflate) : null,
  97 + verbose: verbose,
  98 + version: prev!.version,
  99 + encryptCallback: (input, object) =>
  100 + encryption?.encrypt(input, object) ?? input,
  101 + );
  102 +
91 // Import the existing document 103 // Import the existing document
92 prev!.mergeDocument(this); 104 prev!.mergeDocument(this);
93 } 105 }
@@ -105,8 +117,12 @@ class PdfDocument { @@ -105,8 +117,12 @@ class PdfDocument {
105 /// This is the Catalog object, which is required by each Pdf Document 117 /// This is the Catalog object, which is required by each Pdf Document
106 late final PdfCatalog catalog; 118 late final PdfCatalog catalog;
107 119
  120 + /// PDF generation settings
  121 + late final PdfSettings settings;
  122 +
108 /// PDF version to generate 123 /// PDF version to generate
109 - final PdfVersion version; 124 + @Deprecated('Use settings.version')
  125 + PdfVersion get version => settings.version;
110 126
111 /// This is the info object. Although this is an optional object, we 127 /// This is the info object. Although this is an optional object, we
112 /// include it. 128 /// include it.
@@ -129,7 +145,8 @@ class PdfDocument { @@ -129,7 +145,8 @@ class PdfDocument {
129 /// Callback to compress the stream in the pdf file. 145 /// Callback to compress the stream in the pdf file.
130 /// Use `deflate: zlib.encode` if using dart:io 146 /// Use `deflate: zlib.encode` if using dart:io
131 /// No compression by default 147 /// No compression by default
132 - final DeflateCallback? deflate; 148 + @Deprecated('Use settings.deflate')
  149 + DeflateCallback? get deflate => settings.deflate;
133 150
134 /// Object used to encrypt the document 151 /// Object used to encrypt the document
135 PdfEncryption? encryption; 152 PdfEncryption? encryption;
@@ -148,10 +165,12 @@ class PdfDocument { @@ -148,10 +165,12 @@ class PdfDocument {
148 165
149 Uint8List? _documentID; 166 Uint8List? _documentID;
150 167
151 - bool get compress => deflate != null; 168 + @Deprecated('Use settings.compress')
  169 + bool get compress => settings.deflate != null;
152 170
153 /// Output a PDF document with comments and formatted data 171 /// Output a PDF document with comments and formatted data
154 - final bool verbose; 172 + @Deprecated('Use settings.verbose')
  173 + bool get verbose => settings.verbose;
155 174
156 /// Generates the document ID 175 /// Generates the document ID
157 Uint8List get documentID { 176 Uint8List get documentID {
@@ -30,7 +30,13 @@ abstract class PdfDataType { @@ -30,7 +30,13 @@ abstract class PdfDataType {
30 30
31 PdfStream _toStream() { 31 PdfStream _toStream() {
32 final s = PdfStream(); 32 final s = PdfStream();
33 - output(PdfObjectBase(objser: 0, params: this), s); 33 + output(
  34 + PdfObjectBase(
  35 + objser: 0,
  36 + params: this,
  37 + settings: const PdfSettings(),
  38 + ),
  39 + s);
34 return s; 40 return s;
35 } 41 }
36 42
@@ -66,9 +66,9 @@ class PdfDictStream extends PdfDict<PdfDataType> { @@ -66,9 +66,9 @@ class PdfDictStream extends PdfDict<PdfDataType> {
66 if (_values.containsKey('/Filter')) { 66 if (_values.containsKey('/Filter')) {
67 // The data is already in the right format 67 // The data is already in the right format
68 _data = data; 68 _data = data;
69 - } else if (compress && o.deflate != null) { 69 + } else if (compress && o.settings.deflate != null) {
70 // Compress the data 70 // Compress the data
71 - final newData = Uint8List.fromList(o.deflate!(data)); 71 + final newData = Uint8List.fromList(o.settings.deflate!(data));
72 if (newData.lengthInBytes < data.lengthInBytes) { 72 if (newData.lengthInBytes < data.lengthInBytes) {
73 _values['/Filter'] = const PdfName('/FlateDecode'); 73 _values['/Filter'] = const PdfName('/FlateDecode');
74 _data = newData; 74 _data = newData;
@@ -87,8 +87,8 @@ class PdfDictStream extends PdfDict<PdfDataType> { @@ -87,8 +87,8 @@ class PdfDictStream extends PdfDict<PdfDataType> {
87 } 87 }
88 } 88 }
89 89
90 - if (encrypt && o.encryptCallback != null) {  
91 - _data = o.encryptCallback!(_data, o); 90 + if (encrypt && o.settings.encryptCallback != null) {
  91 + _data = o.settings.encryptCallback!(_data, o);
92 } 92 }
93 93
94 _values['/Length'] = PdfNum(_data.length); 94 _values['/Length'] = PdfNum(_data.length);
@@ -37,26 +37,17 @@ enum PdfVersion { @@ -37,26 +37,17 @@ enum PdfVersion {
37 pdf_1_5, 37 pdf_1_5,
38 } 38 }
39 39
40 -class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic {  
41 - PdfObjectBase({  
42 - required this.objser,  
43 - this.objgen = 0,  
44 - required this.params, 40 +class PdfSettings {
  41 + const PdfSettings({
45 this.deflate, 42 this.deflate,
46 this.encryptCallback, 43 this.encryptCallback,
47 this.verbose = false, 44 this.verbose = false,
48 this.version = PdfVersion.pdf_1_5, 45 this.version = PdfVersion.pdf_1_5,
49 }); 46 });
50 47
51 - /// This is the unique serial number for this object.  
52 - final int objser;  
53 -  
54 - /// This is the generation number for this object.  
55 - final int objgen;  
56 -  
57 - final T params;  
58 -  
59 - /// Callback used to compress the data 48 + /// Callback to compress the streams in the pdf file.
  49 + /// Use `deflate: zlib.encode` if using dart:io
  50 + /// No compression by default
60 final DeflateCallback? deflate; 51 final DeflateCallback? deflate;
61 52
62 /// Callback used to encrypt the value of a [PdfDictStream] or a [PdfEncStream] 53 /// Callback used to encrypt the value of a [PdfDictStream] or a [PdfEncStream]
@@ -68,12 +59,34 @@ class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic { @@ -68,12 +59,34 @@ class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic {
68 /// PDF version to generate 59 /// PDF version to generate
69 final PdfVersion version; 60 final PdfVersion version;
70 61
  62 + /// Compress the document
  63 + bool get compress => deflate != null;
  64 +}
  65 +
  66 +class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic {
  67 + PdfObjectBase({
  68 + required this.objser,
  69 + this.objgen = 0,
  70 + required this.params,
  71 + required this.settings,
  72 + });
  73 +
  74 + /// This is the unique serial number for this object.
  75 + final int objser;
  76 +
  77 + /// This is the generation number for this object.
  78 + final int objgen;
  79 +
  80 + final T params;
  81 +
  82 + final PdfSettings settings;
  83 +
71 /// Returns the unique serial number in Pdf format 84 /// Returns the unique serial number in Pdf format
72 PdfIndirect ref() => PdfIndirect(objser, objgen); 85 PdfIndirect ref() => PdfIndirect(objser, objgen);
73 86
74 int output(PdfStream s) { 87 int output(PdfStream s) {
75 assert(() { 88 assert(() {
76 - if (verbose) { 89 + if (settings.verbose) {
77 setInsertion(s, 160); 90 setInsertion(s, 160);
78 startStopwatch(); 91 startStopwatch();
79 } 92 }
@@ -86,7 +99,7 @@ class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic { @@ -86,7 +99,7 @@ class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic {
86 s.putString('endobj\n'); 99 s.putString('endobj\n');
87 100
88 assert(() { 101 assert(() {
89 - if (verbose) { 102 + if (settings.verbose) {
90 stopStopwatch(); 103 stopStopwatch();
91 debugFill( 104 debugFill(
92 'Creation time: ${elapsedStopwatch / Duration.microsecondsPerSecond} seconds'); 105 'Creation time: ${elapsedStopwatch / Duration.microsecondsPerSecond} seconds');
@@ -98,7 +111,7 @@ class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic { @@ -98,7 +111,7 @@ class PdfObjectBase<T extends PdfDataType> with PdfDiagnostic {
98 } 111 }
99 112
100 void writeContent(PdfStream s) { 113 void writeContent(PdfStream s) {
101 - params.output(this, s, verbose ? 0 : null); 114 + params.output(this, s, settings.verbose ? 0 : null);
102 s.putByte(0x0a); 115 s.putByte(0x0a);
103 } 116 }
104 } 117 }
@@ -184,11 +184,11 @@ class PdfString extends PdfDataType { @@ -184,11 +184,11 @@ class PdfString extends PdfDataType {
184 184
185 @override 185 @override
186 void output(PdfObjectBase o, PdfStream s, [int? indent]) { 186 void output(PdfObjectBase o, PdfStream s, [int? indent]) {
187 - if (!encrypted || o.encryptCallback == null) { 187 + if (!encrypted || o.settings.encryptCallback == null) {
188 return _output(s, value); 188 return _output(s, value);
189 } 189 }
190 190
191 - final enc = o.encryptCallback!(value, o); 191 + final enc = o.settings.encryptCallback!(value, o);
192 _output(s, enc); 192 _output(s, enc);
193 } 193 }
194 194
@@ -115,7 +115,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -115,7 +115,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
115 @override 115 @override
116 void output(PdfObjectBase o, PdfStream s, [int? indent]) { 116 void output(PdfObjectBase o, PdfStream s, [int? indent]) {
117 String v; 117 String v;
118 - switch (o.version) { 118 + switch (o.settings.version) {
119 case PdfVersion.pdf_1_4: 119 case PdfVersion.pdf_1_4:
120 v = '1.4'; 120 v = '1.4';
121 break; 121 break;
@@ -127,7 +127,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -127,7 +127,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
127 s.putString('%PDF-$v\n'); 127 s.putString('%PDF-$v\n');
128 s.putBytes(const <int>[0x25, 0xC2, 0xA5, 0xC2, 0xB1, 0xC3, 0xAB, 0x0A]); 128 s.putBytes(const <int>[0x25, 0xC2, 0xA5, 0xC2, 0xB1, 0xC3, 0xAB, 0x0A]);
129 assert(() { 129 assert(() {
130 - if (o.verbose) { 130 + if (o.settings.verbose) {
131 setInsertion(s); 131 setInsertion(s);
132 startStopwatch(); 132 startStopwatch();
133 debugFill('Verbose dart_pdf'); 133 debugFill('Verbose dart_pdf');
@@ -146,7 +146,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -146,7 +146,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
146 146
147 params['/Root'] = o.ref(); 147 params['/Root'] = o.ref();
148 148
149 - switch (o.version) { 149 + switch (o.settings.version) {
150 case PdfVersion.pdf_1_4: 150 case PdfVersion.pdf_1_4:
151 xrefOffset = outputLegacy(o, s); 151 xrefOffset = outputLegacy(o, s);
152 break; 152 break;
@@ -156,7 +156,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -156,7 +156,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
156 } 156 }
157 157
158 assert(() { 158 assert(() {
159 - if (o.verbose) { 159 + if (o.settings.verbose) {
160 s.putComment(''); 160 s.putComment('');
161 s.putComment('-' * 78); 161 s.putComment('-' * 78);
162 s.putComment('$runtimeType'); 162 s.putComment('$runtimeType');
@@ -168,7 +168,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -168,7 +168,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
168 s.putString('startxref\n$xrefOffset\n%%EOF\n'); 168 s.putString('startxref\n$xrefOffset\n%%EOF\n');
169 169
170 assert(() { 170 assert(() {
171 - if (o.verbose) { 171 + if (o.settings.verbose) {
172 stopStopwatch(); 172 stopStopwatch();
173 debugFill( 173 debugFill(
174 'Creation time: ${elapsedStopwatch / Duration.microsecondsPerSecond} seconds'); 174 'Creation time: ${elapsedStopwatch / Duration.microsecondsPerSecond} seconds');
@@ -195,10 +195,10 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -195,10 +195,10 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
195 final size = _offsets.last.ser + 1; 195 final size = _offsets.last.ser + 1;
196 196
197 assert(() { 197 assert(() {
198 - if (o.verbose) { 198 + if (o.settings.verbose) {
199 s.putComment(''); 199 s.putComment('');
200 s.putComment('-' * 78); 200 s.putComment('-' * 78);
201 - s.putComment('$runtimeType ${o.version.name}\n$this'); 201 + s.putComment('$runtimeType ${o.settings.version.name}\n$this');
202 } 202 }
203 return true; 203 return true;
204 }()); 204 }());
@@ -237,14 +237,14 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -237,14 +237,14 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
237 237
238 // the trailer object 238 // the trailer object
239 assert(() { 239 assert(() {
240 - if (o.verbose) { 240 + if (o.settings.verbose) {
241 s.putComment(''); 241 s.putComment('');
242 } 242 }
243 return true; 243 return true;
244 }()); 244 }());
245 s.putString('trailer\n'); 245 s.putString('trailer\n');
246 params['/Size'] = PdfNum(size); 246 params['/Size'] = PdfNum(size);
247 - params.output(o, s, o.verbose ? 0 : null); 247 + params.output(o, s, o.settings.verbose ? 0 : null);
248 s.putByte(0x0a); 248 s.putByte(0x0a);
249 249
250 return objOffset; 250 return objOffset;
@@ -304,10 +304,10 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -304,10 +304,10 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
304 304
305 // Write the object 305 // Write the object
306 assert(() { 306 assert(() {
307 - if (o.verbose) { 307 + if (o.settings.verbose) {
308 s.putComment(''); 308 s.putComment('');
309 s.putComment('-' * 78); 309 s.putComment('-' * 78);
310 - s.putComment('$runtimeType ${o.version.name}\n$this'); 310 + s.putComment('$runtimeType ${o.settings.version.name}\n$this');
311 } 311 }
312 return true; 312 return true;
313 }()); 313 }());
@@ -322,9 +322,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic { @@ -322,9 +322,7 @@ class PdfXrefTable extends PdfDataType with PdfDiagnostic {
322 encrypt: false, 322 encrypt: false,
323 values: params.values, 323 values: params.values,
324 ), 324 ),
325 - deflate: o.deflate,  
326 - verbose: o.verbose,  
327 - version: o.version, 325 + settings: o.settings,
328 ).output(s); 326 ).output(s);
329 327
330 return objOffset; 328 return objOffset;
@@ -132,7 +132,7 @@ class PdfGraphics { @@ -132,7 +132,7 @@ class PdfGraphics {
132 void fillPath({bool evenOdd = false}) { 132 void fillPath({bool evenOdd = false}) {
133 var o = 0; 133 var o = 0;
134 assert(() { 134 assert(() {
135 - if (_page.pdfDocument.verbose) { 135 + if (_page.pdfDocument.settings.verbose) {
136 o = _buf.offset; 136 o = _buf.offset;
137 _buf.putString(' ' * (_indent)); 137 _buf.putString(' ' * (_indent));
138 } 138 }
@@ -143,7 +143,7 @@ class PdfGraphics { @@ -143,7 +143,7 @@ class PdfGraphics {
143 _page.altered = true; 143 _page.altered = true;
144 144
145 assert(() { 145 assert(() {
146 - if (_page.pdfDocument.verbose) { 146 + if (_page.pdfDocument.settings.verbose) {
147 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 147 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
148 _buf.putComment('fillPath(evenOdd: $evenOdd)'); 148 _buf.putComment('fillPath(evenOdd: $evenOdd)');
149 } 149 }
@@ -155,7 +155,7 @@ class PdfGraphics { @@ -155,7 +155,7 @@ class PdfGraphics {
155 void strokePath({bool close = false}) { 155 void strokePath({bool close = false}) {
156 var o = 0; 156 var o = 0;
157 assert(() { 157 assert(() {
158 - if (_page.pdfDocument.verbose) { 158 + if (_page.pdfDocument.settings.verbose) {
159 o = _buf.offset; 159 o = _buf.offset;
160 _buf.putString(' ' * (_indent)); 160 _buf.putString(' ' * (_indent));
161 } 161 }
@@ -166,7 +166,7 @@ class PdfGraphics { @@ -166,7 +166,7 @@ class PdfGraphics {
166 _page.altered = true; 166 _page.altered = true;
167 167
168 assert(() { 168 assert(() {
169 - if (_page.pdfDocument.verbose) { 169 + if (_page.pdfDocument.settings.verbose) {
170 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 170 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
171 _buf.putComment('strokePath(close: $close)'); 171 _buf.putComment('strokePath(close: $close)');
172 } 172 }
@@ -177,7 +177,7 @@ class PdfGraphics { @@ -177,7 +177,7 @@ class PdfGraphics {
177 /// Close the path with a line 177 /// Close the path with a line
178 void closePath() { 178 void closePath() {
179 assert(() { 179 assert(() {
180 - if (_page.pdfDocument.verbose) { 180 + if (_page.pdfDocument.settings.verbose) {
181 _buf.putString(' ' * (_indent)); 181 _buf.putString(' ' * (_indent));
182 } 182 }
183 return true; 183 return true;
@@ -187,7 +187,7 @@ class PdfGraphics { @@ -187,7 +187,7 @@ class PdfGraphics {
187 _page.altered = true; 187 _page.altered = true;
188 188
189 assert(() { 189 assert(() {
190 - if (_page.pdfDocument.verbose) { 190 + if (_page.pdfDocument.settings.verbose) {
191 _buf.putString(' ' * (_commentIndent - 2 - _indent)); 191 _buf.putString(' ' * (_commentIndent - 2 - _indent));
192 _buf.putComment('closePath()'); 192 _buf.putComment('closePath()');
193 } 193 }
@@ -200,7 +200,7 @@ class PdfGraphics { @@ -200,7 +200,7 @@ class PdfGraphics {
200 void clipPath({bool evenOdd = false, bool end = true}) { 200 void clipPath({bool evenOdd = false, bool end = true}) {
201 var o = 0; 201 var o = 0;
202 assert(() { 202 assert(() {
203 - if (_page.pdfDocument.verbose) { 203 + if (_page.pdfDocument.settings.verbose) {
204 o = _buf.offset; 204 o = _buf.offset;
205 _buf.putString(' ' * (_indent)); 205 _buf.putString(' ' * (_indent));
206 } 206 }
@@ -210,7 +210,7 @@ class PdfGraphics { @@ -210,7 +210,7 @@ class PdfGraphics {
210 _buf.putString('W${evenOdd ? '*' : ''}${end ? ' n' : ''} '); 210 _buf.putString('W${evenOdd ? '*' : ''}${end ? ' n' : ''} ');
211 211
212 assert(() { 212 assert(() {
213 - if (_page.pdfDocument.verbose) { 213 + if (_page.pdfDocument.settings.verbose) {
214 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 214 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
215 _buf.putComment('clipPath(evenOdd: $evenOdd, end: $end)'); 215 _buf.putComment('clipPath(evenOdd: $evenOdd, end: $end)');
216 } 216 }
@@ -223,7 +223,7 @@ class PdfGraphics { @@ -223,7 +223,7 @@ class PdfGraphics {
223 void fillAndStrokePath({bool evenOdd = false, bool close = false}) { 223 void fillAndStrokePath({bool evenOdd = false, bool close = false}) {
224 var o = 0; 224 var o = 0;
225 assert(() { 225 assert(() {
226 - if (_page.pdfDocument.verbose) { 226 + if (_page.pdfDocument.settings.verbose) {
227 o = _buf.offset; 227 o = _buf.offset;
228 _buf.putString(' ' * (_indent)); 228 _buf.putString(' ' * (_indent));
229 } 229 }
@@ -234,7 +234,7 @@ class PdfGraphics { @@ -234,7 +234,7 @@ class PdfGraphics {
234 _page.altered = true; 234 _page.altered = true;
235 235
236 assert(() { 236 assert(() {
237 - if (_page.pdfDocument.verbose) { 237 + if (_page.pdfDocument.settings.verbose) {
238 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 238 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
239 _buf.putComment('fillAndStrokePath(evenOdd:$evenOdd, close:$close)'); 239 _buf.putComment('fillAndStrokePath(evenOdd:$evenOdd, close:$close)');
240 } 240 }
@@ -246,7 +246,7 @@ class PdfGraphics { @@ -246,7 +246,7 @@ class PdfGraphics {
246 void applyShader(PdfShading shader) { 246 void applyShader(PdfShading shader) {
247 var o = 0; 247 var o = 0;
248 assert(() { 248 assert(() {
249 - if (_page.pdfDocument.verbose) { 249 + if (_page.pdfDocument.settings.verbose) {
250 o = _buf.offset; 250 o = _buf.offset;
251 _buf.putString(' ' * (_indent)); 251 _buf.putString(' ' * (_indent));
252 } 252 }
@@ -259,7 +259,7 @@ class PdfGraphics { @@ -259,7 +259,7 @@ class PdfGraphics {
259 _page.altered = true; 259 _page.altered = true;
260 260
261 assert(() { 261 assert(() {
262 - if (_page.pdfDocument.verbose) { 262 + if (_page.pdfDocument.settings.verbose) {
263 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 263 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
264 _buf.putComment('applyShader(${shader.ref()})'); 264 _buf.putComment('applyShader(${shader.ref()})');
265 } 265 }
@@ -276,7 +276,7 @@ class PdfGraphics { @@ -276,7 +276,7 @@ class PdfGraphics {
276 if (_contextQueue.isNotEmpty) { 276 if (_contextQueue.isNotEmpty) {
277 assert(() { 277 assert(() {
278 _indent -= _indentAmount; 278 _indent -= _indentAmount;
279 - if (_page.pdfDocument.verbose) { 279 + if (_page.pdfDocument.settings.verbose) {
280 _buf.putString(' ' * (_indent)); 280 _buf.putString(' ' * (_indent));
281 } 281 }
282 return true; 282 return true;
@@ -287,7 +287,7 @@ class PdfGraphics { @@ -287,7 +287,7 @@ class PdfGraphics {
287 _context = _contextQueue.removeLast(); 287 _context = _contextQueue.removeLast();
288 288
289 assert(() { 289 assert(() {
290 - if (_page.pdfDocument.verbose) { 290 + if (_page.pdfDocument.settings.verbose) {
291 _buf.putString(' ' * (_commentIndent - 2 - _indent)); 291 _buf.putString(' ' * (_commentIndent - 2 - _indent));
292 _buf.putComment('restoreContext()'); 292 _buf.putComment('restoreContext()');
293 } 293 }
@@ -299,7 +299,7 @@ class PdfGraphics { @@ -299,7 +299,7 @@ class PdfGraphics {
299 /// Save the graphic context 299 /// Save the graphic context
300 void saveContext() { 300 void saveContext() {
301 assert(() { 301 assert(() {
302 - if (_page.pdfDocument.verbose) { 302 + if (_page.pdfDocument.settings.verbose) {
303 _buf.putString(' ' * (_indent)); 303 _buf.putString(' ' * (_indent));
304 } 304 }
305 return true; 305 return true;
@@ -307,7 +307,7 @@ class PdfGraphics { @@ -307,7 +307,7 @@ class PdfGraphics {
307 _buf.putString('q '); 307 _buf.putString('q ');
308 _contextQueue.addLast(_context.copy()); 308 _contextQueue.addLast(_context.copy());
309 assert(() { 309 assert(() {
310 - if (_page.pdfDocument.verbose) { 310 + if (_page.pdfDocument.settings.verbose) {
311 _buf.putString(' ' * (_commentIndent - 2 - _indent)); 311 _buf.putString(' ' * (_commentIndent - 2 - _indent));
312 _buf.putComment('saveContext()'); 312 _buf.putComment('saveContext()');
313 } 313 }
@@ -320,7 +320,7 @@ class PdfGraphics { @@ -320,7 +320,7 @@ class PdfGraphics {
320 void drawImage(PdfImage img, double x, double y, [double? w, double? h]) { 320 void drawImage(PdfImage img, double x, double y, [double? w, double? h]) {
321 var o = 0; 321 var o = 0;
322 assert(() { 322 assert(() {
323 - if (_page.pdfDocument.verbose) { 323 + if (_page.pdfDocument.settings.verbose) {
324 o = _buf.offset; 324 o = _buf.offset;
325 _buf.putString(' ' * (_indent)); 325 _buf.putString(' ' * (_indent));
326 } 326 }
@@ -366,7 +366,7 @@ class PdfGraphics { @@ -366,7 +366,7 @@ class PdfGraphics {
366 _page.altered = true; 366 _page.altered = true;
367 367
368 assert(() { 368 assert(() {
369 - if (_page.pdfDocument.verbose) { 369 + if (_page.pdfDocument.settings.verbose) {
370 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 370 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
371 _buf.putComment('drawImage(${img.ref()}, x: $x, y: $y, w: $w, h: $h)'); 371 _buf.putComment('drawImage(${img.ref()}, x: $x, y: $y, w: $w, h: $h)');
372 } 372 }
@@ -403,7 +403,7 @@ class PdfGraphics { @@ -403,7 +403,7 @@ class PdfGraphics {
403 void drawRect(double x, double y, double w, double h) { 403 void drawRect(double x, double y, double w, double h) {
404 var o = 0; 404 var o = 0;
405 assert(() { 405 assert(() {
406 - if (_page.pdfDocument.verbose) { 406 + if (_page.pdfDocument.settings.verbose) {
407 o = _buf.offset; 407 o = _buf.offset;
408 _buf.putString(' ' * (_indent)); 408 _buf.putString(' ' * (_indent));
409 } 409 }
@@ -414,7 +414,7 @@ class PdfGraphics { @@ -414,7 +414,7 @@ class PdfGraphics {
414 _buf.putString(' re '); 414 _buf.putString(' re ');
415 415
416 assert(() { 416 assert(() {
417 - if (_page.pdfDocument.verbose) { 417 + if (_page.pdfDocument.settings.verbose) {
418 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 418 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
419 _buf.putComment('drawRect(x: $x, y: $y, w: $w, h: $h)'); 419 _buf.putComment('drawRect(x: $x, y: $y, w: $w, h: $h)');
420 } 420 }
@@ -453,7 +453,7 @@ class PdfGraphics { @@ -453,7 +453,7 @@ class PdfGraphics {
453 }) { 453 }) {
454 var o = 0; 454 var o = 0;
455 assert(() { 455 assert(() {
456 - if (_page.pdfDocument.verbose) { 456 + if (_page.pdfDocument.settings.verbose) {
457 o = _buf.offset; 457 o = _buf.offset;
458 _buf.putString(' ' * (_indent)); 458 _buf.putString(' ' * (_indent));
459 } 459 }
@@ -486,7 +486,7 @@ class PdfGraphics { @@ -486,7 +486,7 @@ class PdfGraphics {
486 } 486 }
487 487
488 assert(() { 488 assert(() {
489 - if (_page.pdfDocument.verbose) { 489 + if (_page.pdfDocument.settings.verbose) {
490 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 490 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
491 _buf.putComment( 491 _buf.putComment(
492 'setFont(${font.ref()}, size: $size, charSpace: $charSpace, wordSpace: $wordSpace, scale: $scale, mode: ${mode.name}, rise: $rise)'); 492 'setFont(${font.ref()}, size: $size, charSpace: $charSpace, wordSpace: $wordSpace, scale: $scale, mode: ${mode.name}, rise: $rise)');
@@ -509,7 +509,7 @@ class PdfGraphics { @@ -509,7 +509,7 @@ class PdfGraphics {
509 double? rise, 509 double? rise,
510 }) { 510 }) {
511 assert(() { 511 assert(() {
512 - if (_page.pdfDocument.verbose) { 512 + if (_page.pdfDocument.settings.verbose) {
513 _buf.putString(' ' * (_indent)); 513 _buf.putString(' ' * (_indent));
514 } 514 }
515 return true; 515 return true;
@@ -518,7 +518,7 @@ class PdfGraphics { @@ -518,7 +518,7 @@ class PdfGraphics {
518 _buf.putString('BT '); 518 _buf.putString('BT ');
519 519
520 assert(() { 520 assert(() {
521 - if (_page.pdfDocument.verbose) { 521 + if (_page.pdfDocument.settings.verbose) {
522 _buf.putString(' ' * (_commentIndent - 3 - _indent)); 522 _buf.putString(' ' * (_commentIndent - 3 - _indent));
523 _buf.putComment('beginText()'); 523 _buf.putComment('beginText()');
524 _indent += _indentAmount; 524 _indent += _indentAmount;
@@ -535,7 +535,7 @@ class PdfGraphics { @@ -535,7 +535,7 @@ class PdfGraphics {
535 535
536 var o = 0; 536 var o = 0;
537 assert(() { 537 assert(() {
538 - if (_page.pdfDocument.verbose) { 538 + if (_page.pdfDocument.settings.verbose) {
539 o = _buf.offset; 539 o = _buf.offset;
540 _buf.putString(' ' * (_indent)); 540 _buf.putString(' ' * (_indent));
541 } 541 }
@@ -546,7 +546,7 @@ class PdfGraphics { @@ -546,7 +546,7 @@ class PdfGraphics {
546 _buf.putString(' Td '); 546 _buf.putString(' Td ');
547 547
548 assert(() { 548 assert(() {
549 - if (_page.pdfDocument.verbose) { 549 + if (_page.pdfDocument.settings.verbose) {
550 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 550 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
551 _buf.putComment('moveCursor($x, $y)'); 551 _buf.putComment('moveCursor($x, $y)');
552 o = _buf.offset; 552 o = _buf.offset;
@@ -560,7 +560,7 @@ class PdfGraphics { @@ -560,7 +560,7 @@ class PdfGraphics {
560 _buf.putString(']TJ '); 560 _buf.putString(']TJ ');
561 561
562 assert(() { 562 assert(() {
563 - if (_page.pdfDocument.verbose) { 563 + if (_page.pdfDocument.settings.verbose) {
564 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 564 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
565 _buf.putComment('drawString("$s")'); 565 _buf.putComment('drawString("$s")');
566 o = _buf.offset; 566 o = _buf.offset;
@@ -573,7 +573,7 @@ class PdfGraphics { @@ -573,7 +573,7 @@ class PdfGraphics {
573 _buf.putString('ET '); 573 _buf.putString('ET ');
574 574
575 assert(() { 575 assert(() {
576 - if (_page.pdfDocument.verbose) { 576 + if (_page.pdfDocument.settings.verbose) {
577 _buf.putString(' ' * (_commentIndent - 3 - _indent)); 577 _buf.putString(' ' * (_commentIndent - 3 - _indent));
578 _buf.putComment('endText()'); 578 _buf.putComment('endText()');
579 } 579 }
@@ -585,7 +585,7 @@ class PdfGraphics { @@ -585,7 +585,7 @@ class PdfGraphics {
585 585
586 void reset() { 586 void reset() {
587 assert(() { 587 assert(() {
588 - if (_page.pdfDocument.verbose) { 588 + if (_page.pdfDocument.settings.verbose) {
589 _buf.putString(' ' * (_indent)); 589 _buf.putString(' ' * (_indent));
590 } 590 }
591 return true; 591 return true;
@@ -594,7 +594,7 @@ class PdfGraphics { @@ -594,7 +594,7 @@ class PdfGraphics {
594 _buf.putString('0 Tr '); 594 _buf.putString('0 Tr ');
595 595
596 assert(() { 596 assert(() {
597 - if (_page.pdfDocument.verbose) { 597 + if (_page.pdfDocument.settings.verbose) {
598 _buf.putString(' ' * (_commentIndent - 5 - _indent)); 598 _buf.putString(' ' * (_commentIndent - 5 - _indent));
599 _buf.putComment('reset()'); 599 _buf.putComment('reset()');
600 } 600 }
@@ -612,7 +612,7 @@ class PdfGraphics { @@ -612,7 +612,7 @@ class PdfGraphics {
612 void setFillColor(PdfColor? color) { 612 void setFillColor(PdfColor? color) {
613 var o = 0; 613 var o = 0;
614 assert(() { 614 assert(() {
615 - if (_page.pdfDocument.verbose) { 615 + if (_page.pdfDocument.settings.verbose) {
616 o = _buf.offset; 616 o = _buf.offset;
617 _buf.putString(' ' * (_indent)); 617 _buf.putString(' ' * (_indent));
618 } 618 }
@@ -630,7 +630,7 @@ class PdfGraphics { @@ -630,7 +630,7 @@ class PdfGraphics {
630 } 630 }
631 631
632 assert(() { 632 assert(() {
633 - if (_page.pdfDocument.verbose) { 633 + if (_page.pdfDocument.settings.verbose) {
634 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 634 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
635 _buf.putComment('setFillColor(${color?.toHex()})'); 635 _buf.putComment('setFillColor(${color?.toHex()})');
636 } 636 }
@@ -642,7 +642,7 @@ class PdfGraphics { @@ -642,7 +642,7 @@ class PdfGraphics {
642 void setStrokeColor(PdfColor? color) { 642 void setStrokeColor(PdfColor? color) {
643 var o = 0; 643 var o = 0;
644 assert(() { 644 assert(() {
645 - if (_page.pdfDocument.verbose) { 645 + if (_page.pdfDocument.settings.verbose) {
646 o = _buf.offset; 646 o = _buf.offset;
647 _buf.putString(' ' * (_indent)); 647 _buf.putString(' ' * (_indent));
648 } 648 }
@@ -660,7 +660,7 @@ class PdfGraphics { @@ -660,7 +660,7 @@ class PdfGraphics {
660 } 660 }
661 661
662 assert(() { 662 assert(() {
663 - if (_page.pdfDocument.verbose) { 663 + if (_page.pdfDocument.settings.verbose) {
664 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 664 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
665 _buf.putComment('setStrokeColor(${color?.toHex()})'); 665 _buf.putComment('setStrokeColor(${color?.toHex()})');
666 } 666 }
@@ -672,7 +672,7 @@ class PdfGraphics { @@ -672,7 +672,7 @@ class PdfGraphics {
672 void setFillPattern(PdfPattern pattern) { 672 void setFillPattern(PdfPattern pattern) {
673 var o = 0; 673 var o = 0;
674 assert(() { 674 assert(() {
675 - if (_page.pdfDocument.verbose) { 675 + if (_page.pdfDocument.settings.verbose) {
676 o = _buf.offset; 676 o = _buf.offset;
677 _buf.putString(' ' * (_indent)); 677 _buf.putString(' ' * (_indent));
678 } 678 }
@@ -684,7 +684,7 @@ class PdfGraphics { @@ -684,7 +684,7 @@ class PdfGraphics {
684 _buf.putString('/Pattern cs${pattern.name} scn '); 684 _buf.putString('/Pattern cs${pattern.name} scn ');
685 685
686 assert(() { 686 assert(() {
687 - if (_page.pdfDocument.verbose) { 687 + if (_page.pdfDocument.settings.verbose) {
688 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 688 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
689 _buf.putComment('setFillPattern(${pattern.ref()})'); 689 _buf.putComment('setFillPattern(${pattern.ref()})');
690 } 690 }
@@ -696,7 +696,7 @@ class PdfGraphics { @@ -696,7 +696,7 @@ class PdfGraphics {
696 void setStrokePattern(PdfPattern pattern) { 696 void setStrokePattern(PdfPattern pattern) {
697 var o = 0; 697 var o = 0;
698 assert(() { 698 assert(() {
699 - if (_page.pdfDocument.verbose) { 699 + if (_page.pdfDocument.settings.verbose) {
700 o = _buf.offset; 700 o = _buf.offset;
701 _buf.putString(' ' * (_indent)); 701 _buf.putString(' ' * (_indent));
702 } 702 }
@@ -708,7 +708,7 @@ class PdfGraphics { @@ -708,7 +708,7 @@ class PdfGraphics {
708 _buf.putString('/Pattern CS${pattern.name} SCN '); 708 _buf.putString('/Pattern CS${pattern.name} SCN ');
709 709
710 assert(() { 710 assert(() {
711 - if (_page.pdfDocument.verbose) { 711 + if (_page.pdfDocument.settings.verbose) {
712 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 712 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
713 _buf.putComment('setStrokePattern(${pattern.ref()})'); 713 _buf.putComment('setStrokePattern(${pattern.ref()})');
714 } 714 }
@@ -720,7 +720,7 @@ class PdfGraphics { @@ -720,7 +720,7 @@ class PdfGraphics {
720 void setGraphicState(PdfGraphicState state) { 720 void setGraphicState(PdfGraphicState state) {
721 var o = 0; 721 var o = 0;
722 assert(() { 722 assert(() {
723 - if (_page.pdfDocument.verbose) { 723 + if (_page.pdfDocument.settings.verbose) {
724 o = _buf.offset; 724 o = _buf.offset;
725 _buf.putString(' ' * (_indent)); 725 _buf.putString(' ' * (_indent));
726 } 726 }
@@ -731,7 +731,7 @@ class PdfGraphics { @@ -731,7 +731,7 @@ class PdfGraphics {
731 _buf.putString('$name gs '); 731 _buf.putString('$name gs ');
732 732
733 assert(() { 733 assert(() {
734 - if (_page.pdfDocument.verbose) { 734 + if (_page.pdfDocument.settings.verbose) {
735 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 735 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
736 _buf.putComment('setGraphicState($state)'); 736 _buf.putComment('setGraphicState($state)');
737 } 737 }
@@ -743,7 +743,7 @@ class PdfGraphics { @@ -743,7 +743,7 @@ class PdfGraphics {
743 void setTransform(Matrix4 t) { 743 void setTransform(Matrix4 t) {
744 var o = 0; 744 var o = 0;
745 assert(() { 745 assert(() {
746 - if (_page.pdfDocument.verbose) { 746 + if (_page.pdfDocument.settings.verbose) {
747 o = _buf.offset; 747 o = _buf.offset;
748 _buf.putString(' ' * (_indent)); 748 _buf.putString(' ' * (_indent));
749 } 749 }
@@ -757,7 +757,7 @@ class PdfGraphics { @@ -757,7 +757,7 @@ class PdfGraphics {
757 _context.ctm.multiply(t); 757 _context.ctm.multiply(t);
758 758
759 assert(() { 759 assert(() {
760 - if (_page.pdfDocument.verbose) { 760 + if (_page.pdfDocument.settings.verbose) {
761 final n = math.max(0, _commentIndent - _buf.offset + o); 761 final n = math.max(0, _commentIndent - _buf.offset + o);
762 _buf.putString(' ' * n); 762 _buf.putString(' ' * n);
763 _buf.putComment('setTransform($s)'); 763 _buf.putComment('setTransform($s)');
@@ -775,7 +775,7 @@ class PdfGraphics { @@ -775,7 +775,7 @@ class PdfGraphics {
775 void lineTo(double x, double y) { 775 void lineTo(double x, double y) {
776 var o = 0; 776 var o = 0;
777 assert(() { 777 assert(() {
778 - if (_page.pdfDocument.verbose) { 778 + if (_page.pdfDocument.settings.verbose) {
779 o = _buf.offset; 779 o = _buf.offset;
780 _buf.putString(' ' * (_indent)); 780 _buf.putString(' ' * (_indent));
781 } 781 }
@@ -786,7 +786,7 @@ class PdfGraphics { @@ -786,7 +786,7 @@ class PdfGraphics {
786 _buf.putString(' l '); 786 _buf.putString(' l ');
787 787
788 assert(() { 788 assert(() {
789 - if (_page.pdfDocument.verbose) { 789 + if (_page.pdfDocument.settings.verbose) {
790 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 790 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
791 _buf.putComment('lineTo($x, $y)'); 791 _buf.putComment('lineTo($x, $y)');
792 } 792 }
@@ -798,7 +798,7 @@ class PdfGraphics { @@ -798,7 +798,7 @@ class PdfGraphics {
798 void moveTo(double x, double y) { 798 void moveTo(double x, double y) {
799 var o = 0; 799 var o = 0;
800 assert(() { 800 assert(() {
801 - if (_page.pdfDocument.verbose) { 801 + if (_page.pdfDocument.settings.verbose) {
802 o = _buf.offset; 802 o = _buf.offset;
803 _buf.putString(' ' * (_indent)); 803 _buf.putString(' ' * (_indent));
804 } 804 }
@@ -809,7 +809,7 @@ class PdfGraphics { @@ -809,7 +809,7 @@ class PdfGraphics {
809 _buf.putString(' m '); 809 _buf.putString(' m ');
810 810
811 assert(() { 811 assert(() {
812 - if (_page.pdfDocument.verbose) { 812 + if (_page.pdfDocument.settings.verbose) {
813 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 813 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
814 _buf.putComment('moveTo($x, $y)'); 814 _buf.putComment('moveTo($x, $y)');
815 } 815 }
@@ -824,7 +824,7 @@ class PdfGraphics { @@ -824,7 +824,7 @@ class PdfGraphics {
824 double x1, double y1, double x2, double y2, double x3, double y3) { 824 double x1, double y1, double x2, double y2, double x3, double y3) {
825 var o = 0; 825 var o = 0;
826 assert(() { 826 assert(() {
827 - if (_page.pdfDocument.verbose) { 827 + if (_page.pdfDocument.settings.verbose) {
828 o = _buf.offset; 828 o = _buf.offset;
829 _buf.putString(' ' * (_indent)); 829 _buf.putString(' ' * (_indent));
830 } 830 }
@@ -835,7 +835,7 @@ class PdfGraphics { @@ -835,7 +835,7 @@ class PdfGraphics {
835 _buf.putString(' c '); 835 _buf.putString(' c ');
836 836
837 assert(() { 837 assert(() {
838 - if (_page.pdfDocument.verbose) { 838 + if (_page.pdfDocument.settings.verbose) {
839 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 839 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
840 _buf.putComment('curveTo($x1, $y1, $x2, $y2, $x3, $y3)'); 840 _buf.putComment('curveTo($x1, $y1, $x2, $y2, $x3, $y3)');
841 } 841 }
@@ -1001,7 +1001,7 @@ class PdfGraphics { @@ -1001,7 +1001,7 @@ class PdfGraphics {
1001 /// Set line starting and ending cap type 1001 /// Set line starting and ending cap type
1002 void setLineCap(PdfLineCap cap) { 1002 void setLineCap(PdfLineCap cap) {
1003 assert(() { 1003 assert(() {
1004 - if (_page.pdfDocument.verbose) { 1004 + if (_page.pdfDocument.settings.verbose) {
1005 _buf.putString(' ' * (_indent)); 1005 _buf.putString(' ' * (_indent));
1006 } 1006 }
1007 return true; 1007 return true;
@@ -1010,7 +1010,7 @@ class PdfGraphics { @@ -1010,7 +1010,7 @@ class PdfGraphics {
1010 _buf.putString('${cap.index} J '); 1010 _buf.putString('${cap.index} J ');
1011 1011
1012 assert(() { 1012 assert(() {
1013 - if (_page.pdfDocument.verbose) { 1013 + if (_page.pdfDocument.settings.verbose) {
1014 _buf.putString(' ' * (_commentIndent - 4 - _indent)); 1014 _buf.putString(' ' * (_commentIndent - 4 - _indent));
1015 _buf.putComment('setLineCap(${cap.name})'); 1015 _buf.putComment('setLineCap(${cap.name})');
1016 } 1016 }
@@ -1021,7 +1021,7 @@ class PdfGraphics { @@ -1021,7 +1021,7 @@ class PdfGraphics {
1021 /// Set line join type 1021 /// Set line join type
1022 void setLineJoin(PdfLineJoin join) { 1022 void setLineJoin(PdfLineJoin join) {
1023 assert(() { 1023 assert(() {
1024 - if (_page.pdfDocument.verbose) { 1024 + if (_page.pdfDocument.settings.verbose) {
1025 _buf.putString(' ' * (_indent)); 1025 _buf.putString(' ' * (_indent));
1026 } 1026 }
1027 return true; 1027 return true;
@@ -1030,7 +1030,7 @@ class PdfGraphics { @@ -1030,7 +1030,7 @@ class PdfGraphics {
1030 _buf.putString('${join.index} j '); 1030 _buf.putString('${join.index} j ');
1031 1031
1032 assert(() { 1032 assert(() {
1033 - if (_page.pdfDocument.verbose) { 1033 + if (_page.pdfDocument.settings.verbose) {
1034 _buf.putString(' ' * (_commentIndent - 4 - _indent)); 1034 _buf.putString(' ' * (_commentIndent - 4 - _indent));
1035 _buf.putComment('setLineJoin(${join.name})'); 1035 _buf.putComment('setLineJoin(${join.name})');
1036 } 1036 }
@@ -1042,7 +1042,7 @@ class PdfGraphics { @@ -1042,7 +1042,7 @@ class PdfGraphics {
1042 void setLineWidth(double width) { 1042 void setLineWidth(double width) {
1043 var o = 0; 1043 var o = 0;
1044 assert(() { 1044 assert(() {
1045 - if (_page.pdfDocument.verbose) { 1045 + if (_page.pdfDocument.settings.verbose) {
1046 o = _buf.offset; 1046 o = _buf.offset;
1047 _buf.putString(' ' * (_indent)); 1047 _buf.putString(' ' * (_indent));
1048 } 1048 }
@@ -1053,7 +1053,7 @@ class PdfGraphics { @@ -1053,7 +1053,7 @@ class PdfGraphics {
1053 _buf.putString(' w '); 1053 _buf.putString(' w ');
1054 1054
1055 assert(() { 1055 assert(() {
1056 - if (_page.pdfDocument.verbose) { 1056 + if (_page.pdfDocument.settings.verbose) {
1057 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 1057 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
1058 _buf.putComment('setLineWidth($width)'); 1058 _buf.putComment('setLineWidth($width)');
1059 } 1059 }
@@ -1065,7 +1065,7 @@ class PdfGraphics { @@ -1065,7 +1065,7 @@ class PdfGraphics {
1065 void setMiterLimit(double limit) { 1065 void setMiterLimit(double limit) {
1066 var o = 0; 1066 var o = 0;
1067 assert(() { 1067 assert(() {
1068 - if (_page.pdfDocument.verbose) { 1068 + if (_page.pdfDocument.settings.verbose) {
1069 o = _buf.offset; 1069 o = _buf.offset;
1070 _buf.putString(' ' * (_indent)); 1070 _buf.putString(' ' * (_indent));
1071 } 1071 }
@@ -1077,7 +1077,7 @@ class PdfGraphics { @@ -1077,7 +1077,7 @@ class PdfGraphics {
1077 _buf.putString(' M '); 1077 _buf.putString(' M ');
1078 1078
1079 assert(() { 1079 assert(() {
1080 - if (_page.pdfDocument.verbose) { 1080 + if (_page.pdfDocument.settings.verbose) {
1081 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 1081 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
1082 _buf.putComment('setMiterLimit($limit)'); 1082 _buf.putComment('setMiterLimit($limit)');
1083 } 1083 }
@@ -1092,7 +1092,7 @@ class PdfGraphics { @@ -1092,7 +1092,7 @@ class PdfGraphics {
1092 void setLineDashPattern([List<num> array = const <num>[], int phase = 0]) { 1092 void setLineDashPattern([List<num> array = const <num>[], int phase = 0]) {
1093 var o = 0; 1093 var o = 0;
1094 assert(() { 1094 assert(() {
1095 - if (_page.pdfDocument.verbose) { 1095 + if (_page.pdfDocument.settings.verbose) {
1096 o = _buf.offset; 1096 o = _buf.offset;
1097 _buf.putString(' ' * (_indent)); 1097 _buf.putString(' ' * (_indent));
1098 } 1098 }
@@ -1103,7 +1103,7 @@ class PdfGraphics { @@ -1103,7 +1103,7 @@ class PdfGraphics {
1103 _buf.putString(' $phase d '); 1103 _buf.putString(' $phase d ');
1104 1104
1105 assert(() { 1105 assert(() {
1106 - if (_page.pdfDocument.verbose) { 1106 + if (_page.pdfDocument.settings.verbose) {
1107 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 1107 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
1108 _buf.putComment('setLineDashPattern($array, $phase)'); 1108 _buf.putComment('setLineDashPattern($array, $phase)');
1109 } 1109 }
@@ -1114,7 +1114,7 @@ class PdfGraphics { @@ -1114,7 +1114,7 @@ class PdfGraphics {
1114 void markContentBegin(PdfName tag) { 1114 void markContentBegin(PdfName tag) {
1115 var o = 0; 1115 var o = 0;
1116 assert(() { 1116 assert(() {
1117 - if (_page.pdfDocument.verbose) { 1117 + if (_page.pdfDocument.settings.verbose) {
1118 o = _buf.offset; 1118 o = _buf.offset;
1119 _buf.putString(' ' * (_indent)); 1119 _buf.putString(' ' * (_indent));
1120 } 1120 }
@@ -1125,7 +1125,7 @@ class PdfGraphics { @@ -1125,7 +1125,7 @@ class PdfGraphics {
1125 _buf.putString(' BMC '); 1125 _buf.putString(' BMC ');
1126 1126
1127 assert(() { 1127 assert(() {
1128 - if (_page.pdfDocument.verbose) { 1128 + if (_page.pdfDocument.settings.verbose) {
1129 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o)); 1129 _buf.putString(' ' * math.max(0, _commentIndent - _buf.offset + o));
1130 _buf.putComment('markContentBegin($tag)'); 1130 _buf.putComment('markContentBegin($tag)');
1131 } 1131 }
@@ -1135,7 +1135,7 @@ class PdfGraphics { @@ -1135,7 +1135,7 @@ class PdfGraphics {
1135 1135
1136 void markContentEnd() { 1136 void markContentEnd() {
1137 assert(() { 1137 assert(() {
1138 - if (_page.pdfDocument.verbose) { 1138 + if (_page.pdfDocument.settings.verbose) {
1139 _buf.putString(' ' * (_indent)); 1139 _buf.putString(' ' * (_indent));
1140 } 1140 }
1141 return true; 1141 return true;
@@ -1144,7 +1144,7 @@ class PdfGraphics { @@ -1144,7 +1144,7 @@ class PdfGraphics {
1144 _buf.putString('EMC '); 1144 _buf.putString('EMC ');
1145 1145
1146 assert(() { 1146 assert(() {
1147 - if (_page.pdfDocument.verbose) { 1147 + if (_page.pdfDocument.settings.verbose) {
1148 _buf.putString(' ' * (_commentIndent - 4 - _indent)); 1148 _buf.putString(' ' * (_commentIndent - 4 - _indent));
1149 _buf.putComment('markContentEnd()'); 1149 _buf.putComment('markContentEnd()');
1150 } 1150 }
@@ -33,6 +33,7 @@ abstract class PdfObject<T extends PdfDataType> extends PdfObjectBase<T> { @@ -33,6 +33,7 @@ abstract class PdfObject<T extends PdfDataType> extends PdfObjectBase<T> {
33 objser: objser ?? pdfDocument.genSerial(), 33 objser: objser ?? pdfDocument.genSerial(),
34 objgen: objgen, 34 objgen: objgen,
35 params: params, 35 params: params,
  36 + settings: pdfDocument.settings,
36 ) { 37 ) {
37 pdfDocument.objects.add(this); 38 pdfDocument.objects.add(this);
38 } 39 }
@@ -42,18 +43,6 @@ abstract class PdfObject<T extends PdfDataType> extends PdfObjectBase<T> { @@ -42,18 +43,6 @@ abstract class PdfObject<T extends PdfDataType> extends PdfObjectBase<T> {
42 43
43 var inUse = true; 44 var inUse = true;
44 45
45 - @override  
46 - DeflateCallback? get deflate => pdfDocument.deflate;  
47 -  
48 - @override  
49 - PdfEncryptCallback? get encryptCallback => pdfDocument.encryption?.encrypt;  
50 -  
51 - @override  
52 - bool get verbose => pdfDocument.verbose;  
53 -  
54 - @override  
55 - PdfVersion get version => pdfDocument.version;  
56 -  
57 /// Prepare the object to be written to the stream 46 /// Prepare the object to be written to the stream
58 @mustCallSuper 47 @mustCallSuper
59 void prepare() {} 48 void prepare() {}
@@ -38,7 +38,7 @@ class PdfObjectDict extends PdfObject<PdfDict> { @@ -38,7 +38,7 @@ class PdfObjectDict extends PdfObject<PdfDict> {
38 @override 38 @override
39 void writeContent(PdfStream s) { 39 void writeContent(PdfStream s) {
40 if (params.isNotEmpty) { 40 if (params.isNotEmpty) {
41 - params.output(this, s, pdfDocument.verbose ? 0 : null); 41 + params.output(this, s, pdfDocument.settings.verbose ? 0 : null);
42 s.putByte(0x0a); 42 s.putByte(0x0a);
43 } 43 }
44 } 44 }
@@ -40,7 +40,7 @@ class PdfObjectStream extends PdfObjectDict { @@ -40,7 +40,7 @@ class PdfObjectStream extends PdfObjectDict {
40 isBinary: isBinary, 40 isBinary: isBinary,
41 values: params.values, 41 values: params.values,
42 data: buf.output(), 42 data: buf.output(),
43 - ).output(this, s, pdfDocument.verbose ? 0 : null); 43 + ).output(this, s, pdfDocument.settings.verbose ? 0 : null);
44 s.putByte(0x0a); 44 s.putByte(0x0a);
45 } 45 }
46 } 46 }
@@ -52,7 +52,7 @@ class PdfType1Font extends PdfFont { @@ -52,7 +52,7 @@ class PdfType1Font extends PdfFont {
52 }()), 52 }()),
53 super.create(pdfDocument, subtype: '/Type1') { 53 super.create(pdfDocument, subtype: '/Type1') {
54 params['/BaseFont'] = PdfName('/$fontName'); 54 params['/BaseFont'] = PdfName('/$fontName');
55 - if (version.index >= PdfVersion.pdf_1_5.index) { 55 + if (settings.version.index >= PdfVersion.pdf_1_5.index) {
56 params['/FirstChar'] = const PdfNum(0); 56 params['/FirstChar'] = const PdfNum(0);
57 params['/LastChar'] = const PdfNum(256); 57 params['/LastChar'] = const PdfNum(256);
58 params['/Widths'] = PdfArray.fromNum(widths.map((e) => e * 1000)); 58 params['/Widths'] = PdfArray.fromNum(widths.map((e) => e * 1000));
@@ -24,13 +24,15 @@ import 'package:test/test.dart'; @@ -24,13 +24,15 @@ import 'package:test/test.dart';
24 void main() { 24 void main() {
25 test('Pdf Minimal', () async { 25 test('Pdf Minimal', () async {
26 var objser = 1; 26 var objser = 1;
27 - const verbose = true;  
28 - const version = PdfVersion.pdf_1_4; 27 +
  28 + const settings = PdfSettings(
  29 + verbose: true,
  30 + version: PdfVersion.pdf_1_4,
  31 + );
29 32
30 final pages = PdfObjectBase( 33 final pages = PdfObjectBase(
31 objser: objser++, 34 objser: objser++,
32 - verbose: verbose,  
33 - version: version, 35 + settings: settings,
34 params: PdfDict({ 36 params: PdfDict({
35 '/Type': const PdfName('/Pages'), 37 '/Type': const PdfName('/Pages'),
36 '/Count': const PdfNum(1), 38 '/Count': const PdfNum(1),
@@ -38,16 +40,14 @@ void main() { @@ -38,16 +40,14 @@ void main() {
38 40
39 final content = PdfObjectBase( 41 final content = PdfObjectBase(
40 objser: objser++, 42 objser: objser++,
41 - verbose: verbose,  
42 - version: version, 43 + settings: settings,
43 params: PdfDictStream( 44 params: PdfDictStream(
44 data: latin1.encode('30 811.88976 m 200 641.88976 l S'), 45 data: latin1.encode('30 811.88976 m 200 641.88976 l S'),
45 )); 46 ));
46 47
47 final page = PdfObjectBase( 48 final page = PdfObjectBase(
48 objser: objser++, 49 objser: objser++,
49 - verbose: verbose,  
50 - version: version, 50 + settings: settings,
51 params: PdfDict({ 51 params: PdfDict({
52 '/Type': const PdfName('/Page'), 52 '/Type': const PdfName('/Page'),
53 '/Parent': pages.ref(), 53 '/Parent': pages.ref(),
@@ -64,8 +64,7 @@ void main() { @@ -64,8 +64,7 @@ void main() {
64 64
65 final catalog = PdfObjectBase( 65 final catalog = PdfObjectBase(
66 objser: objser++, 66 objser: objser++,
67 - verbose: verbose,  
68 - version: version, 67 + settings: settings,
69 params: PdfDict({ 68 params: PdfDict({
70 '/Type': const PdfName('/Catalog'), 69 '/Type': const PdfName('/Catalog'),
71 '/Pages': pages.ref(), 70 '/Pages': pages.ref(),