feat: expose PDF page indirect object number via EPDF_GetPageObjNum#577
Open
mpogodin-readdle wants to merge 2 commits intoembedpdf:mainfrom
Open
feat: expose PDF page indirect object number via EPDF_GetPageObjNum#577mpogodin-readdle wants to merge 2 commits intoembedpdf:mainfrom
mpogodin-readdle wants to merge 2 commits intoembedpdf:mainfrom
Conversation
|
@mpogodin-readdle is attempting to deploy a commit to the OpenBook Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PDF pages have a stable indirect object number in the PDF file structure (
/Type /PagedictionaryGetObjNum()). This number is stable across page reordering, insertion, and deletion — unlike the page index, which shifts whenever pages are moved. This PR exposes that number through the@embedpdfstack so consumers can use it as a permanent, stable page reference.Use case: features like annotations and AI citations that must survive page reordering. The page index changes when pages are moved; the PDF object number does not.
Changes
@embedpdf/pdfiumEPDF_GetPageObjNum(document, page_index) → intC++ wrapper inbuild/code/cpp/main.cppCPDFDocumentFromFPDFDocument→GetPageDictionary→GetObjNum()from internal PDFium APIs-1if the document or page dictionary is invalidEPDF_GetPageObjNumprototype tobuild/code/cpp/ext_api.h(picked up by the AST export generator)-I.../pdfium-srctocompile.esm.shandcompile.shto allow internal PDFium header access frommain.cppEPDF_GetPageObjNumbinding insrc/vendor/functions.ts,pdfium.js, andpdfium.cjs@embedpdf/modelsobjectNumber?: numbertoPdfPageObjectwith JSDoc explaining stability semantics@embedpdf/enginesopenDocumentBuffer, callsEPDF_GetPageObjNumafter rotation and spreadsobjectNumberonto eachPdfPageObjecttypeof epdfGetPageObjNum === 'function'— existing builds without the new WASM export continue working unaffected (objectNumberis simplyundefined)WASM rebuild required
Backward Compatibility
No breaking changes. The
objectNumberfield is optional onPdfPageObject. Older WASM builds silently skip the call and leave the field absent. Consumers must check forundefinedbefore using it.Testing
@embedpdf/modelsand@embedpdf/pdfiumbuild cleanly@embedpdf/enginesproduces no new errorsEPDF_GetPageRotationByIndex