From 04c4f44324c924b6c5a121259495ecc652e04334 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Wed, 25 Sep 2024 17:04:25 +0300 Subject: [PATCH] Get name from simple object. For example, Image ColorSpace is the reference to other object. --- pdfio-object.c | 20 ++++++++++++++++++++ pdfio.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/pdfio-object.c b/pdfio-object.c index 89c7835..f4bc85e 100644 --- a/pdfio-object.c +++ b/pdfio-object.c @@ -267,6 +267,26 @@ pdfioObjGetDict(pdfio_obj_t *obj) // I - Object return (NULL); } +// +// 'pdfioObjGetName()' - Get the name value associated with an object. +// + +const char * // O - Dictionary or `NULL` on error +pdfioObjGetName(pdfio_obj_t *obj) // I - Object +{ + if (!obj) + return (NULL); + + if (obj->value.type == PDFIO_VALTYPE_NONE) + _pdfioObjLoad(obj); + + if (obj->value.type == PDFIO_VALTYPE_NAME) + return (obj->value.value.name); + else + return (NULL); +} + + // // '_pdfioObjGetExtension()' - Get the extension pointer for an object. diff --git a/pdfio.h b/pdfio.h index f905c82..b53a262 100644 --- a/pdfio.h +++ b/pdfio.h @@ -220,6 +220,8 @@ extern pdfio_obj_t *pdfioObjCopy(pdfio_file_t *pdf, pdfio_obj_t *srcobj) _PDFIO_ extern pdfio_stream_t *pdfioObjCreateStream(pdfio_obj_t *obj, pdfio_filter_t compression) _PDFIO_PUBLIC; extern pdfio_array_t *pdfioObjGetArray(pdfio_obj_t *obj) _PDFIO_PUBLIC; extern pdfio_dict_t *pdfioObjGetDict(pdfio_obj_t *obj) _PDFIO_PUBLIC; +extern const char *pdfioObjGetName(pdfio_obj_t *obj) _PDFIO_PUBLIC; + extern unsigned short pdfioObjGetGeneration(pdfio_obj_t *obj) _PDFIO_PUBLIC; extern size_t pdfioObjGetLength(pdfio_obj_t *obj) _PDFIO_PUBLIC; extern size_t pdfioObjGetNumber(pdfio_obj_t *obj) _PDFIO_PUBLIC;