readInfo method
Metadata from the document /Info, when there is any.
On a loaded document the read comes from the original file; on a new document, from what was set by setInfo.
Implementation
Map<String, String> readInfo() {
final parser = document.prev;
if (parser is! PdfDocumentParser) return const <String, String>{};
final infoObj = parser.trailer.infoObj;
if (infoObj == null) return const <String, String>{};
final object = parser.getObject(infoObj);
final dict = object?.value;
if (dict is! PdfDictToken) return const <String, String>{};
final out = <String, String>{};
dict.values.forEach((key, value) {
final resolved = parser.resolve(value);
if (resolved is PdfStringToken) {
out[key] = _decodeText(resolved.bytes);
} else if (resolved is PdfNameToken) {
out[key] = resolved.value;
}
});
return out;
}