From c7c665aa8f5b98f878634c65c3d3642b2626a0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 12 Mar 2022 21:09:52 +0100 Subject: [PATCH] Display empty dictionnary inside empty objects + Add line return before endobject if there is not --- src/uPDFParser.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/uPDFParser.cpp b/src/uPDFParser.cpp index 357c79f..1c45bf6 100644 --- a/src/uPDFParser.cpp +++ b/src/uPDFParser.cpp @@ -37,14 +37,32 @@ namespace uPDFParser res << " " << indirectOffset << "\n"; else { + bool needLineReturn = false; + if (!_dictionary.empty()) res << _dictionary.str(); + else + { + if (!_data.size()) + res << "<<>>\n"; + else + needLineReturn = true; + } std::vector::iterator it; for(it=_data.begin(); it!=_data.end(); it++) - res << (*it)->str(); + { + std::string tmp = (*it)->str(); + res << tmp; + if (tmp[tmp.size()-1] == '\n' || + tmp[tmp.size()-1] == '\r') + needLineReturn = false; + } + + if (needLineReturn) + res << "\n"; } - + res << "endobj\n"; return res.str();