diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-12-16 20:36:21 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-12-16 21:07:48 +0100 |
commit | 9bb6f570ec73c6154748596d04a6f10c41c57721 (patch) | |
tree | a677b2ca53d621cd9e2030196803397ab868d12c /include | |
parent | f072be032fe921617ba5f78a004ee73c75caf6bd (diff) | |
download | qpdf-9bb6f570ec73c6154748596d04a6f10c41c57721.tar.zst |
C API: add functions for working with pages (fixes #594)
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/qpdf-c.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/qpdf/qpdf-c.h b/include/qpdf/qpdf-c.h index 9d121060..4a6eb3a5 100644 --- a/include/qpdf/qpdf-c.h +++ b/include/qpdf/qpdf-c.h @@ -788,6 +788,67 @@ extern "C" { char const* qpdf_oh_unparse_resolved(qpdf_data qpdf, qpdf_oh oh); QPDF_DLL char const* qpdf_oh_unparse_binary(qpdf_data qpdf, qpdf_oh oh); + + /* PAGE FUNCTIONS */ + + /* The first time a page function is called, qpdf will traverse + * the /Pages tree. Subsequent calls to retrieve the number of + * pages or a specific page run in constant time as they are + * accessing the pages cache. If you manipulate the page tree + * outside of these functions, you should call + * qpdf_update_all_pages_cache. See comments for getAllPages() and + * updateAllPagesCache() in QPDF.hh. + */ + + /* For each function, the corresponding method in QPDF.hh is + * referenced. Please see comments in QPDF.hh for details. + */ + + /* calls getAllPages(). On error, returns -1 and sets error for + * qpdf_get_error. */ + QPDF_DLL + int qpdf_get_num_pages(qpdf_data qpdf); + /* returns uninitialized object if out of range */ + QPDF_DLL + qpdf_oh qpdf_get_page_n(qpdf_data qpdf, size_t zero_based_index); + + /* updateAllPagesCache() */ + QPDF_DLL + QPDF_ERROR_CODE qpdf_update_all_pages_cache(qpdf_data qpdf); + + /* findPage() -- return zero-based index. If page is not found, + * return -1 and save the error to be retrieved with + * qpdf_get_error. + */ + QPDF_DLL + int qpdf_find_page_by_id(qpdf_data qpdf, int objid, int generation); + QPDF_DLL + int qpdf_find_page_by_oh(qpdf_data qpdf, qpdf_oh oh); + + /* pushInheritedAttributesToPage() */ + QPDF_DLL + QPDF_ERROR_CODE qpdf_push_inherited_attributes_to_page(qpdf_data qpdf); + + /* Functions that add pages may add pages from other files. If + * adding a page from the same file, newpage_qpdf and qpdf are the + * same. + /*/ + + /* addPage() */ + QPDF_DLL + QPDF_ERROR_CODE qpdf_add_page( + qpdf_data qpdf, + qpdf_data newpage_qpdf, qpdf_oh newpage, + QPDF_BOOL first); + /* addPageAt() */ + QPDF_DLL + QPDF_ERROR_CODE qpdf_add_page_at( + qpdf_data qpdf, + qpdf_data newpage_qpdf, qpdf_oh newpage, + QPDF_BOOL before, qpdf_oh refpage); + /* removePage() */ + QPDF_DLL + QPDF_ERROR_CODE qpdf_remove_page(qpdf_data qpdf, qpdf_oh page); #ifdef __cplusplus } #endif |