David PHAM-VAN

Deprecate PdfArrayObject and PdfObjectDict

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ## 3.10.2 3 ## 3.10.2
4 4
5 - Fix Type1 font widths 5 - Fix Type1 font widths
  6 +- Deprecate PdfArrayObject and PdfObjectDict
6 7
7 ## 3.10.1 8 ## 3.10.1
8 9
@@ -23,7 +23,7 @@ import 'format/dict.dart'; @@ -23,7 +23,7 @@ import 'format/dict.dart';
23 import 'format/name.dart'; 23 import 'format/name.dart';
24 import 'format/num.dart'; 24 import 'format/num.dart';
25 import 'obj/function.dart'; 25 import 'obj/function.dart';
26 -import 'obj/object_dict.dart'; 26 +import 'obj/object.dart';
27 import 'obj/smask.dart'; 27 import 'obj/smask.dart';
28 28
29 enum PdfBlendMode { 29 enum PdfBlendMode {
@@ -165,9 +165,10 @@ class PdfGraphicState { @@ -165,9 +165,10 @@ class PdfGraphicState {
165 } 165 }
166 166
167 /// Stores all the graphic states used in the document 167 /// Stores all the graphic states used in the document
168 -class PdfGraphicStates extends PdfObjectDict { 168 +class PdfGraphicStates extends PdfObject<PdfDict> {
169 /// Create a new Graphic States object 169 /// Create a new Graphic States object
170 - PdfGraphicStates(PdfDocument pdfDocument) : super(pdfDocument); 170 + PdfGraphicStates(PdfDocument pdfDocument)
  171 + : super(pdfDocument, params: PdfDict());
171 172
172 final List<PdfGraphicState> _states = <PdfGraphicState>[]; 173 final List<PdfGraphicState> _states = <PdfGraphicState>[];
173 174
@@ -34,7 +34,6 @@ import 'border.dart'; @@ -34,7 +34,6 @@ import 'border.dart';
34 import 'font.dart'; 34 import 'font.dart';
35 import 'graphic_stream.dart'; 35 import 'graphic_stream.dart';
36 import 'object.dart'; 36 import 'object.dart';
37 -import 'object_dict.dart';  
38 import 'page.dart'; 37 import 'page.dart';
39 38
40 class PdfChoiceField extends PdfAnnotWidget { 39 class PdfChoiceField extends PdfAnnotWidget {
@@ -104,9 +103,12 @@ class PdfChoiceField extends PdfAnnotWidget { @@ -104,9 +103,12 @@ class PdfChoiceField extends PdfAnnotWidget {
104 } 103 }
105 } 104 }
106 105
107 -class PdfAnnot extends PdfObjectDict { 106 +class PdfAnnot extends PdfObject<PdfDict> {
108 PdfAnnot(this.pdfPage, this.annot) 107 PdfAnnot(this.pdfPage, this.annot)
109 - : super(pdfPage.pdfDocument, type: '/Annot') { 108 + : super(pdfPage.pdfDocument,
  109 + params: PdfDict({
  110 + '/Type': const PdfName('/Annot'),
  111 + })) {
110 pdfPage.annotations.add(this); 112 pdfPage.annotations.add(this);
111 } 113 }
112 114
@@ -19,6 +19,7 @@ import '../format/array.dart'; @@ -19,6 +19,7 @@ import '../format/array.dart';
19 import 'object.dart'; 19 import 'object.dart';
20 20
21 /// An array object 21 /// An array object
  22 +@Deprecated('Use PdfObject<PdfArray> instead')
22 class PdfArrayObject extends PdfObject<PdfArray> { 23 class PdfArrayObject extends PdfObject<PdfArray> {
23 /// Creates an array object 24 /// Creates an array object
24 PdfArrayObject( 25 PdfArrayObject(
@@ -16,10 +16,11 @@ @@ -16,10 +16,11 @@
16 16
17 import '../document.dart'; 17 import '../document.dart';
18 import '../format/array.dart'; 18 import '../format/array.dart';
  19 +import '../format/dict.dart';
19 import '../format/name.dart'; 20 import '../format/name.dart';
20 import '../format/num.dart'; 21 import '../format/num.dart';
21 import 'annotation.dart'; 22 import 'annotation.dart';
22 -import 'object_dict.dart'; 23 +import 'object.dart';
23 24
24 /// Border style 25 /// Border style
25 enum PdfBorderStyle { 26 enum PdfBorderStyle {
@@ -42,14 +43,14 @@ enum PdfBorderStyle { @@ -42,14 +43,14 @@ enum PdfBorderStyle {
42 } 43 }
43 44
44 /// Defines a border object 45 /// Defines a border object
45 -class PdfBorder extends PdfObjectDict { 46 +class PdfBorder extends PdfObject<PdfDict> {
46 /// Creates a border using the predefined styles in [PdfAnnot]. 47 /// Creates a border using the predefined styles in [PdfAnnot].
47 PdfBorder( 48 PdfBorder(
48 PdfDocument pdfDocument, 49 PdfDocument pdfDocument,
49 this.width, { 50 this.width, {
50 this.style = PdfBorderStyle.solid, 51 this.style = PdfBorderStyle.solid,
51 this.dash, 52 this.dash,
52 - }) : super(pdfDocument); 53 + }) : super(pdfDocument, params: PdfDict());
53 54
54 /// The style of the border 55 /// The style of the border
55 final PdfBorderStyle style; 56 final PdfBorderStyle style;
@@ -22,13 +22,13 @@ import '../format/num.dart'; @@ -22,13 +22,13 @@ import '../format/num.dart';
22 import 'annotation.dart'; 22 import 'annotation.dart';
23 import 'metadata.dart'; 23 import 'metadata.dart';
24 import 'names.dart'; 24 import 'names.dart';
25 -import 'object_dict.dart'; 25 +import 'object.dart';
26 import 'outline.dart'; 26 import 'outline.dart';
27 import 'page_label.dart'; 27 import 'page_label.dart';
28 import 'page_list.dart'; 28 import 'page_list.dart';
29 29
30 /// Pdf Catalog object 30 /// Pdf Catalog object
31 -class PdfCatalog extends PdfObjectDict { 31 +class PdfCatalog extends PdfObject<PdfDict> {
32 /// This constructs a Pdf Catalog object 32 /// This constructs a Pdf Catalog object
33 PdfCatalog( 33 PdfCatalog(
34 PdfDocument pdfDocument, 34 PdfDocument pdfDocument,
@@ -36,7 +36,14 @@ class PdfCatalog extends PdfObjectDict { @@ -36,7 +36,14 @@ class PdfCatalog extends PdfObjectDict {
36 this.pageMode, 36 this.pageMode,
37 int objgen = 0, 37 int objgen = 0,
38 int? objser, 38 int? objser,
39 - }) : super(pdfDocument, type: '/Catalog', objser: objser, objgen: objgen); 39 + }) : super(
  40 + pdfDocument,
  41 + params: PdfDict({
  42 + '/Type': const PdfName('/Catalog'),
  43 + }),
  44 + objser: objser,
  45 + objgen: objgen,
  46 + );
40 47
41 /// The pages of the document 48 /// The pages of the document
42 final PdfPageList pdfPageList; 49 final PdfPageList pdfPageList;
@@ -17,13 +17,15 @@ @@ -17,13 +17,15 @@
17 import 'dart:typed_data'; 17 import 'dart:typed_data';
18 18
19 import '../document.dart'; 19 import '../document.dart';
  20 +import '../format/dict.dart';
20 import '../format/object_base.dart'; 21 import '../format/object_base.dart';
21 -import 'object_dict.dart'; 22 +import 'object.dart';
22 23
23 /// Encryption object 24 /// Encryption object
24 -abstract class PdfEncryption extends PdfObjectDict { 25 +abstract class PdfEncryption extends PdfObject<PdfDict> {
25 /// Creates an encryption object 26 /// Creates an encryption object
26 - PdfEncryption(PdfDocument pdfDocument) : super(pdfDocument); 27 + PdfEncryption(PdfDocument pdfDocument)
  28 + : super(pdfDocument, params: PdfDict());
27 29
28 /// Encrypt some data 30 /// Encrypt some data
29 Uint8List encrypt(Uint8List input, PdfObjectBase object); 31 Uint8List encrypt(Uint8List input, PdfObjectBase object);
@@ -19,19 +19,25 @@ import 'dart:convert'; @@ -19,19 +19,25 @@ import 'dart:convert';
19 import '../document.dart'; 19 import '../document.dart';
20 import '../font/font_metrics.dart'; 20 import '../font/font_metrics.dart';
21 import '../font/type1_fonts.dart'; 21 import '../font/type1_fonts.dart';
  22 +import '../format/dict.dart';
22 import '../format/name.dart'; 23 import '../format/name.dart';
23 import '../format/stream.dart'; 24 import '../format/stream.dart';
24 import '../format/string.dart'; 25 import '../format/string.dart';
25 import '../point.dart'; 26 import '../point.dart';
26 -import 'object_dict.dart'; 27 +import 'object.dart';
27 import 'type1_font.dart'; 28 import 'type1_font.dart';
28 29
29 /// Pdf font object 30 /// Pdf font object
30 -abstract class PdfFont extends PdfObjectDict { 31 +abstract class PdfFont extends PdfObject<PdfDict> {
31 /// Constructs a [PdfFont]. This will attempt to map the font from a known 32 /// Constructs a [PdfFont]. This will attempt to map the font from a known
32 /// font name to that in Pdf, defaulting to Helvetica if not possible. 33 /// font name to that in Pdf, defaulting to Helvetica if not possible.
33 PdfFont.create(PdfDocument pdfDocument, {required this.subtype}) 34 PdfFont.create(PdfDocument pdfDocument, {required this.subtype})
34 - : super(pdfDocument, type: '/Font') { 35 + : super(
  36 + pdfDocument,
  37 + params: PdfDict({
  38 + '/Type': const PdfName('/Font'),
  39 + }),
  40 + ) {
35 pdfDocument.fonts.add(this); 41 pdfDocument.fonts.add(this);
36 } 42 }
37 43
@@ -15,24 +15,30 @@ @@ -15,24 +15,30 @@
15 */ 15 */
16 16
17 import '../format/array.dart'; 17 import '../format/array.dart';
  18 +import '../format/dict.dart';
18 import '../format/name.dart'; 19 import '../format/name.dart';
19 import '../format/num.dart'; 20 import '../format/num.dart';
20 -import 'object_dict.dart'; 21 +import 'object.dart';
21 import 'object_stream.dart'; 22 import 'object_stream.dart';
22 import 'ttffont.dart'; 23 import 'ttffont.dart';
23 24
24 /// Font descriptor object 25 /// Font descriptor object
25 -class PdfFontDescriptor extends PdfObjectDict { 26 +class PdfFontDescriptor extends PdfObject<PdfDict> {
26 /// Create a Font descriptor object 27 /// Create a Font descriptor object
27 PdfFontDescriptor( 28 PdfFontDescriptor(
28 this.ttfFont, 29 this.ttfFont,
29 this.file, 30 this.file,
30 - ) : super(ttfFont.pdfDocument, type: '/FontDescriptor'); 31 + ) : super(
  32 + ttfFont.pdfDocument,
  33 + params: PdfDict({
  34 + '/Type': const PdfName('/FontDescriptor'),
  35 + }),
  36 + );
31 37
32 /// File data 38 /// File data
33 final PdfObjectStream file; 39 final PdfObjectStream file;
34 40
35 - /// Truetype font 41 + /// TrueType font
36 final PdfTtfFont ttfFont; 42 final PdfTtfFont ttfFont;
37 43
38 @override 44 @override
@@ -17,12 +17,14 @@ @@ -17,12 +17,14 @@
17 import '../color.dart'; 17 import '../color.dart';
18 import '../document.dart'; 18 import '../document.dart';
19 import '../format/array.dart'; 19 import '../format/array.dart';
  20 +import '../format/dict.dart';
20 import '../format/num.dart'; 21 import '../format/num.dart';
21 -import 'object_dict.dart'; 22 +import 'object.dart';
22 import 'object_stream.dart'; 23 import 'object_stream.dart';
23 24
24 -abstract class PdfBaseFunction extends PdfObjectDict {  
25 - PdfBaseFunction(PdfDocument pdfDocument) : super(pdfDocument); 25 +abstract class PdfBaseFunction extends PdfObject<PdfDict> {
  26 + PdfBaseFunction(PdfDocument pdfDocument)
  27 + : super(pdfDocument, params: PdfDict());
26 28
27 factory PdfBaseFunction.colorsAndStops( 29 factory PdfBaseFunction.colorsAndStops(
28 PdfDocument pdfDocument, 30 PdfDocument pdfDocument,
@@ -21,13 +21,13 @@ import '../format/dict.dart'; @@ -21,13 +21,13 @@ import '../format/dict.dart';
21 import '../format/name.dart'; 21 import '../format/name.dart';
22 import '../graphic_state.dart'; 22 import '../graphic_state.dart';
23 import 'font.dart'; 23 import 'font.dart';
24 -import 'object_dict.dart'; 24 +import 'object.dart';
25 import 'pattern.dart'; 25 import 'pattern.dart';
26 import 'shading.dart'; 26 import 'shading.dart';
27 import 'xobject.dart'; 27 import 'xobject.dart';
28 28
29 /// Helper functions for graphic objects 29 /// Helper functions for graphic objects
30 -mixin PdfGraphicStream on PdfObjectDict { 30 +mixin PdfGraphicStream on PdfObject<PdfDict> {
31 /// Isolated transparency: If this flag is true, objects within the group 31 /// Isolated transparency: If this flag is true, objects within the group
32 /// shall be composited against a fully transparent initial backdrop; 32 /// shall be composited against a fully transparent initial backdrop;
33 /// if false, they shall be composited against the group’s backdrop 33 /// if false, they shall be composited against the group’s backdrop
@@ -15,43 +15,36 @@ @@ -15,43 +15,36 @@
15 */ 15 */
16 16
17 import '../document.dart'; 17 import '../document.dart';
  18 +import '../format/dict.dart';
18 import '../format/string.dart'; 19 import '../format/string.dart';
19 -import 'object_dict.dart'; 20 +import 'object.dart';
20 21
21 /// Information object 22 /// Information object
22 -class PdfInfo extends PdfObjectDict { 23 +class PdfInfo extends PdfObject<PdfDict> {
23 /// Create an information object 24 /// Create an information object
24 - PdfInfo(PdfDocument pdfDocument,  
25 - {this.title,  
26 - this.author,  
27 - this.creator,  
28 - this.subject,  
29 - this.keywords,  
30 - this.producer})  
31 - : super(pdfDocument) {  
32 - if (author != null) {  
33 - params['/Author'] = PdfString.fromString(author!);  
34 - }  
35 - if (creator != null) {  
36 - params['/Creator'] = PdfString.fromString(creator!);  
37 - }  
38 - if (title != null) {  
39 - params['/Title'] = PdfString.fromString(title!);  
40 - }  
41 - if (subject != null) {  
42 - params['/Subject'] = PdfString.fromString(subject!);  
43 - }  
44 - if (keywords != null) {  
45 - params['/Keywords'] = PdfString.fromString(keywords!);  
46 - }  
47 - if (producer != null) {  
48 - params['/Producer'] = PdfString.fromString('$producer ($_libraryName)');  
49 - } else {  
50 - params['/Producer'] = PdfString.fromString(_libraryName);  
51 - }  
52 -  
53 - params['/CreationDate'] = PdfString.fromDate(DateTime.now());  
54 - } 25 + PdfInfo(
  26 + PdfDocument pdfDocument, {
  27 + this.title,
  28 + this.author,
  29 + this.creator,
  30 + this.subject,
  31 + this.keywords,
  32 + this.producer,
  33 + }) : super(
  34 + pdfDocument,
  35 + params: PdfDict({
  36 + if (author != null) '/Author': PdfString.fromString(author),
  37 + if (creator != null) '/Creator': PdfString.fromString(creator),
  38 + if (title != null) '/Title': PdfString.fromString(title),
  39 + if (subject != null) '/Subject': PdfString.fromString(subject),
  40 + if (keywords != null) '/Keywords': PdfString.fromString(keywords),
  41 + if (producer != null)
  42 + '/Producer': PdfString.fromString('$producer ($_libraryName)')
  43 + else
  44 + '/Producer': PdfString.fromString(_libraryName),
  45 + '/CreationDate': PdfString.fromDate(DateTime.now()),
  46 + }),
  47 + );
55 48
56 static const String _libraryName = 'https://github.com/DavBfr/dart_pdf'; 49 static const String _libraryName = 'https://github.com/DavBfr/dart_pdf';
57 50
@@ -22,13 +22,13 @@ import '../format/name.dart'; @@ -22,13 +22,13 @@ import '../format/name.dart';
22 import '../format/null_value.dart'; 22 import '../format/null_value.dart';
23 import '../format/num.dart'; 23 import '../format/num.dart';
24 import '../format/string.dart'; 24 import '../format/string.dart';
25 -import 'object_dict.dart'; 25 +import 'object.dart';
26 import 'page.dart'; 26 import 'page.dart';
27 27
28 /// Pdf Name object 28 /// Pdf Name object
29 -class PdfNames extends PdfObjectDict { 29 +class PdfNames extends PdfObject<PdfDict> {
30 /// This constructs a Pdf Name object 30 /// This constructs a Pdf Name object
31 - PdfNames(PdfDocument pdfDocument) : super(pdfDocument); 31 + PdfNames(PdfDocument pdfDocument) : super(pdfDocument, params: PdfDict());
32 32
33 final Map<String, PdfDataType> _dests = <String, PdfDataType>{}; 33 final Map<String, PdfDataType> _dests = <String, PdfDataType>{};
34 34
@@ -21,9 +21,8 @@ import '../format/base.dart'; @@ -21,9 +21,8 @@ import '../format/base.dart';
21 import '../format/object_base.dart'; 21 import '../format/object_base.dart';
22 22
23 /// Base Object used in the PDF file 23 /// Base Object used in the PDF file
24 -abstract class PdfObject<T extends PdfDataType> extends PdfObjectBase<T> {  
25 - /// This is usually called by extensors to this class, and sets the  
26 - /// Pdf Object Type 24 +class PdfObject<T extends PdfDataType> extends PdfObjectBase<T> {
  25 + /// Create a base Object used in the PDF file
27 PdfObject( 26 PdfObject(
28 this.pdfDocument, { 27 this.pdfDocument, {
29 required T params, 28 required T params,
@@ -21,6 +21,7 @@ import '../format/stream.dart'; @@ -21,6 +21,7 @@ import '../format/stream.dart';
21 import 'object.dart'; 21 import 'object.dart';
22 22
23 /// Object with a PdfDict used in the PDF file 23 /// Object with a PdfDict used in the PDF file
  24 +@Deprecated('Use PdfObject<PdfDict> instead')
24 class PdfObjectDict extends PdfObject<PdfDict> { 25 class PdfObjectDict extends PdfObject<PdfDict> {
25 /// This is usually called by extensors to this class, and sets the 26 /// This is usually called by extensors to this class, and sets the
26 /// Pdf Object Type 27 /// Pdf Object Type
@@ -15,18 +15,25 @@ @@ -15,18 +15,25 @@
15 */ 15 */
16 16
17 import '../document.dart'; 17 import '../document.dart';
  18 +import '../format/dict.dart';
18 import '../format/dict_stream.dart'; 19 import '../format/dict_stream.dart';
  20 +import '../format/name.dart';
19 import '../format/stream.dart'; 21 import '../format/stream.dart';
20 -import 'object_dict.dart'; 22 +import 'object.dart';
21 23
22 /// Stream Object 24 /// Stream Object
23 -class PdfObjectStream extends PdfObjectDict { 25 +class PdfObjectStream extends PdfObject<PdfDict> {
24 /// Constructs a stream object to store some data 26 /// Constructs a stream object to store some data
25 PdfObjectStream( 27 PdfObjectStream(
26 PdfDocument pdfDocument, { 28 PdfDocument pdfDocument, {
27 String? type, 29 String? type,
28 this.isBinary = false, 30 this.isBinary = false,
29 - }) : super(pdfDocument, type: type); 31 + }) : super(
  32 + pdfDocument,
  33 + params: PdfDict({
  34 + if (type != null) '/Type': PdfName(type),
  35 + }),
  36 + );
30 37
31 /// This holds the stream's content. 38 /// This holds the stream's content.
32 final PdfStream buf = PdfStream(); 39 final PdfStream buf = PdfStream();
@@ -17,11 +17,12 @@ @@ -17,11 +17,12 @@
17 import '../color.dart'; 17 import '../color.dart';
18 import '../document.dart'; 18 import '../document.dart';
19 import '../format/array.dart'; 19 import '../format/array.dart';
  20 +import '../format/dict.dart';
20 import '../format/name.dart'; 21 import '../format/name.dart';
21 import '../format/num.dart'; 22 import '../format/num.dart';
22 import '../format/string.dart'; 23 import '../format/string.dart';
23 import '../rect.dart'; 24 import '../rect.dart';
24 -import 'object_dict.dart'; 25 +import 'object.dart';
25 import 'page.dart'; 26 import 'page.dart';
26 27
27 /// Outline mode 28 /// Outline mode
@@ -49,7 +50,7 @@ enum PdfOutlineStyle { @@ -49,7 +50,7 @@ enum PdfOutlineStyle {
49 } 50 }
50 51
51 /// Pdf Outline object 52 /// Pdf Outline object
52 -class PdfOutline extends PdfObjectDict { 53 +class PdfOutline extends PdfObject<PdfDict> {
53 /// Constructs a Pdf Outline object. 54 /// Constructs a Pdf Outline object.
54 /// When selected, the specified region is displayed. 55 /// When selected, the specified region is displayed.
55 PdfOutline( 56 PdfOutline(
@@ -64,7 +65,7 @@ class PdfOutline extends PdfObjectDict { @@ -64,7 +65,7 @@ class PdfOutline extends PdfObjectDict {
64 PdfPage? page, 65 PdfPage? page,
65 }) : assert(anchor == null || (dest == null && rect == null)), 66 }) : assert(anchor == null || (dest == null && rect == null)),
66 _page = page, 67 _page = page,
67 - super(pdfDocument); 68 + super(pdfDocument, params: PdfDict());
68 69
69 /// This holds any outlines below us 70 /// This holds any outlines below us
70 List<PdfOutline> outlines = <PdfOutline>[]; 71 List<PdfOutline> outlines = <PdfOutline>[];
@@ -16,14 +16,15 @@ @@ -16,14 +16,15 @@
16 16
17 import '../document.dart'; 17 import '../document.dart';
18 import '../format/array.dart'; 18 import '../format/array.dart';
  19 +import '../format/dict.dart';
19 import '../format/indirect.dart'; 20 import '../format/indirect.dart';
  21 +import '../format/name.dart';
20 import '../format/num.dart'; 22 import '../format/num.dart';
21 import '../graphics.dart'; 23 import '../graphics.dart';
22 import '../page_format.dart'; 24 import '../page_format.dart';
23 import 'annotation.dart'; 25 import 'annotation.dart';
24 import 'graphic_stream.dart'; 26 import 'graphic_stream.dart';
25 import 'object.dart'; 27 import 'object.dart';
26 -import 'object_dict.dart';  
27 import 'object_stream.dart'; 28 import 'object_stream.dart';
28 29
29 /// Page rotation 30 /// Page rotation
@@ -42,7 +43,7 @@ enum PdfPageRotation { @@ -42,7 +43,7 @@ enum PdfPageRotation {
42 } 43 }
43 44
44 /// Page object, which will hold any contents for this page. 45 /// Page object, which will hold any contents for this page.
45 -class PdfPage extends PdfObjectDict with PdfGraphicStream { 46 +class PdfPage extends PdfObject<PdfDict> with PdfGraphicStream {
46 /// This constructs a Page object, which will hold any contents for this 47 /// This constructs a Page object, which will hold any contents for this
47 /// page. 48 /// page.
48 PdfPage( 49 PdfPage(
@@ -52,7 +53,12 @@ class PdfPage extends PdfObjectDict with PdfGraphicStream { @@ -52,7 +53,12 @@ class PdfPage extends PdfObjectDict with PdfGraphicStream {
52 int? index, 53 int? index,
53 int? objser, 54 int? objser,
54 int objgen = 0, 55 int objgen = 0,
55 - }) : super(pdfDocument, type: '/Page', objser: objser, objgen: objgen) { 56 + }) : super(pdfDocument,
  57 + params: PdfDict({
  58 + '/Type': const PdfName('/Page'),
  59 + }),
  60 + objser: objser,
  61 + objgen: objgen) {
56 if (index != null) { 62 if (index != null) {
57 pdfDocument.pdfPageList.pages.insert(index, this); 63 pdfDocument.pdfPageList.pages.insert(index, this);
58 } else { 64 } else {
@@ -20,7 +20,7 @@ import '../format/dict.dart'; @@ -20,7 +20,7 @@ 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_dict.dart'; 23 +import 'object.dart';
24 24
25 enum PdfPageLabelStyle { 25 enum PdfPageLabelStyle {
26 arabic, 26 arabic,
@@ -145,9 +145,10 @@ class PdfPageLabel { @@ -145,9 +145,10 @@ class PdfPageLabel {
145 } 145 }
146 146
147 /// Pdf PageLabels object 147 /// Pdf PageLabels object
148 -class PdfPageLabels extends PdfObjectDict { 148 +class PdfPageLabels extends PdfObject<PdfDict> {
149 /// Constructs a Pdf PageLabels object. 149 /// Constructs a Pdf PageLabels object.
150 - PdfPageLabels(PdfDocument pdfDocument) : super(pdfDocument); 150 + PdfPageLabels(PdfDocument pdfDocument)
  151 + : super(pdfDocument, params: PdfDict());
151 152
152 final labels = <int, PdfPageLabel>{}; 153 final labels = <int, PdfPageLabel>{};
153 154
@@ -16,18 +16,27 @@ @@ -16,18 +16,27 @@
16 16
17 import '../document.dart'; 17 import '../document.dart';
18 import '../format/array.dart'; 18 import '../format/array.dart';
  19 +import '../format/dict.dart';
  20 +import '../format/name.dart';
19 import '../format/num.dart'; 21 import '../format/num.dart';
20 -import 'object_dict.dart'; 22 +import 'object.dart';
21 import 'page.dart'; 23 import 'page.dart';
22 24
23 /// PdfPageList object 25 /// PdfPageList object
24 -class PdfPageList extends PdfObjectDict { 26 +class PdfPageList extends PdfObject<PdfDict> {
25 /// This constructs a [PdfPageList] object. 27 /// This constructs a [PdfPageList] object.
26 PdfPageList( 28 PdfPageList(
27 PdfDocument pdfDocument, { 29 PdfDocument pdfDocument, {
28 int objgen = 0, 30 int objgen = 0,
29 int? objser, 31 int? objser,
30 - }) : super(pdfDocument, type: '/Pages', objgen: objgen, objser: objser); 32 + }) : super(
  33 + pdfDocument,
  34 + params: PdfDict({
  35 + '/Type': const PdfName('/Pages'),
  36 + }),
  37 + objgen: objgen,
  38 + objser: objser,
  39 + );
31 40
32 /// This holds the pages 41 /// This holds the pages
33 final pages = <PdfPage>[]; 42 final pages = <PdfPage>[];
@@ -18,14 +18,15 @@ import 'package:vector_math/vector_math_64.dart'; @@ -18,14 +18,15 @@ import 'package:vector_math/vector_math_64.dart';
18 18
19 import '../document.dart'; 19 import '../document.dart';
20 import '../format/array.dart'; 20 import '../format/array.dart';
  21 +import '../format/dict.dart';
21 import '../format/num.dart'; 22 import '../format/num.dart';
22 import '../graphic_state.dart'; 23 import '../graphic_state.dart';
23 -import 'object_dict.dart'; 24 +import 'object.dart';
24 import 'shading.dart'; 25 import 'shading.dart';
25 26
26 -abstract class PdfPattern extends PdfObjectDict { 27 +abstract class PdfPattern extends PdfObject<PdfDict> {
27 PdfPattern(PdfDocument pdfDocument, this.patternType, this.matrix) 28 PdfPattern(PdfDocument pdfDocument, this.patternType, this.matrix)
28 - : super(pdfDocument); 29 + : super(pdfDocument, params: PdfDict());
29 30
30 /// Name of the Pattern object 31 /// Name of the Pattern object
31 String get name => '/P$objser'; 32 String get name => '/P$objser';
@@ -17,16 +17,17 @@ @@ -17,16 +17,17 @@
17 import '../document.dart'; 17 import '../document.dart';
18 import '../format/array.dart'; 18 import '../format/array.dart';
19 import '../format/bool.dart'; 19 import '../format/bool.dart';
  20 +import '../format/dict.dart';
20 import '../format/name.dart'; 21 import '../format/name.dart';
21 import '../format/num.dart'; 22 import '../format/num.dart';
22 import '../point.dart'; 23 import '../point.dart';
23 import '../rect.dart'; 24 import '../rect.dart';
24 import 'function.dart'; 25 import 'function.dart';
25 -import 'object_dict.dart'; 26 +import 'object.dart';
26 27
27 enum PdfShadingType { axial, radial } 28 enum PdfShadingType { axial, radial }
28 29
29 -class PdfShading extends PdfObjectDict { 30 +class PdfShading extends PdfObject<PdfDict> {
30 PdfShading( 31 PdfShading(
31 PdfDocument pdfDocument, { 32 PdfDocument pdfDocument, {
32 required this.shadingType, 33 required this.shadingType,
@@ -38,7 +39,7 @@ class PdfShading extends PdfObjectDict { @@ -38,7 +39,7 @@ class PdfShading extends PdfObjectDict {
38 this.boundingBox, 39 this.boundingBox,
39 this.extendStart = false, 40 this.extendStart = false,
40 this.extendEnd = false, 41 this.extendEnd = false,
41 - }) : super(pdfDocument); 42 + }) : super(pdfDocument, params: PdfDict());
42 43
43 /// Name of the Shading object 44 /// Name of the Shading object
44 String get name => '/S$objser'; 45 String get name => '/S$objser';
@@ -18,9 +18,9 @@ import 'dart:typed_data'; @@ -18,9 +18,9 @@ import 'dart:typed_data';
18 18
19 import '../document.dart'; 19 import '../document.dart';
20 import '../format/dict.dart'; 20 import '../format/dict.dart';
  21 +import '../format/name.dart';
21 import '../format/stream.dart'; 22 import '../format/stream.dart';
22 import 'object.dart'; 23 import 'object.dart';
23 -import 'object_dict.dart';  
24 import 'object_stream.dart'; 24 import 'object_stream.dart';
25 25
26 /// Signature flags 26 /// Signature flags
@@ -35,7 +35,7 @@ enum PdfSigFlags { @@ -35,7 +35,7 @@ enum PdfSigFlags {
35 appendOnly, 35 appendOnly,
36 } 36 }
37 37
38 -class PdfSignature extends PdfObjectDict { 38 +class PdfSignature extends PdfObject<PdfDict> {
39 PdfSignature( 39 PdfSignature(
40 PdfDocument pdfDocument, { 40 PdfDocument pdfDocument, {
41 required this.value, 41 required this.value,
@@ -43,7 +43,12 @@ class PdfSignature extends PdfObjectDict { @@ -43,7 +43,12 @@ class PdfSignature extends PdfObjectDict {
43 List<Uint8List>? crl, 43 List<Uint8List>? crl,
44 List<Uint8List>? cert, 44 List<Uint8List>? cert,
45 List<Uint8List>? ocsp, 45 List<Uint8List>? ocsp,
46 - }) : super(pdfDocument, type: '/Sig') { 46 + }) : super(
  47 + pdfDocument,
  48 + params: PdfDict({
  49 + '/Type': const PdfName('/Sig'),
  50 + }),
  51 + ) {
47 if (crl != null) { 52 if (crl != null) {
48 for (final o in crl) { 53 for (final o in crl) {
49 this.crl.add(PdfObjectStream(pdfDocument)..buf.putBytes(o)); 54 this.crl.add(PdfObjectStream(pdfDocument)..buf.putBytes(o));
@@ -28,9 +28,9 @@ import '../format/name.dart'; @@ -28,9 +28,9 @@ import '../format/name.dart';
28 import '../format/num.dart'; 28 import '../format/num.dart';
29 import '../format/stream.dart'; 29 import '../format/stream.dart';
30 import '../format/string.dart'; 30 import '../format/string.dart';
31 -import 'array.dart';  
32 import 'font.dart'; 31 import 'font.dart';
33 import 'font_descriptor.dart'; 32 import 'font_descriptor.dart';
  33 +import 'object.dart';
34 import 'object_stream.dart'; 34 import 'object_stream.dart';
35 import 'unicode_cmap.dart'; 35 import 'unicode_cmap.dart';
36 36
@@ -42,7 +42,7 @@ class PdfTtfFont extends PdfFont { @@ -42,7 +42,7 @@ class PdfTtfFont extends PdfFont {
42 file = PdfObjectStream(pdfDocument, isBinary: true); 42 file = PdfObjectStream(pdfDocument, isBinary: true);
43 unicodeCMap = PdfUnicodeCmap(pdfDocument, protect); 43 unicodeCMap = PdfUnicodeCmap(pdfDocument, protect);
44 descriptor = PdfFontDescriptor(this, file); 44 descriptor = PdfFontDescriptor(this, file);
45 - widthsObject = PdfArrayObject(pdfDocument, PdfArray()); 45 + widthsObject = PdfObject<PdfArray>(pdfDocument, params: PdfArray());
46 } 46 }
47 47
48 @override 48 @override
@@ -54,7 +54,7 @@ class PdfTtfFont extends PdfFont { @@ -54,7 +54,7 @@ class PdfTtfFont extends PdfFont {
54 54
55 late PdfObjectStream file; 55 late PdfObjectStream file;
56 56
57 - late PdfArrayObject widthsObject; 57 + late PdfObject<PdfArray> widthsObject;
58 58
59 final TtfParser font; 59 final TtfParser font;
60 60
@@ -98,7 +98,7 @@ class PdfTtfFont extends PdfFont { @@ -98,7 +98,7 @@ class PdfTtfFont extends PdfFont {
98 charMin = 32; 98 charMin = 32;
99 charMax = 255; 99 charMax = 255;
100 for (var i = charMin; i <= charMax; i++) { 100 for (var i = charMin; i <= charMax; i++) {
101 - widthsObject.array 101 + widthsObject.params
102 .add(PdfNum((glyphMetrics(i).advanceWidth * 1000.0).toInt())); 102 .add(PdfNum((glyphMetrics(i).advanceWidth * 1000.0).toInt()));
103 } 103 }
104 params['/FirstChar'] = PdfNum(charMin); 104 params['/FirstChar'] = PdfNum(charMin);
@@ -142,7 +142,7 @@ class PdfTtfFont extends PdfFont { @@ -142,7 +142,7 @@ class PdfTtfFont extends PdfFont {
142 charMin = 0; 142 charMin = 0;
143 charMax = unicodeCMap.cmap.length - 1; 143 charMax = unicodeCMap.cmap.length - 1;
144 for (var i = charMin; i <= charMax; i++) { 144 for (var i = charMin; i <= charMax; i++) {
145 - widthsObject.array.add(PdfNum( 145 + widthsObject.params.add(PdfNum(
146 (glyphMetrics(unicodeCMap.cmap[i]).advanceWidth * 1000.0).toInt())); 146 (glyphMetrics(unicodeCMap.cmap[i]).advanceWidth * 1000.0).toInt()));
147 } 147 }
148 } 148 }
@@ -19,7 +19,6 @@ import '../document.dart'; @@ -19,7 +19,6 @@ import '../document.dart';
19 import '../font/font_metrics.dart'; 19 import '../font/font_metrics.dart';
20 import '../format/object_base.dart'; 20 import '../format/object_base.dart';
21 import 'font.dart'; 21 import 'font.dart';
22 -import 'object_dict.dart';  
23 import 'ttffont.dart'; 22 import 'ttffont.dart';
24 23
25 /// Type 1 font object. 24 /// Type 1 font object.
@@ -63,17 +62,22 @@ class PdfType1Font extends PdfFont { @@ -63,17 +62,22 @@ class PdfType1Font extends PdfFont {
63 List<int>.filled(256, (missingWidth * unitsPerEm).toInt())); 62 List<int>.filled(256, (missingWidth * unitsPerEm).toInt()));
64 } 63 }
65 64
66 - final fontDescriptor = PdfObjectDict(pdfDocument, type: '/FontDescriptor')  
67 - ..params['/FontName'] = PdfName('/$fontName')  
68 - ..params['/Flags'] = PdfNum(32 + (isFixedPitch ? 1 : 0))  
69 - ..params['/FontBBox'] = PdfArray.fromNum(fontBBox)  
70 - ..params['/Ascent'] = PdfNum((ascent * unitsPerEm).toInt())  
71 - ..params['/Descent'] = PdfNum((descent * unitsPerEm).toInt())  
72 - ..params['/ItalicAngle'] = PdfNum(italicAngle)  
73 - ..params['/CapHeight'] = PdfNum(capHeight)  
74 - ..params['/StemV'] = PdfNum(stdVW)  
75 - ..params['/StemH'] = PdfNum(stdHW)  
76 - ..params['/MissingWidth'] = PdfNum((missingWidth * unitsPerEm).toInt()); 65 + final fontDescriptor = PdfObject<PdfDict>(
  66 + pdfDocument,
  67 + params: PdfDict({
  68 + '/Type': const PdfName('/FontDescriptor'),
  69 + '/FontName': PdfName('/$fontName'),
  70 + '/Flags': PdfNum(32 + (isFixedPitch ? 1 : 0)),
  71 + '/FontBBox': PdfArray.fromNum(fontBBox),
  72 + '/Ascent': PdfNum((ascent * unitsPerEm).toInt()),
  73 + '/Descent': PdfNum((descent * unitsPerEm).toInt()),
  74 + '/ItalicAngle': PdfNum(italicAngle),
  75 + '/CapHeight': PdfNum(capHeight),
  76 + '/StemV': PdfNum(stdVW),
  77 + '/StemH': PdfNum(stdHW),
  78 + '/MissingWidth': PdfNum((missingWidth * unitsPerEm).toInt()),
  79 + }),
  80 + );
77 81
78 params['/FontDescriptor'] = fontDescriptor.ref(); 82 params['/FontDescriptor'] = fontDescriptor.ref();
79 } 83 }