diff options
author | Vincent Sanders <vince@kyllikki.org> | 2018-02-03 22:24:59 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2018-02-03 22:24:59 +0000 |
commit | e6af9e997df381f053f3f8c85a678ad07677c791 (patch) | |
tree | 9608ed7de269e5d2536201551678340c45433463 /src/cos_object.c | |
parent | 1ca90f384d4f2311cbf0abd44d8e4e5b7a4abb37 (diff) | |
download | libnspdf-e6af9e997df381f053f3f8c85a678ad07677c791.tar.gz libnspdf-e6af9e997df381f053f3f8c85a678ad07677c791.tar.bz2 |
correctly extract the page boundaries from the page tree
Diffstat (limited to 'src/cos_object.c')
-rw-r--r-- | src/cos_object.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/cos_object.c b/src/cos_object.c index 52731ca..12adcc9 100644 --- a/src/cos_object.c +++ b/src/cos_object.c @@ -30,6 +30,10 @@ static nspdferror cos_dump_object(const char *fmt, struct cos_object *cos_obj) printf(" type = COS_TYPE_NAMETREE\n"); break; + case COS_TYPE_NUMBERTREE: + printf(" type = COS_TYPE_NUMBERTREE\n"); + break; + case COS_TYPE_REFERENCE: printf(" type = COS_TYPE_REFERENCE\n" " u.reference->id = %lu\n" @@ -116,7 +120,6 @@ static nspdferror cos_dump_object(const char *fmt, struct cos_object *cos_obj) return NSPDFERROR_OK; - } nspdferror cos_free_object(struct cos_object *cos_obj) @@ -318,6 +321,8 @@ cos_heritable_dictionary_dictionary(struct nspdf_doc *doc, return cos_get_dictionary(doc, dict_value, value_out); } + +/* get an inheritable array object from a dictionary */ nspdferror cos_get_dictionary_array(struct nspdf_doc *doc, struct cos_object *dict, @@ -503,6 +508,41 @@ cos_get_object(struct nspdf_doc *doc, return res; } + +nspdferror +cos_get_rectangle(struct nspdf_doc *doc, + struct cos_object *cobj, + struct cos_rectangle *rect_out) +{ + nspdferror res; + struct cos_rectangle rect; + + res = nspdf__xref_get_referenced(doc, &cobj); + if (res == NSPDFERROR_OK) { + if ((cobj->type != COS_TYPE_ARRAY) || + (cobj->u.array->length != 4)) { + res = NSPDFERROR_TYPE; + } else { + res = cos_get_number(doc, cobj->u.array->values[0], &rect.llx); + if (res == NSPDFERROR_OK) { + res = cos_get_number(doc, cobj->u.array->values[1], &rect.lly); + if (res == NSPDFERROR_OK) { + res = cos_get_number(doc, cobj->u.array->values[2], &rect.urx); + if (res == NSPDFERROR_OK) { + res = cos_get_number(doc, cobj->u.array->values[3], &rect.ury); + if (res == NSPDFERROR_OK) { + *rect_out = rect; + } + } + } + } + } + } + + return res; +} + + /* * exported interface documented in cos_object.h * |