Repository navigation
[pdf] Upgrade to pypdfium2 v5 - #22
Merged
Merged
Conversation
Adapt to the API changes: the outline items are now bookmarks, page objects take a container argument, get_pos() became get_bounds(), the text render mode moved to the text object and pages must be registered with their document. Newer pdfium computes the loose character box from the real font ascent and descent, which breaks the layout heuristics. Compute the previous definition instead, including its single precision rounding. It also generates fewer spaces, so add back the one between a bullet point and its text for the list detection. Fix the named destination lookup, which passed the wrong ctypes types.
5 tasks done
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.
pypdfium2 v4 is getting a bit long in the tooth, so this moves to v5.14.0. The API breaks were the easy part, the newer pdfium underneath also quietly changed its text extraction, which is of course exactly what all the layout heuristics are tuned to, lol.
containerargument for page objects,get_pos()->get_bounds(), text render mode via the text object, pages registered with their document.Document.destinations, which passed the wrong ctypes types and never worked, whoops.cxxheaderparserintools/requirements.txt.Missing: the remaining 813 differing hunks (of 5.7M lines) are almost all whitespace from spaces that pdfium no longer generates (formulas,
. .dot leaders), plus ~40 sub/superscript placements inside math formulas. A general gap-based space insertion fixed those but added spurious spaces elsewhere (TIM1 /2), so meh, only the bullets get one.Character.weightnow reports the real 400/700 instead of 440/690 and the file identifiers are 16 bytes instead of 15, neither is used by the converter.