Repository navigation
Conversation
process_pdf_mem_with_options parses the file and recomputes detection, font CMaps and the structure tree on every call, even for one page. LoadedPdf::open loads once; process_pages runs the existing pipeline (now a LoadedPdf method that borrows the document, which the one-shot functions also call) and caches those document-wide results. Adds PartialEq to DetectionConfig/ScanStrategy and Clone to PdfTypeResult for the detection cache.
new PdfDocument(data, password?) parses once; pageCount and processPages(options) reuse the parsed document. Documented in the wasm README and CHANGELOG.
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Shadow auto-approve: would auto-approve with 3 open P3 issues. Adds optional Rust/WebAssembly PDF handles that parse once and cache document-derived data across repeated page processing, while one-shot APIs delegate to the same pipeline; integration tests pin equivalence with one-shot results.
Reply to a comment to ask cubic a question or push back. It learns from your replies.
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.
View guided diff | Re-trigger cubic
Fix the undeclared `password` in the PdfDocument README example, reword the changelog sentence on API equivalence, and clarify that detection is cached only for the most recent DetectionConfig. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qPK5UkzZdiiQ8q97sdRSq
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds LoadedPdf/PdfDocument handles that parse a PDF once and process it repeatedly; one-shot entry points now share the same pipeline. Equivalence tests and docs keep this bounded and clearly beneficial.
View guided diff | Re-trigger cubic
Currently the whole PDF doc is re-processed for extracting a new page range. This PR adds an API to let the API caller hold a loaded PDF doc so that later extraction does not require re-processing. I did a benchmark with NASA/TM-2014-217388 (release build, NASA PDF, one page per call, markdown asserted identical):
LoadedPdfLoadedPdf(Rust) andPdfDocument(WebAssembly) open a PDF once and process it any number of times:LoadedPdf::process_pages(options)andnew PdfDocument(data, password?).processPages(options)give the resultprocess_pdf_mem_with_optionsandprocessPdfgive for the same options, without parsing the file again. Detection, the font CMaps and the structure tree are computed by the first call that needs them and kept.This PR is implemented with the assistance from AI
Summary by cubic
Adds
LoadedPdf(Rust) andPdfDocument(WebAssembly) handles that parse a PDF once and process any pages of it any number of times.process_pdf_mem_with_optionsandprocessPdfre-parse the whole file on every call even for one page; opening once drops per-page processing from ~36 ms to ~1.2 ms on a 197-page benchmark PDF.Notes
LoadedPdf::process_pages(options)andnew PdfDocument(data, password?).processPages(options)return the same result as the one-shot functions for the same options.DetectionConfigonly; the font CMaps and the structure tree are computed by the first call that needs them and kept.process_pagesignoresoptions.passwordsince the document is already open;page_count, document type, and the OCR page list still describe the whole document.Written for commit 118cf04. Summary will update on new commits.