2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-04-08 01:01:50 +00:00

Use BaseHandle::operator QPDFObjGen in examples

This commit is contained in:
m-holger 2025-03-08 14:01:46 +00:00
parent f40a96bdeb
commit 947e77530c
3 changed files with 7 additions and 8 deletions

View File

@ -50,7 +50,7 @@ generate_page_map(QPDF& qpdf)
QPDFPageDocumentHelper dh(qpdf); QPDFPageDocumentHelper dh(qpdf);
int n = 0; int n = 0;
for (auto const& page: dh.getAllPages()) { for (auto const& page: dh.getAllPages()) {
page_map[page.getObjectHandle().getObjGen()] = ++n; page_map[page] = ++n;
} }
} }
@ -104,15 +104,14 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector<int> numbers)
QPDFObjectHandle dest_page = outline.getDestPage(); QPDFObjectHandle dest_page = outline.getDestPage();
if (!dest_page.isNull()) { if (!dest_page.isNull()) {
QTC::TC("examples", "pdf-bookmarks dest"); QTC::TC("examples", "pdf-bookmarks dest");
QPDFObjGen og = dest_page.getObjGen(); if (page_map.count(dest_page)) {
if (page_map.count(og)) { target = std::to_string(page_map[dest_page]);
target = std::to_string(page_map[og]);
} }
} }
std::cout << "[ -> " << target << " ] "; std::cout << "[ -> " << target << " ] ";
} }
std::cout << outline.getTitle() << std::endl; std::cout << outline.getTitle() << '\n';
} }
void void

View File

@ -48,7 +48,7 @@ ImageInverter::registerImage(
// class from ever being deleted since the reference count will never drop to zero (and // class from ever being deleted since the reference count will never drop to zero (and
// std::shared_ptr doesn't have weak references). // std::shared_ptr doesn't have weak references).
QPDFObjGen og(image.getObjGen()); QPDFObjGen og(image);
// Store information about the images based on the object and generation number. Recall that a // Store information about the images based on the object and generation number. Recall that a
// single image object may be used more than once, so no need to update the same stream multiple // single image object may be used more than once, so no need to update the same stream multiple
// times. // times.

View File

@ -84,13 +84,13 @@ FuzzHelper::testPages()
pldh.getLabelForPage(pageno); pldh.getLabelForPage(pageno);
QPDFObjectHandle page_obj(page.getObjectHandle()); QPDFObjectHandle page_obj(page.getObjectHandle());
page_obj.getJSON(JSON::LATEST, true).unparse(); page_obj.getJSON(JSON::LATEST, true).unparse();
odh.getOutlinesForPage(page_obj.getObjGen()); odh.getOutlinesForPage(page_obj);
for (auto& aoh: afdh.getWidgetAnnotationsForPage(page)) { for (auto& aoh: afdh.getWidgetAnnotationsForPage(page)) {
afdh.getFieldForAnnotation(aoh); afdh.getFieldForAnnotation(aoh);
} }
} catch (QPDFExc& e) { } catch (QPDFExc& e) {
std::cerr << "page " << pageno << ": " << e.what() << std::endl; std::cerr << "page " << pageno << ": " << e.what() << '\n';
} }
} }
} }