Display empty dictionnary inside empty objects + Add line return before endobject if there is not

This commit is contained in:
Grégory Soutadé 2022-03-12 21:09:52 +01:00
parent b540646199
commit c7c665aa8f

View File

@ -37,12 +37,30 @@ namespace uPDFParser
res << " " << indirectOffset << "\n"; res << " " << indirectOffset << "\n";
else else
{ {
bool needLineReturn = false;
if (!_dictionary.empty()) if (!_dictionary.empty())
res << _dictionary.str(); res << _dictionary.str();
else
{
if (!_data.size())
res << "<<>>\n";
else
needLineReturn = true;
}
std::vector<DataType*>::iterator it; std::vector<DataType*>::iterator it;
for(it=_data.begin(); it!=_data.end(); 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"; res << "endobj\n";