Showing
10 changed files
with
58 additions
and
17 deletions
@@ -25,12 +25,13 @@ import 'font.dart'; | @@ -25,12 +25,13 @@ import 'font.dart'; | ||
25 | import 'graphic_stream.dart'; | 25 | import 'graphic_stream.dart'; |
26 | import 'graphics.dart'; | 26 | import 'graphics.dart'; |
27 | import 'object.dart'; | 27 | import 'object.dart'; |
28 | +import 'object_dict.dart'; | ||
28 | import 'page.dart'; | 29 | import 'page.dart'; |
29 | import 'point.dart'; | 30 | import 'point.dart'; |
30 | import 'rect.dart'; | 31 | import 'rect.dart'; |
31 | import 'stream.dart'; | 32 | import 'stream.dart'; |
32 | 33 | ||
33 | -class PdfAnnot extends PdfObject { | 34 | +class PdfAnnot extends PdfObjectDict { |
34 | PdfAnnot(this.pdfPage, this.annot) | 35 | PdfAnnot(this.pdfPage, this.annot) |
35 | : super(pdfPage.pdfDocument, type: '/Annot') { | 36 | : super(pdfPage.pdfDocument, type: '/Annot') { |
36 | pdfPage.annotations.add(this); | 37 | pdfPage.annotations.add(this); |
@@ -19,11 +19,12 @@ import 'data_types.dart'; | @@ -19,11 +19,12 @@ import 'data_types.dart'; | ||
19 | import 'document.dart'; | 19 | import 'document.dart'; |
20 | import 'names.dart'; | 20 | import 'names.dart'; |
21 | import 'object.dart'; | 21 | import 'object.dart'; |
22 | +import 'object_dict.dart'; | ||
22 | import 'outline.dart'; | 23 | import 'outline.dart'; |
23 | import 'page_list.dart'; | 24 | import 'page_list.dart'; |
24 | 25 | ||
25 | /// Pdf Catalog object | 26 | /// Pdf Catalog object |
26 | -class PdfCatalog extends PdfObject { | 27 | +class PdfCatalog extends PdfObjectDict { |
27 | /// This constructs a Pdf Catalog object | 28 | /// This constructs a Pdf Catalog object |
28 | PdfCatalog( | 29 | PdfCatalog( |
29 | PdfDocument pdfDocument, | 30 | PdfDocument pdfDocument, |
@@ -19,14 +19,14 @@ import 'dart:convert'; | @@ -19,14 +19,14 @@ import 'dart:convert'; | ||
19 | import 'data_types.dart'; | 19 | import 'data_types.dart'; |
20 | import 'document.dart'; | 20 | import 'document.dart'; |
21 | import 'font_metrics.dart'; | 21 | import 'font_metrics.dart'; |
22 | -import 'object.dart'; | 22 | +import 'object_dict.dart'; |
23 | import 'point.dart'; | 23 | import 'point.dart'; |
24 | import 'stream.dart'; | 24 | import 'stream.dart'; |
25 | import 'type1_font.dart'; | 25 | import 'type1_font.dart'; |
26 | import 'type1_fonts.dart'; | 26 | import 'type1_fonts.dart'; |
27 | 27 | ||
28 | /// Pdf font object | 28 | /// Pdf font object |
29 | -abstract class PdfFont extends PdfObject { | 29 | +abstract class PdfFont extends PdfObjectDict { |
30 | /// Constructs a [PdfFont]. This will attempt to map the font from a known | 30 | /// Constructs a [PdfFont]. This will attempt to map the font from a known |
31 | /// font name to that in Pdf, defaulting to Helvetica if not possible. | 31 | /// font name to that in Pdf, defaulting to Helvetica if not possible. |
32 | PdfFont.create(PdfDocument pdfDocument, {required this.subtype}) | 32 | PdfFont.create(PdfDocument pdfDocument, {required this.subtype}) |
@@ -16,11 +16,12 @@ | @@ -16,11 +16,12 @@ | ||
16 | 16 | ||
17 | import 'data_types.dart'; | 17 | import 'data_types.dart'; |
18 | import 'object.dart'; | 18 | import 'object.dart'; |
19 | +import 'object_dict.dart'; | ||
19 | import 'object_stream.dart'; | 20 | import 'object_stream.dart'; |
20 | import 'ttffont.dart'; | 21 | import 'ttffont.dart'; |
21 | 22 | ||
22 | /// Font descriptor object | 23 | /// Font descriptor object |
23 | -class PdfFontDescriptor extends PdfObject { | 24 | +class PdfFontDescriptor extends PdfObjectDict { |
24 | /// Create a Font descriptor object | 25 | /// Create a Font descriptor object |
25 | PdfFontDescriptor( | 26 | PdfFontDescriptor( |
26 | this.ttfFont, | 27 | this.ttfFont, |
@@ -26,14 +26,10 @@ class PdfObject { | @@ -26,14 +26,10 @@ class PdfObject { | ||
26 | /// Pdf Object Type | 26 | /// Pdf Object Type |
27 | PdfObject( | 27 | PdfObject( |
28 | this.pdfDocument, { | 28 | this.pdfDocument, { |
29 | - String? type, | 29 | + // String? type, |
30 | this.objgen = 0, | 30 | this.objgen = 0, |
31 | int? objser, | 31 | int? objser, |
32 | }) : objser = objser ?? pdfDocument.genSerial() { | 32 | }) : objser = objser ?? pdfDocument.genSerial() { |
33 | - if (type != null) { | ||
34 | - params['/Type'] = PdfName(type); | ||
35 | - } | ||
36 | - | ||
37 | pdfDocument.objects.add(this); | 33 | pdfDocument.objects.add(this); |
38 | } | 34 | } |
39 | 35 |
pdf/lib/src/pdf/object_dict.dart
0 → 100644
1 | +/* | ||
2 | + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com> | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +import 'data_types.dart'; | ||
18 | +import 'document.dart'; | ||
19 | +import 'object.dart'; | ||
20 | + | ||
21 | +/// Object with a PdfDict used in the PDF file | ||
22 | +class PdfObjectDict extends PdfObject { | ||
23 | + /// This is usually called by extensors to this class, and sets the | ||
24 | + /// Pdf Object Type | ||
25 | + PdfObjectDict( | ||
26 | + PdfDocument pdfDocument, { | ||
27 | + String? type, | ||
28 | + int objgen = 0, | ||
29 | + int? objser, | ||
30 | + }) : super(pdfDocument, objgen: objgen, objser: objser) { | ||
31 | + if (type != null) { | ||
32 | + params['/Type'] = PdfName(type); | ||
33 | + } | ||
34 | + } | ||
35 | + | ||
36 | + /// This is the object parameters. | ||
37 | + final PdfDict params = PdfDict(); | ||
38 | + | ||
39 | + @override | ||
40 | + String toString() => '$runtimeType $params'; | ||
41 | +} |
@@ -19,11 +19,11 @@ import 'dart:typed_data'; | @@ -19,11 +19,11 @@ import 'dart:typed_data'; | ||
19 | import 'ascii85.dart'; | 19 | import 'ascii85.dart'; |
20 | import 'data_types.dart'; | 20 | import 'data_types.dart'; |
21 | import 'document.dart'; | 21 | import 'document.dart'; |
22 | -import 'object.dart'; | 22 | +import 'object_dict.dart'; |
23 | import 'stream.dart'; | 23 | import 'stream.dart'; |
24 | 24 | ||
25 | /// Stream Object | 25 | /// Stream Object |
26 | -class PdfObjectStream extends PdfObject { | 26 | +class PdfObjectStream extends PdfObjectDict { |
27 | /// Constructs a stream object to store some data | 27 | /// Constructs a stream object to store some data |
28 | PdfObjectStream( | 28 | PdfObjectStream( |
29 | PdfDocument pdfDocument, { | 29 | PdfDocument pdfDocument, { |
@@ -19,7 +19,7 @@ import 'data_types.dart'; | @@ -19,7 +19,7 @@ import 'data_types.dart'; | ||
19 | import 'document.dart'; | 19 | import 'document.dart'; |
20 | import 'graphic_stream.dart'; | 20 | import 'graphic_stream.dart'; |
21 | import 'graphics.dart'; | 21 | import 'graphics.dart'; |
22 | -import 'object.dart'; | 22 | +import 'object_dict.dart'; |
23 | import 'object_stream.dart'; | 23 | import 'object_stream.dart'; |
24 | import 'page_format.dart'; | 24 | import 'page_format.dart'; |
25 | 25 | ||
@@ -39,7 +39,7 @@ enum PdfPageRotation { | @@ -39,7 +39,7 @@ enum PdfPageRotation { | ||
39 | } | 39 | } |
40 | 40 | ||
41 | /// Page object, which will hold any contents for this page. | 41 | /// Page object, which will hold any contents for this page. |
42 | -class PdfPage extends PdfObject with PdfGraphicStream { | 42 | +class PdfPage extends PdfObjectDict with PdfGraphicStream { |
43 | /// This constructs a Page object, which will hold any contents for this | 43 | /// This constructs a Page object, which will hold any contents for this |
44 | /// page. | 44 | /// page. |
45 | PdfPage( | 45 | PdfPage( |
@@ -16,11 +16,11 @@ | @@ -16,11 +16,11 @@ | ||
16 | 16 | ||
17 | import 'data_types.dart'; | 17 | import 'data_types.dart'; |
18 | import 'document.dart'; | 18 | import 'document.dart'; |
19 | -import 'object.dart'; | 19 | +import 'object_dict.dart'; |
20 | import 'page.dart'; | 20 | import 'page.dart'; |
21 | 21 | ||
22 | /// PdfPageList object | 22 | /// PdfPageList object |
23 | -class PdfPageList extends PdfObject { | 23 | +class PdfPageList extends PdfObjectDict { |
24 | /// This constructs a [PdfPageList] object. | 24 | /// This constructs a [PdfPageList] object. |
25 | PdfPageList(PdfDocument pdfDocument) : super(pdfDocument, type: '/Pages'); | 25 | PdfPageList(PdfDocument pdfDocument) : super(pdfDocument, type: '/Pages'); |
26 | 26 |
@@ -17,11 +17,12 @@ | @@ -17,11 +17,12 @@ | ||
17 | import 'data_types.dart'; | 17 | import 'data_types.dart'; |
18 | import 'document.dart'; | 18 | import 'document.dart'; |
19 | import 'object.dart'; | 19 | import 'object.dart'; |
20 | +import 'object_dict.dart'; | ||
20 | import 'stream.dart'; | 21 | import 'stream.dart'; |
21 | 22 | ||
22 | enum PdfSigFlags { signaturesExist, appendOnly } | 23 | enum PdfSigFlags { signaturesExist, appendOnly } |
23 | 24 | ||
24 | -class PdfSignature extends PdfObject { | 25 | +class PdfSignature extends PdfObjectDict { |
25 | PdfSignature( | 26 | PdfSignature( |
26 | PdfDocument pdfDocument, { | 27 | PdfDocument pdfDocument, { |
27 | required this.crypto, | 28 | required this.crypto, |
-
Please register or login to post a comment