summaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2014-12-01 20:44:47 +0100
committerJay Berkenbilt <ejb@ql.org>2014-12-29 16:17:21 +0100
commitd8900c2255d12adbe9342ea751403740ca7a826d (patch)
tree51046b6d6366bb749da6838b2f4df0dd6a25bbe9 /libqpdf
parentcaab1b0e1642bc6ee0194c7ab4c4a4de2ab22f2c (diff)
downloadqpdf-d8900c2255d12adbe9342ea751403740ca7a826d.tar.zst
Handle page tree node with no /Type
Original reported here: https://bugs.launchpad.net/ubuntu/+source/qpdf/+bug/1397413 The PDF specification says that the /Type key for nodes in the pages dictionary (both /Page and /Pages) is required, but some PDF files omit them. Use the presence of other keys to determine the type of pages tree node this is if the type key is not found.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF_pages.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc
index e8d107b3..44db064c 100644
--- a/libqpdf/QPDF_pages.cc
+++ b/libqpdf/QPDF_pages.cc
@@ -56,7 +56,20 @@ void
QPDF::getAllPagesInternal(QPDFObjectHandle cur_pages,
std::vector<QPDFObjectHandle>& result)
{
- std::string type = cur_pages.getKey("/Type").getName();
+ std::string type;
+ QPDFObjectHandle type_key = cur_pages.getKey("/Type");
+ if (type_key.isName())
+ {
+ type = type_key.getName();
+ }
+ else if (cur_pages.hasKey("/Kids"))
+ {
+ type = "/Pages";
+ }
+ else
+ {
+ type = "/Page";
+ }
if (type == "/Pages")
{
QPDFObjectHandle kids = cur_pages.getKey("/Kids");