Add OCRModule::PageNeedsOCR sample usage (Python, Ruby, PHP, Go) - #223
Open
igor-pdftron wants to merge 2 commits into
Open
Add OCRModule::PageNeedsOCR sample usage (Python, Ruby, PHP, Go)#223igor-pdftron wants to merge 2 commits into
igor-pdftron wants to merge 2 commits into
Conversation
…ython, Ruby, PHP, Go Adds a new usage example to the OCRTest sample apps demonstrating OCRModule::PageNeedsOCR, mirroring the C/C++/Java/ObjC/.NET samples added in ApryseSDK/PDFTronCore. The example opens german_kids_song.pdf, checks whether page 1 needs OCR, and conditionally runs OCR only if needed, saving to a *_conditional output file. No .i interface file changes are required: PDFNetPHP.i, PDFNetPython.i, PDFNetRuby.i, and PDFTronGo/pdftron.i all %include PDF/OCRModule.h unmodified, so the new PageNeedsOCR binding is picked up automatically once built against an updated PDFNetC header/binary. Co-authored-by: Copilot <[email protected]>
Corrected the Example 7 comment to accurately describe passing process_invisible_text as false, matching the same fix applied to the PDFTronCore OCRTest samples after Copilot code review flagged the same true/false mismatch. Co-authored-by: Copilot <[email protected]>
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.
Description
Adds a new usage example (Example 7) to the
OCRTestsample apps for Python, Ruby, PHP, and Go, demonstrating theOCRModule::PageNeedsOCRmethod that was added to the underlying PDFTronCore SDK.Context/Why?
OCRModule::PageNeedsOCRwas newly exposed across the C, C++/Objective-C, Java, and .NET wrapper layers in ApryseSDK/PDFTronCore #6800, letting callers check whether a page needs OCR (e.g. has no extractable text) before running OCR on it. Since PDFNetWrappers' PHP, Ruby, Python, and Go bindings are generated via SWIG directly from the same C++ header, the method binding itself required no changes here — but the sample apps needed an example showing how to call it from each of these languages so users know it's available and how to use it.Implementation notes
PDFNetPHP/PDFNetPHP.i,PDFNetPython/PDFNetPython.i,PDFNetRuby/PDFNetRuby.i,PDFTronGo/pdftron.i) that each does%include "PDF/OCRModule.h"with no%rename/%ignorerules forOCRModulemethods, soPageNeedsOCRis auto-exposed once built against an updatedPDFNetCheader/binary — no.ifile edits were necessary.GetPage(1)) rather than assuming:doc.GetPage(1)in Python/Ruby/Go,$doc->GetPage(1)in PHP.OCRModulePageNeedsOCR(doc, page, bool)) consistent with other static/class-level calls in the Go bindings (e.g.OCRModuleProcessPDF), rather than adoc.Method()-style call.PDFNetC/in this repo is a placeholder populated with headers/binaries at build time, so no vendored header changes were needed or possible here.How to verify
PageNeedsOCRwrapper (from PDFTronCore PR #6800).OCRTestsample for that language (Samples/OCRTest/{PYTHON,RUBY,PHP,GO}).german_kids_song.pdf, callsPageNeedsOCRon page 1, prints whether OCR is needed, and only runs OCR conditionally, saving to a*_conditionaloutput file.git diff --staton this branch shows additive-only changes (123 insertions, 0 deletions) across 4 files.Changelog entry
Added a Python/Ruby/PHP/Go sample demonstrating
OCRModule.PageNeedsOCR, which allows checking whether a page requires OCR before running OCR processing on it.🤖 Generated with Copilot CLI