Commit ff69773b35480de41f86f410a120524c4d57d5c0

Authored by m-holger
1 parent 9dea7d30

Fix warnings in QPDF::getAllPagesInternal

libqpdf/QPDF_pages.cc
@@ -107,10 +107,7 @@ QPDF::getAllPagesInternal( @@ -107,10 +107,7 @@ QPDF::getAllPagesInternal(
107 } 107 }
108 visited.insert(cur_node_og); 108 visited.insert(cur_node_og);
109 if (!cur_node.isDictionaryOfType("/Pages")) { 109 if (!cur_node.isDictionaryOfType("/Pages")) {
110 - warn(  
111 - qpdf_e_damaged_pdf,  
112 - "page tree node",  
113 - m->file->getLastOffset(), 110 + cur_node.warnIfPossible(
114 "/Type key should be /Pages but is not; overriding"); 111 "/Type key should be /Pages but is not; overriding");
115 cur_node.replaceKey("/Type", "/Pages"_qpdf); 112 cur_node.replaceKey("/Type", "/Pages"_qpdf);
116 } 113 }
@@ -140,10 +137,7 @@ QPDF::getAllPagesInternal( @@ -140,10 +137,7 @@ QPDF::getAllPagesInternal(
140 kids.setArrayItem(i, kid); 137 kids.setArrayItem(i, kid);
141 } 138 }
142 if (!kid.isDictionaryOfType("/Page")) { 139 if (!kid.isDictionaryOfType("/Page")) {
143 - warn(  
144 - qpdf_e_damaged_pdf,  
145 - "page tree node",  
146 - this->m->file->getLastOffset(), 140 + kid.warnIfPossible(
147 "/Type key should be /Page but is not; overriding"); 141 "/Type key should be /Page but is not; overriding");
148 kid.replaceKey("/Type", "/Page"_qpdf); 142 kid.replaceKey("/Type", "/Page"_qpdf);
149 } 143 }
qpdf/qtest/qpdf/no-pages-types-fix.out
1 -WARNING: no-pages-types.pdf (page tree node, offset 307): /Type key should be /Pages but is not; overriding  
2 -WARNING: no-pages-types.pdf (page tree node, offset 307): /Type key should be /Page but is not; overriding 1 +WARNING: no-pages-types.pdf, object 2 0 at offset 73: /Type key should be /Pages but is not; overriding
  2 +WARNING: no-pages-types.pdf, object 3 0 at offset 145: /Type key should be /Page but is not; overriding
3 qpdf: operation succeeded with warnings; resulting file may have some problems 3 qpdf: operation succeeded with warnings; resulting file may have some problems
qpdf/qtest/qpdf/no-pages-types.out
@@ -2,6 +2,6 @@ checking no-pages-types.pdf @@ -2,6 +2,6 @@ checking no-pages-types.pdf
2 PDF Version: 1.3 2 PDF Version: 1.3
3 File is not encrypted 3 File is not encrypted
4 File is not linearized 4 File is not linearized
5 -WARNING: no-pages-types.pdf (page tree node, offset 135): /Type key should be /Pages but is not; overriding  
6 -WARNING: no-pages-types.pdf (page tree node, offset 307): /Type key should be /Page but is not; overriding 5 +WARNING: no-pages-types.pdf, object 2 0 at offset 73: /Type key should be /Pages but is not; overriding
  6 +WARNING: no-pages-types.pdf, object 3 0 at offset 145: /Type key should be /Page but is not; overriding
7 qpdf: operation succeeded with warnings 7 qpdf: operation succeeded with warnings