David PHAM-VAN

Improve pdf output

... ... @@ -96,31 +96,28 @@ class PdfOutput {
}
// now the trailer object
os.putString('trailer\n<<\n');
os.putString('trailer\n');
final Map<String, PdfStream> params = <String, PdfStream>{};
// the number of entries (REQUIRED)
os.putString('/Size ');
os.putString((offsets.length + 1).toString());
os.putString('\n');
params['/Size'] = PdfStream.intNum(offsets.length + 1);
// the /Root catalog indirect reference (REQUIRED)
if (rootID != null) {
os.putString('/Root ');
os.putStream(rootID.ref());
os.putString('\n');
params['/Root'] = rootID.ref();
} else {
throw Exception('Root object is not present in document');
}
// the /Info reference (OPTIONAL)
if (infoID != null) {
os.putString('/Info ');
os.putStream(infoID.ref());
os.putString('\n');
params['/Info'] = infoID.ref();
}
// end the trailer object
os.putString('>>\nstartxref\n$xref\n%%EOF\n');
os.putDictionary(params);
os.putString('\nstartxref\n$xref\n%%EOF\n');
}
/// Writes a block of references to the Pdf file
... ...
... ... @@ -184,13 +184,8 @@ class PdfStream {
PdfStream()..putDictionary(values);
void putObjectDictionary(Map<String, PdfObject> values) {
putString('<< ');
values.forEach((String k, PdfObject v) {
putString('$k ');
putStream(v.ref());
putString(' ');
});
putString('>>');
putDictionary(values.map((String string, PdfObject object) =>
MapEntry<String, PdfStream>(string, object.ref())));
}
int get offset => _stream.length;
... ...