Showing
25 changed files
with
127 additions
and
138 deletions
@@ -65,7 +65,7 @@ class PdfArray<T extends PdfDataType> extends PdfDataType { | @@ -65,7 +65,7 @@ class PdfArray<T extends PdfDataType> extends PdfDataType { | ||
65 | } | 65 | } |
66 | 66 | ||
67 | @override | 67 | @override |
68 | - void output(PdfStream s, [int? indent]) { | 68 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
69 | if (indent != null) { | 69 | if (indent != null) { |
70 | s.putBytes(List<int>.filled(indent, 0x20)); | 70 | s.putBytes(List<int>.filled(indent, 0x20)); |
71 | indent += kIndentSize; | 71 | indent += kIndentSize; |
@@ -88,7 +88,7 @@ class PdfArray<T extends PdfDataType> extends PdfDataType { | @@ -88,7 +88,7 @@ class PdfArray<T extends PdfDataType> extends PdfDataType { | ||
88 | s.putByte(0x20); | 88 | s.putByte(0x20); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | - val.output(s, indent); | 91 | + val.output(o, s, indent); |
92 | } | 92 | } |
93 | if (indent != null) { | 93 | if (indent != null) { |
94 | s.putByte(0x0a); | 94 | s.putByte(0x0a); |
@@ -18,6 +18,7 @@ import 'dart:typed_data'; | @@ -18,6 +18,7 @@ import 'dart:typed_data'; | ||
18 | 18 | ||
19 | import 'package:meta/meta.dart'; | 19 | import 'package:meta/meta.dart'; |
20 | 20 | ||
21 | +import 'object_base.dart'; | ||
21 | import 'stream.dart'; | 22 | import 'stream.dart'; |
22 | 23 | ||
23 | const kIndentSize = 2; | 24 | const kIndentSize = 2; |
@@ -25,11 +26,11 @@ const kIndentSize = 2; | @@ -25,11 +26,11 @@ const kIndentSize = 2; | ||
25 | abstract class PdfDataType { | 26 | abstract class PdfDataType { |
26 | const PdfDataType(); | 27 | const PdfDataType(); |
27 | 28 | ||
28 | - void output(PdfStream s, [int? indent]); | 29 | + void output(PdfObjectBase o, PdfStream s, [int? indent]); |
29 | 30 | ||
30 | PdfStream _toStream() { | 31 | PdfStream _toStream() { |
31 | final s = PdfStream(); | 32 | final s = PdfStream(); |
32 | - output(s); | 33 | + output(const PdfObjectBase(objser: 0), s); |
33 | return s; | 34 | return s; |
34 | } | 35 | } |
35 | 36 |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'base.dart'; | 17 | import 'base.dart'; |
18 | +import 'object_base.dart'; | ||
18 | import 'stream.dart'; | 19 | import 'stream.dart'; |
19 | 20 | ||
20 | class PdfBool extends PdfDataType { | 21 | class PdfBool extends PdfDataType { |
@@ -23,7 +24,7 @@ class PdfBool extends PdfDataType { | @@ -23,7 +24,7 @@ class PdfBool extends PdfDataType { | ||
23 | final bool value; | 24 | final bool value; |
24 | 25 | ||
25 | @override | 26 | @override |
26 | - void output(PdfStream s, [int? indent]) { | 27 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
27 | s.putString(value ? 'true' : 'false'); | 28 | s.putString(value ? 'true' : 'false'); |
28 | } | 29 | } |
29 | 30 |
@@ -58,7 +58,7 @@ class PdfDict<T extends PdfDataType> extends PdfDataType { | @@ -58,7 +58,7 @@ class PdfDict<T extends PdfDataType> extends PdfDataType { | ||
58 | } | 58 | } |
59 | 59 | ||
60 | @override | 60 | @override |
61 | - void output(PdfStream s, [int? indent]) { | 61 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
62 | if (indent != null) { | 62 | if (indent != null) { |
63 | s.putBytes(List<int>.filled(indent, 0x20)); | 63 | s.putBytes(List<int>.filled(indent, 0x20)); |
64 | } | 64 | } |
@@ -87,7 +87,7 @@ class PdfDict<T extends PdfDataType> extends PdfDataType { | @@ -87,7 +87,7 @@ class PdfDict<T extends PdfDataType> extends PdfDataType { | ||
87 | s.putByte(0x20); | 87 | s.putByte(0x20); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | - v.output(s, indent); | 90 | + v.output(o, s, indent); |
91 | if (indent != null) { | 91 | if (indent != null) { |
92 | s.putByte(0x0a); | 92 | s.putByte(0x0a); |
93 | } | 93 | } |
@@ -26,7 +26,6 @@ import 'stream.dart'; | @@ -26,7 +26,6 @@ import 'stream.dart'; | ||
26 | 26 | ||
27 | class PdfDictStream extends PdfDict<PdfDataType> { | 27 | class PdfDictStream extends PdfDict<PdfDataType> { |
28 | factory PdfDictStream({ | 28 | factory PdfDictStream({ |
29 | - required PdfObjectBase object, | ||
30 | Map<String, PdfDataType>? values, | 29 | Map<String, PdfDataType>? values, |
31 | Uint8List? data, | 30 | Uint8List? data, |
32 | bool isBinary = false, | 31 | bool isBinary = false, |
@@ -34,7 +33,6 @@ class PdfDictStream extends PdfDict<PdfDataType> { | @@ -34,7 +33,6 @@ class PdfDictStream extends PdfDict<PdfDataType> { | ||
34 | bool compress = true, | 33 | bool compress = true, |
35 | }) { | 34 | }) { |
36 | return PdfDictStream.values( | 35 | return PdfDictStream.values( |
37 | - object: object, | ||
38 | values: values ?? {}, | 36 | values: values ?? {}, |
39 | data: data ?? Uint8List(0), | 37 | data: data ?? Uint8List(0), |
40 | encrypt: encrypt, | 38 | encrypt: encrypt, |
@@ -44,7 +42,6 @@ class PdfDictStream extends PdfDict<PdfDataType> { | @@ -44,7 +42,6 @@ class PdfDictStream extends PdfDict<PdfDataType> { | ||
44 | } | 42 | } |
45 | 43 | ||
46 | PdfDictStream.values({ | 44 | PdfDictStream.values({ |
47 | - required this.object, | ||
48 | required Map<String, PdfDataType> values, | 45 | required Map<String, PdfDataType> values, |
49 | required this.data, | 46 | required this.data, |
50 | this.isBinary = false, | 47 | this.isBinary = false, |
@@ -54,8 +51,6 @@ class PdfDictStream extends PdfDict<PdfDataType> { | @@ -54,8 +51,6 @@ class PdfDictStream extends PdfDict<PdfDataType> { | ||
54 | 51 | ||
55 | Uint8List data; | 52 | Uint8List data; |
56 | 53 | ||
57 | - final PdfObjectBase object; | ||
58 | - | ||
59 | final bool isBinary; | 54 | final bool isBinary; |
60 | 55 | ||
61 | final bool encrypt; | 56 | final bool encrypt; |
@@ -63,7 +58,7 @@ class PdfDictStream extends PdfDict<PdfDataType> { | @@ -63,7 +58,7 @@ class PdfDictStream extends PdfDict<PdfDataType> { | ||
63 | final bool compress; | 58 | final bool compress; |
64 | 59 | ||
65 | @override | 60 | @override |
66 | - void output(PdfStream s, [int? indent]) { | 61 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
67 | final _values = PdfDict(values); | 62 | final _values = PdfDict(values); |
68 | 63 | ||
69 | Uint8List? _data; | 64 | Uint8List? _data; |
@@ -71,9 +66,9 @@ class PdfDictStream extends PdfDict<PdfDataType> { | @@ -71,9 +66,9 @@ class PdfDictStream extends PdfDict<PdfDataType> { | ||
71 | if (_values.containsKey('/Filter')) { | 66 | if (_values.containsKey('/Filter')) { |
72 | // The data is already in the right format | 67 | // The data is already in the right format |
73 | _data = data; | 68 | _data = data; |
74 | - } else if (compress && object.deflate != null) { | 69 | + } else if (compress && o.deflate != null) { |
75 | // Compress the data | 70 | // Compress the data |
76 | - final newData = Uint8List.fromList(object.deflate!(data)); | 71 | + final newData = Uint8List.fromList(o.deflate!(data)); |
77 | if (newData.lengthInBytes < data.lengthInBytes) { | 72 | if (newData.lengthInBytes < data.lengthInBytes) { |
78 | _values['/Filter'] = const PdfName('/FlateDecode'); | 73 | _values['/Filter'] = const PdfName('/FlateDecode'); |
79 | _data = newData; | 74 | _data = newData; |
@@ -92,13 +87,13 @@ class PdfDictStream extends PdfDict<PdfDataType> { | @@ -92,13 +87,13 @@ class PdfDictStream extends PdfDict<PdfDataType> { | ||
92 | } | 87 | } |
93 | } | 88 | } |
94 | 89 | ||
95 | - if (encrypt && object.encryptCallback != null) { | ||
96 | - _data = object.encryptCallback!(_data, object); | 90 | + if (encrypt && o.encryptCallback != null) { |
91 | + _data = o.encryptCallback!(_data, o); | ||
97 | } | 92 | } |
98 | 93 | ||
99 | _values['/Length'] = PdfNum(_data.length); | 94 | _values['/Length'] = PdfNum(_data.length); |
100 | 95 | ||
101 | - _values.output(s, indent); | 96 | + _values.output(o, s, indent); |
102 | if (indent != null) { | 97 | if (indent != null) { |
103 | s.putByte(0x0a); | 98 | s.putByte(0x0a); |
104 | } | 99 | } |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'base.dart'; | 17 | import 'base.dart'; |
18 | +import 'object_base.dart'; | ||
18 | import 'stream.dart'; | 19 | import 'stream.dart'; |
19 | 20 | ||
20 | class PdfIndirect extends PdfDataType { | 21 | class PdfIndirect extends PdfDataType { |
@@ -25,7 +26,7 @@ class PdfIndirect extends PdfDataType { | @@ -25,7 +26,7 @@ class PdfIndirect extends PdfDataType { | ||
25 | final int gen; | 26 | final int gen; |
26 | 27 | ||
27 | @override | 28 | @override |
28 | - void output(PdfStream s, [int? indent]) { | 29 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
29 | s.putString('$ser $gen R'); | 30 | s.putString('$ser $gen R'); |
30 | } | 31 | } |
31 | 32 |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'base.dart'; | 17 | import 'base.dart'; |
18 | +import 'object_base.dart'; | ||
18 | import 'stream.dart'; | 19 | import 'stream.dart'; |
19 | 20 | ||
20 | class PdfName extends PdfDataType { | 21 | class PdfName extends PdfDataType { |
@@ -23,7 +24,7 @@ class PdfName extends PdfDataType { | @@ -23,7 +24,7 @@ class PdfName extends PdfDataType { | ||
23 | final String value; | 24 | final String value; |
24 | 25 | ||
25 | @override | 26 | @override |
26 | - void output(PdfStream s, [int? indent]) { | 27 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
27 | assert(value[0] == '/'); | 28 | assert(value[0] == '/'); |
28 | final bytes = <int>[]; | 29 | final bytes = <int>[]; |
29 | for (final c in value.codeUnits) { | 30 | for (final c in value.codeUnits) { |
@@ -15,13 +15,14 @@ | @@ -15,13 +15,14 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'base.dart'; | 17 | import 'base.dart'; |
18 | +import 'object_base.dart'; | ||
18 | import 'stream.dart'; | 19 | import 'stream.dart'; |
19 | 20 | ||
20 | class PdfNull extends PdfDataType { | 21 | class PdfNull extends PdfDataType { |
21 | const PdfNull(); | 22 | const PdfNull(); |
22 | 23 | ||
23 | @override | 24 | @override |
24 | - void output(PdfStream s, [int? indent]) { | 25 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
25 | s.putString('null'); | 26 | s.putString('null'); |
26 | } | 27 | } |
27 | 28 |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'base.dart'; | 17 | import 'base.dart'; |
18 | +import 'object_base.dart'; | ||
18 | import 'stream.dart'; | 19 | import 'stream.dart'; |
19 | 20 | ||
20 | class PdfNum extends PdfDataType { | 21 | class PdfNum extends PdfDataType { |
@@ -27,7 +28,7 @@ class PdfNum extends PdfDataType { | @@ -27,7 +28,7 @@ class PdfNum extends PdfDataType { | ||
27 | final num value; | 28 | final num value; |
28 | 29 | ||
29 | @override | 30 | @override |
30 | - void output(PdfStream s, [int? indent]) { | 31 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
31 | assert(!value.isNaN); | 32 | assert(!value.isNaN); |
32 | assert(!value.isInfinite); | 33 | assert(!value.isInfinite); |
33 | 34 | ||
@@ -72,12 +73,12 @@ class PdfNumList extends PdfDataType { | @@ -72,12 +73,12 @@ class PdfNumList extends PdfDataType { | ||
72 | final List<num> values; | 73 | final List<num> values; |
73 | 74 | ||
74 | @override | 75 | @override |
75 | - void output(PdfStream s, [int? indent]) { | 76 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
76 | for (var n = 0; n < values.length; n++) { | 77 | for (var n = 0; n < values.length; n++) { |
77 | if (n > 0) { | 78 | if (n > 0) { |
78 | s.putByte(0x20); | 79 | s.putByte(0x20); |
79 | } | 80 | } |
80 | - PdfNum(values[n]).output(s, indent); | 81 | + PdfNum(values[n]).output(o, s, indent); |
81 | } | 82 | } |
82 | } | 83 | } |
83 | 84 |
@@ -34,12 +34,17 @@ enum PdfVersion { | @@ -34,12 +34,17 @@ enum PdfVersion { | ||
34 | pdf_1_5, | 34 | pdf_1_5, |
35 | } | 35 | } |
36 | 36 | ||
37 | -mixin PdfObjectBase { | 37 | +class PdfObjectBase { |
38 | + const PdfObjectBase({ | ||
39 | + required this.objser, | ||
40 | + this.objgen = 0, | ||
41 | + }); | ||
42 | + | ||
38 | /// This is the unique serial number for this object. | 43 | /// This is the unique serial number for this object. |
39 | - int get objser; | 44 | + final int objser; |
40 | 45 | ||
41 | /// This is the generation number for this object. | 46 | /// This is the generation number for this object. |
42 | - int get objgen => 0; | 47 | + final int objgen; |
43 | 48 | ||
44 | /// Callback used to compress the data | 49 | /// Callback used to compress the data |
45 | DeflateCallback? get deflate => null; | 50 | DeflateCallback? get deflate => null; |
@@ -167,7 +167,7 @@ class PdfString extends PdfDataType { | @@ -167,7 +167,7 @@ class PdfString extends PdfDataType { | ||
167 | } | 167 | } |
168 | 168 | ||
169 | @override | 169 | @override |
170 | - void output(PdfStream s, [int? indent]) { | 170 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
171 | _output(s, value); | 171 | _output(s, value); |
172 | } | 172 | } |
173 | 173 | ||
@@ -185,51 +185,44 @@ class PdfString extends PdfDataType { | @@ -185,51 +185,44 @@ class PdfString extends PdfDataType { | ||
185 | } | 185 | } |
186 | 186 | ||
187 | class PdfSecString extends PdfString { | 187 | class PdfSecString extends PdfString { |
188 | - const PdfSecString(this.object, Uint8List value, | 188 | + const PdfSecString(Uint8List value, |
189 | [PdfStringFormat format = PdfStringFormat.binary]) | 189 | [PdfStringFormat format = PdfStringFormat.binary]) |
190 | : super(value, format); | 190 | : super(value, format); |
191 | 191 | ||
192 | factory PdfSecString.fromString( | 192 | factory PdfSecString.fromString( |
193 | - PdfObjectBase object, | ||
194 | String value, [ | 193 | String value, [ |
195 | PdfStringFormat format = PdfStringFormat.literal, | 194 | PdfStringFormat format = PdfStringFormat.literal, |
196 | ]) { | 195 | ]) { |
197 | return PdfSecString( | 196 | return PdfSecString( |
198 | - object, | ||
199 | PdfString._string(value), | 197 | PdfString._string(value), |
200 | format, | 198 | format, |
201 | ); | 199 | ); |
202 | } | 200 | } |
203 | 201 | ||
204 | factory PdfSecString.fromStream( | 202 | factory PdfSecString.fromStream( |
205 | - PdfObjectBase object, | ||
206 | PdfStream value, [ | 203 | PdfStream value, [ |
207 | PdfStringFormat format = PdfStringFormat.literal, | 204 | PdfStringFormat format = PdfStringFormat.literal, |
208 | ]) { | 205 | ]) { |
209 | return PdfSecString( | 206 | return PdfSecString( |
210 | - object, | ||
211 | value.output(), | 207 | value.output(), |
212 | format, | 208 | format, |
213 | ); | 209 | ); |
214 | } | 210 | } |
215 | 211 | ||
216 | - factory PdfSecString.fromDate(PdfObjectBase object, DateTime date) { | 212 | + factory PdfSecString.fromDate(DateTime date) { |
217 | return PdfSecString( | 213 | return PdfSecString( |
218 | - object, | ||
219 | PdfString._date(date), | 214 | PdfString._date(date), |
220 | PdfStringFormat.literal, | 215 | PdfStringFormat.literal, |
221 | ); | 216 | ); |
222 | } | 217 | } |
223 | 218 | ||
224 | - final PdfObjectBase object; | ||
225 | - | ||
226 | @override | 219 | @override |
227 | - void output(PdfStream s, [int? indent]) { | ||
228 | - if (object.encryptCallback == null) { | ||
229 | - return super.output(s, indent); | 220 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) { |
221 | + if (o.encryptCallback == null) { | ||
222 | + return super.output(o, s, indent); | ||
230 | } | 223 | } |
231 | 224 | ||
232 | - final enc = object.encryptCallback!(value, object); | 225 | + final enc = o.encryptCallback!(value, o); |
233 | _output(s, enc); | 226 | _output(s, enc); |
234 | } | 227 | } |
235 | } | 228 | } |
@@ -117,7 +117,7 @@ class PdfXrefTable extends PdfDataType { | @@ -117,7 +117,7 @@ class PdfXrefTable extends PdfDataType { | ||
117 | } | 117 | } |
118 | 118 | ||
119 | @override | 119 | @override |
120 | - void output(PdfStream s, [int? indent]) {} | 120 | + void output(PdfObjectBase o, PdfStream s, [int? indent]) {} |
121 | 121 | ||
122 | @override | 122 | @override |
123 | String toString() { | 123 | String toString() { |
@@ -181,7 +181,7 @@ class PdfXrefTable extends PdfDataType { | @@ -181,7 +181,7 @@ class PdfXrefTable extends PdfDataType { | ||
181 | return true; | 181 | return true; |
182 | }()); | 182 | }()); |
183 | s.putString('trailer\n'); | 183 | s.putString('trailer\n'); |
184 | - params.output(s, object.verbose ? 0 : null); | 184 | + params.output(object, s, object.verbose ? 0 : null); |
185 | s.putByte(0x0a); | 185 | s.putByte(0x0a); |
186 | 186 | ||
187 | return objOffset; | 187 | return objOffset; |
@@ -253,12 +253,11 @@ class PdfXrefTable extends PdfDataType { | @@ -253,12 +253,11 @@ class PdfXrefTable extends PdfDataType { | ||
253 | s.putString('$id 0 obj\n'); | 253 | s.putString('$id 0 obj\n'); |
254 | 254 | ||
255 | PdfDictStream( | 255 | PdfDictStream( |
256 | - object: object, | ||
257 | data: o.buffer.asUint8List(), | 256 | data: o.buffer.asUint8List(), |
258 | isBinary: false, | 257 | isBinary: false, |
259 | encrypt: false, | 258 | encrypt: false, |
260 | values: params.values, | 259 | values: params.values, |
261 | - ).output(s, object.verbose ? 0 : null); | 260 | + ).output(object, s, object.verbose ? 0 : null); |
262 | 261 | ||
263 | s.putString('endobj\n'); | 262 | s.putString('endobj\n'); |
264 | return objOffset; | 263 | return objOffset; |
@@ -338,28 +338,28 @@ class PdfGraphics { | @@ -338,28 +338,28 @@ class PdfGraphics { | ||
338 | _buf.putString('q '); | 338 | _buf.putString('q '); |
339 | switch (img.orientation) { | 339 | switch (img.orientation) { |
340 | case PdfImageOrientation.topLeft: | 340 | case PdfImageOrientation.topLeft: |
341 | - PdfNumList(<double>[w, 0, 0, h, x, y]).output(_buf); | 341 | + PdfNumList(<double>[w, 0, 0, h, x, y]).output(_page, _buf); |
342 | break; | 342 | break; |
343 | case PdfImageOrientation.topRight: | 343 | case PdfImageOrientation.topRight: |
344 | - PdfNumList(<double>[-w, 0, 0, h, w + x, y]).output(_buf); | 344 | + PdfNumList(<double>[-w, 0, 0, h, w + x, y]).output(_page, _buf); |
345 | break; | 345 | break; |
346 | case PdfImageOrientation.bottomRight: | 346 | case PdfImageOrientation.bottomRight: |
347 | - PdfNumList(<double>[-w, 0, 0, -h, w + x, h + y]).output(_buf); | 347 | + PdfNumList(<double>[-w, 0, 0, -h, w + x, h + y]).output(_page, _buf); |
348 | break; | 348 | break; |
349 | case PdfImageOrientation.bottomLeft: | 349 | case PdfImageOrientation.bottomLeft: |
350 | - PdfNumList(<double>[w, 0, 0, -h, x, h + y]).output(_buf); | 350 | + PdfNumList(<double>[w, 0, 0, -h, x, h + y]).output(_page, _buf); |
351 | break; | 351 | break; |
352 | case PdfImageOrientation.leftTop: | 352 | case PdfImageOrientation.leftTop: |
353 | - PdfNumList(<double>[0, -h, -w, 0, w + x, h + y]).output(_buf); | 353 | + PdfNumList(<double>[0, -h, -w, 0, w + x, h + y]).output(_page, _buf); |
354 | break; | 354 | break; |
355 | case PdfImageOrientation.rightTop: | 355 | case PdfImageOrientation.rightTop: |
356 | - PdfNumList(<double>[0, -h, w, 0, x, h + y]).output(_buf); | 356 | + PdfNumList(<double>[0, -h, w, 0, x, h + y]).output(_page, _buf); |
357 | break; | 357 | break; |
358 | case PdfImageOrientation.rightBottom: | 358 | case PdfImageOrientation.rightBottom: |
359 | - PdfNumList(<double>[0, h, w, 0, x, y]).output(_buf); | 359 | + PdfNumList(<double>[0, h, w, 0, x, y]).output(_page, _buf); |
360 | break; | 360 | break; |
361 | case PdfImageOrientation.leftBottom: | 361 | case PdfImageOrientation.leftBottom: |
362 | - PdfNumList(<double>[0, h, -w, 0, w + x, y]).output(_buf); | 362 | + PdfNumList(<double>[0, h, -w, 0, w + x, y]).output(_page, _buf); |
363 | break; | 363 | break; |
364 | } | 364 | } |
365 | 365 | ||
@@ -411,7 +411,7 @@ class PdfGraphics { | @@ -411,7 +411,7 @@ class PdfGraphics { | ||
411 | return true; | 411 | return true; |
412 | }()); | 412 | }()); |
413 | 413 | ||
414 | - PdfNumList([x, y, w, h]).output(_buf); | 414 | + PdfNumList([x, y, w, h]).output(_page, _buf); |
415 | _buf.putString(' re '); | 415 | _buf.putString(' re '); |
416 | 416 | ||
417 | assert(() { | 417 | assert(() { |
@@ -464,22 +464,22 @@ class PdfGraphics { | @@ -464,22 +464,22 @@ class PdfGraphics { | ||
464 | _page.addFont(font); | 464 | _page.addFont(font); |
465 | 465 | ||
466 | _buf.putString('${font.name} '); | 466 | _buf.putString('${font.name} '); |
467 | - PdfNum(size).output(_buf); | 467 | + PdfNum(size).output(_page, _buf); |
468 | _buf.putString(' Tf '); | 468 | _buf.putString(' Tf '); |
469 | if (charSpace != null) { | 469 | if (charSpace != null) { |
470 | - PdfNum(charSpace).output(_buf); | 470 | + PdfNum(charSpace).output(_page, _buf); |
471 | _buf.putString(' Tc '); | 471 | _buf.putString(' Tc '); |
472 | } | 472 | } |
473 | if (wordSpace != null) { | 473 | if (wordSpace != null) { |
474 | - PdfNum(wordSpace).output(_buf); | 474 | + PdfNum(wordSpace).output(_page, _buf); |
475 | _buf.putString(' Tw '); | 475 | _buf.putString(' Tw '); |
476 | } | 476 | } |
477 | if (scale != null) { | 477 | if (scale != null) { |
478 | - PdfNum(scale * 100).output(_buf); | 478 | + PdfNum(scale * 100).output(_page, _buf); |
479 | _buf.putString(' Tz '); | 479 | _buf.putString(' Tz '); |
480 | } | 480 | } |
481 | if (rise != null) { | 481 | if (rise != null) { |
482 | - PdfNum(rise).output(_buf); | 482 | + PdfNum(rise).output(_page, _buf); |
483 | _buf.putString(' Ts '); | 483 | _buf.putString(' Ts '); |
484 | } | 484 | } |
485 | if (mode != PdfTextRenderingMode.fill) { | 485 | if (mode != PdfTextRenderingMode.fill) { |
@@ -543,7 +543,7 @@ class PdfGraphics { | @@ -543,7 +543,7 @@ class PdfGraphics { | ||
543 | return true; | 543 | return true; |
544 | }()); | 544 | }()); |
545 | 545 | ||
546 | - PdfNumList([x, y]).output(_buf); | 546 | + PdfNumList([x, y]).output(_page, _buf); |
547 | _buf.putString(' Td '); | 547 | _buf.putString(' Td '); |
548 | 548 | ||
549 | assert(() { | 549 | assert(() { |
@@ -622,10 +622,11 @@ class PdfGraphics { | @@ -622,10 +622,11 @@ class PdfGraphics { | ||
622 | 622 | ||
623 | if (color is PdfColorCmyk) { | 623 | if (color is PdfColorCmyk) { |
624 | PdfNumList(<double>[color.cyan, color.magenta, color.yellow, color.black]) | 624 | PdfNumList(<double>[color.cyan, color.magenta, color.yellow, color.black]) |
625 | - .output(_buf); | 625 | + .output(_page, _buf); |
626 | _buf.putString(' k '); | 626 | _buf.putString(' k '); |
627 | } else { | 627 | } else { |
628 | - PdfNumList(<double>[color!.red, color.green, color.blue]).output(_buf); | 628 | + PdfNumList(<double>[color!.red, color.green, color.blue]) |
629 | + .output(_page, _buf); | ||
629 | _buf.putString(' rg '); | 630 | _buf.putString(' rg '); |
630 | } | 631 | } |
631 | 632 | ||
@@ -651,10 +652,11 @@ class PdfGraphics { | @@ -651,10 +652,11 @@ class PdfGraphics { | ||
651 | 652 | ||
652 | if (color is PdfColorCmyk) { | 653 | if (color is PdfColorCmyk) { |
653 | PdfNumList(<double>[color.cyan, color.magenta, color.yellow, color.black]) | 654 | PdfNumList(<double>[color.cyan, color.magenta, color.yellow, color.black]) |
654 | - .output(_buf); | 655 | + .output(_page, _buf); |
655 | _buf.putString(' K '); | 656 | _buf.putString(' K '); |
656 | } else { | 657 | } else { |
657 | - PdfNumList(<double>[color!.red, color.green, color.blue]).output(_buf); | 658 | + PdfNumList(<double>[color!.red, color.green, color.blue]) |
659 | + .output(_page, _buf); | ||
658 | _buf.putString(' RG '); | 660 | _buf.putString(' RG '); |
659 | } | 661 | } |
660 | 662 | ||
@@ -750,7 +752,8 @@ class PdfGraphics { | @@ -750,7 +752,8 @@ class PdfGraphics { | ||
750 | }()); | 752 | }()); |
751 | 753 | ||
752 | final s = t.storage; | 754 | final s = t.storage; |
753 | - PdfNumList(<double>[s[0], s[1], s[4], s[5], s[12], s[13]]).output(_buf); | 755 | + PdfNumList(<double>[s[0], s[1], s[4], s[5], s[12], s[13]]) |
756 | + .output(_page, _buf); | ||
754 | _buf.putString(' cm '); | 757 | _buf.putString(' cm '); |
755 | _context.ctm.multiply(t); | 758 | _context.ctm.multiply(t); |
756 | 759 | ||
@@ -780,7 +783,7 @@ class PdfGraphics { | @@ -780,7 +783,7 @@ class PdfGraphics { | ||
780 | return true; | 783 | return true; |
781 | }()); | 784 | }()); |
782 | 785 | ||
783 | - PdfNumList([x, y]).output(_buf); | 786 | + PdfNumList([x, y]).output(_page, _buf); |
784 | _buf.putString(' l '); | 787 | _buf.putString(' l '); |
785 | 788 | ||
786 | assert(() { | 789 | assert(() { |
@@ -803,7 +806,7 @@ class PdfGraphics { | @@ -803,7 +806,7 @@ class PdfGraphics { | ||
803 | return true; | 806 | return true; |
804 | }()); | 807 | }()); |
805 | 808 | ||
806 | - PdfNumList([x, y]).output(_buf); | 809 | + PdfNumList([x, y]).output(_page, _buf); |
807 | _buf.putString(' m '); | 810 | _buf.putString(' m '); |
808 | 811 | ||
809 | assert(() { | 812 | assert(() { |
@@ -829,7 +832,7 @@ class PdfGraphics { | @@ -829,7 +832,7 @@ class PdfGraphics { | ||
829 | return true; | 832 | return true; |
830 | }()); | 833 | }()); |
831 | 834 | ||
832 | - PdfNumList([x1, y1, x2, y2, x3, y3]).output(_buf); | 835 | + PdfNumList([x1, y1, x2, y2, x3, y3]).output(_page, _buf); |
833 | _buf.putString(' c '); | 836 | _buf.putString(' c '); |
834 | 837 | ||
835 | assert(() { | 838 | assert(() { |
@@ -1047,7 +1050,7 @@ class PdfGraphics { | @@ -1047,7 +1050,7 @@ class PdfGraphics { | ||
1047 | return true; | 1050 | return true; |
1048 | }()); | 1051 | }()); |
1049 | 1052 | ||
1050 | - PdfNum(width).output(_buf); | 1053 | + PdfNum(width).output(_page, _buf); |
1051 | _buf.putString(' w '); | 1054 | _buf.putString(' w '); |
1052 | 1055 | ||
1053 | assert(() { | 1056 | assert(() { |
@@ -1071,7 +1074,7 @@ class PdfGraphics { | @@ -1071,7 +1074,7 @@ class PdfGraphics { | ||
1071 | }()); | 1074 | }()); |
1072 | 1075 | ||
1073 | assert(limit >= 1.0); | 1076 | assert(limit >= 1.0); |
1074 | - PdfNum(limit).output(_buf); | 1077 | + PdfNum(limit).output(_page, _buf); |
1075 | _buf.putString(' M '); | 1078 | _buf.putString(' M '); |
1076 | 1079 | ||
1077 | assert(() { | 1080 | assert(() { |
@@ -1097,7 +1100,7 @@ class PdfGraphics { | @@ -1097,7 +1100,7 @@ class PdfGraphics { | ||
1097 | return true; | 1100 | return true; |
1098 | }()); | 1101 | }()); |
1099 | 1102 | ||
1100 | - PdfArray.fromNum(array).output(_buf); | 1103 | + PdfArray.fromNum(array).output(_page, _buf); |
1101 | _buf.putString(' $phase d '); | 1104 | _buf.putString(' $phase d '); |
1102 | 1105 | ||
1103 | assert(() { | 1106 | assert(() { |
@@ -1119,7 +1122,7 @@ class PdfGraphics { | @@ -1119,7 +1122,7 @@ class PdfGraphics { | ||
1119 | return true; | 1122 | return true; |
1120 | }()); | 1123 | }()); |
1121 | 1124 | ||
1122 | - tag.output(_buf); | 1125 | + tag.output(_page, _buf); |
1123 | _buf.putString(' BMC '); | 1126 | _buf.putString(' BMC '); |
1124 | 1127 | ||
1125 | assert(() { | 1128 | assert(() { |
@@ -87,7 +87,7 @@ class PdfChoiceField extends PdfAnnotWidget { | @@ -87,7 +87,7 @@ class PdfChoiceField extends PdfAnnotWidget { | ||
87 | g.setFillColor(textColor); | 87 | g.setFillColor(textColor); |
88 | g.setFont(font, fontSize); | 88 | g.setFont(font, fontSize); |
89 | 89 | ||
90 | - params['/DA'] = PdfSecString.fromStream(object, buf); | 90 | + params['/DA'] = PdfSecString.fromStream(buf); |
91 | 91 | ||
92 | // What is /TU? Tooltip? | 92 | // What is /TU? Tooltip? |
93 | //params['/TU'] = PdfString.fromString('Select from list'); | 93 | //params['/TU'] = PdfString.fromString('Select from list'); |
@@ -257,9 +257,9 @@ abstract class PdfAnnotBase { | @@ -257,9 +257,9 @@ abstract class PdfAnnotBase { | ||
257 | [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]]); | 257 | [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]]); |
258 | } | 258 | } |
259 | 259 | ||
260 | - final bbox = boundingBox ?? PdfRect.fromPoints(PdfPoint.zero, rect.size); | 260 | + final bBox = boundingBox ?? PdfRect.fromPoints(PdfPoint.zero, rect.size); |
261 | s.params['/BBox'] = | 261 | s.params['/BBox'] = |
262 | - PdfArray.fromNum([bbox.x, bbox.y, bbox.width, bbox.height]); | 262 | + PdfArray.fromNum([bBox.x, bBox.y, bBox.width, bBox.height]); |
263 | final g = PdfGraphics(s, s.buf); | 263 | final g = PdfGraphics(s, s.buf); |
264 | 264 | ||
265 | if (selected && name != null) { | 265 | if (selected && name != null) { |
@@ -285,11 +285,11 @@ abstract class PdfAnnotBase { | @@ -285,11 +285,11 @@ abstract class PdfAnnotBase { | ||
285 | } | 285 | } |
286 | 286 | ||
287 | if (content != null) { | 287 | if (content != null) { |
288 | - params['/Contents'] = PdfSecString.fromString(object, content!); | 288 | + params['/Contents'] = PdfSecString.fromString(content!); |
289 | } | 289 | } |
290 | 290 | ||
291 | if (name != null) { | 291 | if (name != null) { |
292 | - params['/NM'] = PdfSecString.fromString(object, name!); | 292 | + params['/NM'] = PdfSecString.fromString(name!); |
293 | } | 293 | } |
294 | 294 | ||
295 | if (flags != null && flags!.isNotEmpty) { | 295 | if (flags != null && flags!.isNotEmpty) { |
@@ -297,7 +297,7 @@ abstract class PdfAnnotBase { | @@ -297,7 +297,7 @@ abstract class PdfAnnotBase { | ||
297 | } | 297 | } |
298 | 298 | ||
299 | if (date != null) { | 299 | if (date != null) { |
300 | - params['/M'] = PdfSecString.fromDate(object, date!); | 300 | + params['/M'] = PdfSecString.fromDate(date!); |
301 | } | 301 | } |
302 | 302 | ||
303 | if (color != null) { | 303 | if (color != null) { |
@@ -305,11 +305,11 @@ abstract class PdfAnnotBase { | @@ -305,11 +305,11 @@ abstract class PdfAnnotBase { | ||
305 | } | 305 | } |
306 | 306 | ||
307 | if (subject != null) { | 307 | if (subject != null) { |
308 | - params['/Subj'] = PdfSecString.fromString(object, subject!); | 308 | + params['/Subj'] = PdfSecString.fromString(subject!); |
309 | } | 309 | } |
310 | 310 | ||
311 | if (author != null) { | 311 | if (author != null) { |
312 | - params['/T'] = PdfSecString.fromString(object, author!); | 312 | + params['/T'] = PdfSecString.fromString(author!); |
313 | } | 313 | } |
314 | 314 | ||
315 | if (_appearances.isNotEmpty) { | 315 | if (_appearances.isNotEmpty) { |
@@ -377,7 +377,7 @@ class PdfAnnotNamedLink extends PdfAnnotBase { | @@ -377,7 +377,7 @@ class PdfAnnotNamedLink extends PdfAnnotBase { | ||
377 | params['/A'] = PdfDict( | 377 | params['/A'] = PdfDict( |
378 | { | 378 | { |
379 | '/S': const PdfName('/GoTo'), | 379 | '/S': const PdfName('/GoTo'), |
380 | - '/D': PdfSecString.fromString(object, dest), | 380 | + '/D': PdfSecString.fromString(dest), |
381 | }, | 381 | }, |
382 | ); | 382 | ); |
383 | } | 383 | } |
@@ -413,7 +413,7 @@ class PdfAnnotUrlLink extends PdfAnnotBase { | @@ -413,7 +413,7 @@ class PdfAnnotUrlLink extends PdfAnnotBase { | ||
413 | params['/A'] = PdfDict( | 413 | params['/A'] = PdfDict( |
414 | { | 414 | { |
415 | '/S': const PdfName('/URI'), | 415 | '/S': const PdfName('/URI'), |
416 | - '/URI': PdfSecString.fromString(object, url), | 416 | + '/URI': PdfSecString.fromString(url), |
417 | }, | 417 | }, |
418 | ); | 418 | ); |
419 | } | 419 | } |
@@ -522,13 +522,13 @@ class PdfAnnotPolygon extends PdfAnnotBase { | @@ -522,13 +522,13 @@ class PdfAnnotPolygon extends PdfAnnotBase { | ||
522 | final flippedPoints = | 522 | final flippedPoints = |
523 | points.map((e) => PdfPoint(e.x, rect.height - e.y)).toList(); | 523 | points.map((e) => PdfPoint(e.x, rect.height - e.y)).toList(); |
524 | 524 | ||
525 | - final verticies = <num>[]; | 525 | + final vertices = <num>[]; |
526 | for (var i = 0; i < flippedPoints.length; i++) { | 526 | for (var i = 0; i < flippedPoints.length; i++) { |
527 | - verticies.add(flippedPoints[i].x); | ||
528 | - verticies.add(flippedPoints[i].y); | 527 | + vertices.add(flippedPoints[i].x); |
528 | + vertices.add(flippedPoints[i].y); | ||
529 | } | 529 | } |
530 | 530 | ||
531 | - params['/Vertices'] = PdfArray.fromNum(verticies); | 531 | + params['/Vertices'] = PdfArray.fromNum(vertices); |
532 | 532 | ||
533 | if (interiorColor != null) { | 533 | if (interiorColor != null) { |
534 | params['/IC'] = PdfArray.fromColor(interiorColor!); | 534 | params['/IC'] = PdfArray.fromColor(interiorColor!); |
@@ -573,20 +573,20 @@ class PdfAnnotInk extends PdfAnnotBase { | @@ -573,20 +573,20 @@ class PdfAnnotInk extends PdfAnnotBase { | ||
573 | ) { | 573 | ) { |
574 | super.build(page, object, params); | 574 | super.build(page, object, params); |
575 | 575 | ||
576 | - final verticies = List<List<num>>.filled(points.length, <num>[]); | 576 | + final vertices = List<List<num>>.filled(points.length, <num>[]); |
577 | for (var listIndex = 0; listIndex < points.length; listIndex++) { | 577 | for (var listIndex = 0; listIndex < points.length; listIndex++) { |
578 | // Flip the points on the Y axis. | 578 | // Flip the points on the Y axis. |
579 | final flippedPoints = points[listIndex] | 579 | final flippedPoints = points[listIndex] |
580 | .map((e) => PdfPoint(e.x, rect.height - e.y)) | 580 | .map((e) => PdfPoint(e.x, rect.height - e.y)) |
581 | .toList(); | 581 | .toList(); |
582 | for (var i = 0; i < flippedPoints.length; i++) { | 582 | for (var i = 0; i < flippedPoints.length; i++) { |
583 | - verticies[listIndex].add(flippedPoints[i].x); | ||
584 | - verticies[listIndex].add(flippedPoints[i].y); | 583 | + vertices[listIndex].add(flippedPoints[i].x); |
584 | + vertices[listIndex].add(flippedPoints[i].y); | ||
585 | } | 585 | } |
586 | } | 586 | } |
587 | 587 | ||
588 | params['/InkList'] = | 588 | params['/InkList'] = |
589 | - PdfArray(verticies.map((v) => PdfArray.fromNum(v)).toList()); | 589 | + PdfArray(vertices.map((v) => PdfArray.fromNum(v)).toList()); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
@@ -632,7 +632,7 @@ abstract class PdfAnnotWidget extends PdfAnnotBase { | @@ -632,7 +632,7 @@ abstract class PdfAnnotWidget extends PdfAnnotBase { | ||
632 | params['/FT'] = PdfName(fieldType); | 632 | params['/FT'] = PdfName(fieldType); |
633 | 633 | ||
634 | if (fieldName != null) { | 634 | if (fieldName != null) { |
635 | - params['/T'] = PdfSecString.fromString(object, fieldName!); | 635 | + params['/T'] = PdfSecString.fromString(fieldName!); |
636 | } | 636 | } |
637 | 637 | ||
638 | final mk = PdfDict(); | 638 | final mk = PdfDict(); |
@@ -847,10 +847,10 @@ class PdfFormField extends PdfAnnotWidget { | @@ -847,10 +847,10 @@ class PdfFormField extends PdfAnnotWidget { | ||
847 | void build(PdfPage page, PdfObject object, PdfDict params) { | 847 | void build(PdfPage page, PdfObject object, PdfDict params) { |
848 | super.build(page, object, params); | 848 | super.build(page, object, params); |
849 | if (alternateName != null) { | 849 | if (alternateName != null) { |
850 | - params['/TU'] = PdfSecString.fromString(object, alternateName!); | 850 | + params['/TU'] = PdfSecString.fromString(alternateName!); |
851 | } | 851 | } |
852 | if (mappingName != null) { | 852 | if (mappingName != null) { |
853 | - params['/TM'] = PdfSecString.fromString(object, mappingName!); | 853 | + params['/TM'] = PdfSecString.fromString(mappingName!); |
854 | } | 854 | } |
855 | 855 | ||
856 | params['/Ff'] = PdfNum(fieldFlagsValue); | 856 | params['/Ff'] = PdfNum(fieldFlagsValue); |
@@ -923,13 +923,13 @@ class PdfTextField extends PdfFormField { | @@ -923,13 +923,13 @@ class PdfTextField extends PdfFormField { | ||
923 | final g = PdfGraphics(page, buf); | 923 | final g = PdfGraphics(page, buf); |
924 | g.setFillColor(textColor); | 924 | g.setFillColor(textColor); |
925 | g.setFont(font, fontSize); | 925 | g.setFont(font, fontSize); |
926 | - params['/DA'] = PdfSecString.fromStream(object, buf); | 926 | + params['/DA'] = PdfSecString.fromStream(buf); |
927 | 927 | ||
928 | if (value != null) { | 928 | if (value != null) { |
929 | - params['/V'] = PdfSecString.fromString(object, value!); | 929 | + params['/V'] = PdfSecString.fromString(value!); |
930 | } | 930 | } |
931 | if (defaultValue != null) { | 931 | if (defaultValue != null) { |
932 | - params['/DV'] = PdfSecString.fromString(object, defaultValue!); | 932 | + params['/DV'] = PdfSecString.fromString(defaultValue!); |
933 | } | 933 | } |
934 | if (textAlign != null) { | 934 | if (textAlign != null) { |
935 | params['/Q'] = PdfNum(textAlign!.index); | 935 | params['/Q'] = PdfNum(textAlign!.index); |
@@ -195,7 +195,8 @@ See https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management | @@ -195,7 +195,8 @@ See https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management | ||
195 | /// Draw some text | 195 | /// Draw some text |
196 | void putText(PdfStream stream, String text) { | 196 | void putText(PdfStream stream, String text) { |
197 | try { | 197 | try { |
198 | - PdfString(latin1.encode(text), PdfStringFormat.literal).output(stream); | 198 | + PdfString(latin1.encode(text), PdfStringFormat.literal) |
199 | + .output(this, stream); | ||
199 | } catch (_) { | 200 | } catch (_) { |
200 | assert(() { | 201 | assert(() { |
201 | print(_cannotDecodeMessage); | 202 | print(_cannotDecodeMessage); |
@@ -30,28 +30,28 @@ class PdfInfo extends PdfObjectDict { | @@ -30,28 +30,28 @@ class PdfInfo extends PdfObjectDict { | ||
30 | this.producer}) | 30 | this.producer}) |
31 | : super(pdfDocument) { | 31 | : super(pdfDocument) { |
32 | if (author != null) { | 32 | if (author != null) { |
33 | - params['/Author'] = PdfSecString.fromString(this, author!); | 33 | + params['/Author'] = PdfSecString.fromString(author!); |
34 | } | 34 | } |
35 | if (creator != null) { | 35 | if (creator != null) { |
36 | - params['/Creator'] = PdfSecString.fromString(this, creator!); | 36 | + params['/Creator'] = PdfSecString.fromString(creator!); |
37 | } | 37 | } |
38 | if (title != null) { | 38 | if (title != null) { |
39 | - params['/Title'] = PdfSecString.fromString(this, title!); | 39 | + params['/Title'] = PdfSecString.fromString(title!); |
40 | } | 40 | } |
41 | if (subject != null) { | 41 | if (subject != null) { |
42 | - params['/Subject'] = PdfSecString.fromString(this, subject!); | 42 | + params['/Subject'] = PdfSecString.fromString(subject!); |
43 | } | 43 | } |
44 | if (keywords != null) { | 44 | if (keywords != null) { |
45 | - params['/Keywords'] = PdfSecString.fromString(this, keywords!); | 45 | + params['/Keywords'] = PdfSecString.fromString(keywords!); |
46 | } | 46 | } |
47 | if (producer != null) { | 47 | if (producer != null) { |
48 | params['/Producer'] = | 48 | params['/Producer'] = |
49 | - PdfSecString.fromString(this, '$producer ($_libraryName)'); | 49 | + PdfSecString.fromString('$producer ($_libraryName)'); |
50 | } else { | 50 | } else { |
51 | - params['/Producer'] = PdfSecString.fromString(this, _libraryName); | 51 | + params['/Producer'] = PdfSecString.fromString(_libraryName); |
52 | } | 52 | } |
53 | 53 | ||
54 | - params['/CreationDate'] = PdfSecString.fromDate(this, DateTime.now()); | 54 | + params['/CreationDate'] = PdfSecString.fromDate(DateTime.now()); |
55 | } | 55 | } |
56 | 56 | ||
57 | static const String _libraryName = 'https://github.com/DavBfr/dart_pdf'; | 57 | static const String _libraryName = 'https://github.com/DavBfr/dart_pdf'; |
@@ -33,7 +33,6 @@ class PdfMetadata extends PdfObject<PdfDictStream> { | @@ -33,7 +33,6 @@ class PdfMetadata extends PdfObject<PdfDictStream> { | ||
33 | ) : super( | 33 | ) : super( |
34 | pdfDocument, | 34 | pdfDocument, |
35 | params: PdfDictStream( | 35 | params: PdfDictStream( |
36 | - object: pdfDocument.catalog, | ||
37 | compress: false, | 36 | compress: false, |
38 | encrypt: false, | 37 | encrypt: false, |
39 | ), | 38 | ), |
@@ -62,7 +62,7 @@ class PdfNames extends PdfObjectDict { | @@ -62,7 +62,7 @@ class PdfNames extends PdfObjectDict { | ||
62 | final keys = _dests.keys.toList()..sort(); | 62 | final keys = _dests.keys.toList()..sort(); |
63 | 63 | ||
64 | for (final name in keys) { | 64 | for (final name in keys) { |
65 | - dests.add(PdfSecString.fromString(this, name)); | 65 | + dests.add(PdfSecString.fromString(name)); |
66 | dests.add(_dests[name]!); | 66 | dests.add(_dests[name]!); |
67 | } | 67 | } |
68 | 68 | ||
@@ -70,8 +70,8 @@ class PdfNames extends PdfObjectDict { | @@ -70,8 +70,8 @@ class PdfNames extends PdfObjectDict { | ||
70 | if (dests.values.isNotEmpty) { | 70 | if (dests.values.isNotEmpty) { |
71 | dict['/Names'] = dests; | 71 | dict['/Names'] = dests; |
72 | dict['/Limits'] = PdfArray([ | 72 | dict['/Limits'] = PdfArray([ |
73 | - PdfSecString.fromString(this, keys.first), | ||
74 | - PdfSecString.fromString(this, keys.last), | 73 | + PdfSecString.fromString(keys.first), |
74 | + PdfSecString.fromString(keys.last), | ||
75 | ]); | 75 | ]); |
76 | } | 76 | } |
77 | params['/Dests'] = dict; | 77 | params['/Dests'] = dict; |
@@ -23,28 +23,22 @@ import '../format/stream.dart'; | @@ -23,28 +23,22 @@ import '../format/stream.dart'; | ||
23 | import 'diagnostic.dart'; | 23 | import 'diagnostic.dart'; |
24 | 24 | ||
25 | /// Base Object used in the PDF file | 25 | /// Base Object used in the PDF file |
26 | -abstract class PdfObject<T extends PdfDataType> | ||
27 | - with PdfDiagnostic, PdfObjectBase { | 26 | +abstract class PdfObject<T extends PdfDataType> extends PdfObjectBase |
27 | + with PdfDiagnostic { | ||
28 | /// This is usually called by extensors to this class, and sets the | 28 | /// This is usually called by extensors to this class, and sets the |
29 | /// Pdf Object Type | 29 | /// Pdf Object Type |
30 | PdfObject( | 30 | PdfObject( |
31 | this.pdfDocument, { | 31 | this.pdfDocument, { |
32 | required this.params, | 32 | required this.params, |
33 | - this.objgen = 0, | 33 | + int objgen = 0, |
34 | int? objser, | 34 | int? objser, |
35 | - }) : objser = objser ?? pdfDocument.genSerial() { | 35 | + }) : super(objser: objser ?? pdfDocument.genSerial(), objgen: objgen) { |
36 | pdfDocument.objects.add(this); | 36 | pdfDocument.objects.add(this); |
37 | } | 37 | } |
38 | 38 | ||
39 | /// This is the object parameters. | 39 | /// This is the object parameters. |
40 | final T params; | 40 | final T params; |
41 | 41 | ||
42 | - @override | ||
43 | - final int objser; | ||
44 | - | ||
45 | - @override | ||
46 | - final int objgen; | ||
47 | - | ||
48 | /// This allows any Pdf object to refer to the document being constructed. | 42 | /// This allows any Pdf object to refer to the document being constructed. |
49 | final PdfDocument pdfDocument; | 43 | final PdfDocument pdfDocument; |
50 | 44 | ||
@@ -81,7 +75,7 @@ abstract class PdfObject<T extends PdfDataType> | @@ -81,7 +75,7 @@ abstract class PdfObject<T extends PdfDataType> | ||
81 | } | 75 | } |
82 | 76 | ||
83 | void writeContent(PdfStream os) { | 77 | void writeContent(PdfStream os) { |
84 | - params.output(os, verbose ? 0 : null); | 78 | + params.output(this, os, verbose ? 0 : null); |
85 | os.putByte(0x0a); | 79 | os.putByte(0x0a); |
86 | } | 80 | } |
87 | 81 |
@@ -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 os) { | 39 | void writeContent(PdfStream os) { |
40 | if (params.isNotEmpty) { | 40 | if (params.isNotEmpty) { |
41 | - params.output(os, pdfDocument.verbose ? 0 : null); | 41 | + params.output(this, os, pdfDocument.verbose ? 0 : null); |
42 | os.putByte(0x0a); | 42 | os.putByte(0x0a); |
43 | } | 43 | } |
44 | } | 44 | } |
@@ -37,10 +37,9 @@ class PdfObjectStream extends PdfObjectDict { | @@ -37,10 +37,9 @@ class PdfObjectStream extends PdfObjectDict { | ||
37 | @override | 37 | @override |
38 | void writeContent(PdfStream os) { | 38 | void writeContent(PdfStream os) { |
39 | PdfDictStream.values( | 39 | PdfDictStream.values( |
40 | - object: this, | ||
41 | isBinary: isBinary, | 40 | isBinary: isBinary, |
42 | values: params.values, | 41 | values: params.values, |
43 | data: buf.output(), | 42 | data: buf.output(), |
44 | - ).output(os, pdfDocument.verbose ? 0 : null); | 43 | + ).output(this, os, pdfDocument.verbose ? 0 : null); |
45 | } | 44 | } |
46 | } | 45 | } |
@@ -125,7 +125,7 @@ class PdfOutline extends PdfObjectDict { | @@ -125,7 +125,7 @@ class PdfOutline extends PdfObjectDict { | ||
125 | 125 | ||
126 | // These are for kids only | 126 | // These are for kids only |
127 | if (parent != null) { | 127 | if (parent != null) { |
128 | - params['/Title'] = PdfSecString.fromString(this, title!); | 128 | + params['/Title'] = PdfSecString.fromString(title!); |
129 | 129 | ||
130 | if (color != null) { | 130 | if (color != null) { |
131 | params['/C'] = PdfArray.fromColor(color!); | 131 | params['/C'] = PdfArray.fromColor(color!); |
@@ -136,7 +136,7 @@ class PdfOutline extends PdfObjectDict { | @@ -136,7 +136,7 @@ class PdfOutline extends PdfObjectDict { | ||
136 | } | 136 | } |
137 | 137 | ||
138 | if (anchor != null) { | 138 | if (anchor != null) { |
139 | - params['/Dest'] = PdfSecString.fromString(this, anchor!); | 139 | + params['/Dest'] = PdfSecString.fromString(anchor!); |
140 | } else { | 140 | } else { |
141 | final dests = PdfArray(); | 141 | final dests = PdfArray(); |
142 | dests.add(dest!.ref()); | 142 | dests.add(dest!.ref()); |
@@ -20,7 +20,6 @@ import '../format/dict.dart'; | @@ -20,7 +20,6 @@ import '../format/dict.dart'; | ||
20 | import '../format/name.dart'; | 20 | import '../format/name.dart'; |
21 | import '../format/num.dart'; | 21 | import '../format/num.dart'; |
22 | import '../format/string.dart'; | 22 | import '../format/string.dart'; |
23 | -import 'object.dart'; | ||
24 | import 'object_dict.dart'; | 23 | import 'object_dict.dart'; |
25 | 24 | ||
26 | enum PdfPageLabelStyle { | 25 | enum PdfPageLabelStyle { |
@@ -53,7 +52,7 @@ class PdfPageLabel { | @@ -53,7 +52,7 @@ class PdfPageLabel { | ||
53 | final String? prefix; | 52 | final String? prefix; |
54 | final int? subsequent; | 53 | final int? subsequent; |
55 | 54 | ||
56 | - PdfDict toDict(PdfObject obj) { | 55 | + PdfDict toDict() { |
57 | final PdfName? s; | 56 | final PdfName? s; |
58 | switch (style) { | 57 | switch (style) { |
59 | case PdfPageLabelStyle.arabic: | 58 | case PdfPageLabelStyle.arabic: |
@@ -77,7 +76,7 @@ class PdfPageLabel { | @@ -77,7 +76,7 @@ class PdfPageLabel { | ||
77 | return PdfDict({ | 76 | return PdfDict({ |
78 | if (s != null) '/S': s, | 77 | if (s != null) '/S': s, |
79 | if (prefix != null && prefix!.isNotEmpty) | 78 | if (prefix != null && prefix!.isNotEmpty) |
80 | - '/P': PdfSecString.fromString(obj, prefix!), | 79 | + '/P': PdfSecString.fromString(prefix!), |
81 | if (subsequent != null) '/St': PdfNum(subsequent!) | 80 | if (subsequent != null) '/St': PdfNum(subsequent!) |
82 | }); | 81 | }); |
83 | } | 82 | } |
@@ -191,7 +190,7 @@ class PdfPageLabels extends PdfObjectDict { | @@ -191,7 +190,7 @@ class PdfPageLabels extends PdfObjectDict { | ||
191 | final nums = PdfArray(); | 190 | final nums = PdfArray(); |
192 | for (final entry in labels.entries) { | 191 | for (final entry in labels.entries) { |
193 | nums.add(PdfNum(entry.key)); | 192 | nums.add(PdfNum(entry.key)); |
194 | - nums.add(entry.value.toDict(this)); | 193 | + nums.add(entry.value.toDict()); |
195 | } | 194 | } |
196 | 195 | ||
197 | params['/Nums'] = nums; | 196 | params['/Nums'] = nums; |
@@ -129,8 +129,8 @@ class PdfTtfFont extends PdfFont { | @@ -129,8 +129,8 @@ class PdfTtfFont extends PdfFont { | ||
129 | '/Subtype': const PdfName('/CIDFontType2'), | 129 | '/Subtype': const PdfName('/CIDFontType2'), |
130 | '/CIDSystemInfo': PdfDict({ | 130 | '/CIDSystemInfo': PdfDict({ |
131 | '/Supplement': const PdfNum(0), | 131 | '/Supplement': const PdfNum(0), |
132 | - '/Registry': PdfSecString.fromString(this, 'Adobe'), | ||
133 | - '/Ordering': PdfSecString.fromString(this, 'Identity-H'), | 132 | + '/Registry': PdfSecString.fromString('Adobe'), |
133 | + '/Ordering': PdfSecString.fromString('Identity-H'), | ||
134 | }) | 134 | }) |
135 | }); | 135 | }); |
136 | 136 |
@@ -20,18 +20,15 @@ import 'dart:io'; | @@ -20,18 +20,15 @@ import 'dart:io'; | ||
20 | import 'package:pdf/src/priv.dart'; | 20 | import 'package:pdf/src/priv.dart'; |
21 | import 'package:test/test.dart'; | 21 | import 'package:test/test.dart'; |
22 | 22 | ||
23 | -class BasicObject with PdfObjectBase { | ||
24 | - const BasicObject(this.objser); | ||
25 | - | ||
26 | - @override | ||
27 | - final int objser; | 23 | +class BasicObject extends PdfObjectBase { |
24 | + const BasicObject(int objser) : super(objser: objser); | ||
28 | 25 | ||
29 | @override | 26 | @override |
30 | bool get verbose => true; | 27 | bool get verbose => true; |
31 | 28 | ||
32 | void write(PdfStream os, PdfDataType value) { | 29 | void write(PdfStream os, PdfDataType value) { |
33 | os.putString('$objser $objgen obj\n'); | 30 | os.putString('$objser $objgen obj\n'); |
34 | - value.output(os, verbose ? 0 : null); | 31 | + value.output(this, os, verbose ? 0 : null); |
35 | os.putByte(0x0a); | 32 | os.putByte(0x0a); |
36 | os.putString('endobj\n'); | 33 | os.putString('endobj\n'); |
37 | } | 34 | } |
@@ -57,7 +54,6 @@ void main() { | @@ -57,7 +54,6 @@ void main() { | ||
57 | }); | 54 | }); |
58 | 55 | ||
59 | final content = PdfDictStream( | 56 | final content = PdfDictStream( |
60 | - object: const BasicObject(1), | ||
61 | data: latin1.encode('30 811.88976 m 200 641.88976 l S'), | 57 | data: latin1.encode('30 811.88976 m 200 641.88976 l S'), |
62 | ); | 58 | ); |
63 | 59 |
-
Please register or login to post a comment