Showing
2 changed files
with
10 additions
and
18 deletions
@@ -96,31 +96,28 @@ class PdfOutput { | @@ -96,31 +96,28 @@ class PdfOutput { | ||
96 | } | 96 | } |
97 | 97 | ||
98 | // now the trailer object | 98 | // now the trailer object |
99 | - os.putString('trailer\n<<\n'); | 99 | + os.putString('trailer\n'); |
100 | + | ||
101 | + final Map<String, PdfStream> params = <String, PdfStream>{}; | ||
100 | 102 | ||
101 | // the number of entries (REQUIRED) | 103 | // the number of entries (REQUIRED) |
102 | - os.putString('/Size '); | ||
103 | - os.putString((offsets.length + 1).toString()); | ||
104 | - os.putString('\n'); | 104 | + params['/Size'] = PdfStream.intNum(offsets.length + 1); |
105 | 105 | ||
106 | // the /Root catalog indirect reference (REQUIRED) | 106 | // the /Root catalog indirect reference (REQUIRED) |
107 | if (rootID != null) { | 107 | if (rootID != null) { |
108 | - os.putString('/Root '); | ||
109 | - os.putStream(rootID.ref()); | ||
110 | - os.putString('\n'); | 108 | + params['/Root'] = rootID.ref(); |
111 | } else { | 109 | } else { |
112 | throw Exception('Root object is not present in document'); | 110 | throw Exception('Root object is not present in document'); |
113 | } | 111 | } |
114 | 112 | ||
115 | // the /Info reference (OPTIONAL) | 113 | // the /Info reference (OPTIONAL) |
116 | if (infoID != null) { | 114 | if (infoID != null) { |
117 | - os.putString('/Info '); | ||
118 | - os.putStream(infoID.ref()); | ||
119 | - os.putString('\n'); | 115 | + params['/Info'] = infoID.ref(); |
120 | } | 116 | } |
121 | 117 | ||
122 | // end the trailer object | 118 | // end the trailer object |
123 | - os.putString('>>\nstartxref\n$xref\n%%EOF\n'); | 119 | + os.putDictionary(params); |
120 | + os.putString('\nstartxref\n$xref\n%%EOF\n'); | ||
124 | } | 121 | } |
125 | 122 | ||
126 | /// Writes a block of references to the Pdf file | 123 | /// Writes a block of references to the Pdf file |
@@ -184,13 +184,8 @@ class PdfStream { | @@ -184,13 +184,8 @@ class PdfStream { | ||
184 | PdfStream()..putDictionary(values); | 184 | PdfStream()..putDictionary(values); |
185 | 185 | ||
186 | void putObjectDictionary(Map<String, PdfObject> values) { | 186 | void putObjectDictionary(Map<String, PdfObject> values) { |
187 | - putString('<< '); | ||
188 | - values.forEach((String k, PdfObject v) { | ||
189 | - putString('$k '); | ||
190 | - putStream(v.ref()); | ||
191 | - putString(' '); | ||
192 | - }); | ||
193 | - putString('>>'); | 187 | + putDictionary(values.map((String string, PdfObject object) => |
188 | + MapEntry<String, PdfStream>(string, object.ref()))); | ||
194 | } | 189 | } |
195 | 190 | ||
196 | int get offset => _stream.length; | 191 | int get offset => _stream.length; |
-
Please register or login to post a comment