Skip to content

pdf:charsPerPage is broken for nested PDFs #486

Closed

Description

@ExtReMLapin

Example :

type(metaInf["pdf:charsPerPage"][-1])
<class 'list'>
type(metaInf["pdf:charsPerPage"][0])
<class 'str'>

Test PDF :

d0305b35-7e69-4e1d-a9ed-8a59178d1ff8.pdf

Activity

  1. changed the title [-]`pdf:charsPerPage` is fuckedup on nested PDFs[/-] [+]`pdf:charsPerPage` is broken for nested PDFs[/+] on Apr 26, 2026
  2. chrismattmann commented on Apr 26, 2026

    @chrismattmann
    Owner

    Please see my comments on #487

  3. added this to the tika-next milestone on Apr 26, 2026
  4. ExtReMLapin commented on Apr 26, 2026

    @ExtReMLapin
    Author

    I'm pretty sure the title was fine

  5. chrismattmann commented on Apr 26, 2026

    @chrismattmann
    Owner

    I'm pretty sure the title was fine

    And I'm not sure, actually, which is why I changed it. Please don't use profanity in issue titles or anywhere in this repo.

  6. chrismattmann commented on Jun 8, 2026

    @chrismattmann
    Owner

    I don't think this is a bug and in fact changing this would change the default behavior that people have been using for a while. Thanks anyways!

  7. ExtReMLapin commented on Jun 8, 2026

    @ExtReMLapin
    Author

    I don't think this is a bug

    Have you tried running it with Tika rest api and using the Tika python lib, it's clear to us at the office it's a bug

  8. ExtReMLapin commented on Jun 8, 2026

    @ExtReMLapin
    Author

    Alright now re-reading the whole thing I feel like I forgot to show a before-after delta and compare it to tika rest behavior.

    (Out of bandwidth with everything tbh)


    Follow-up with actual output. Clean install, stock tika==3.1.0 + tika-server 3.1.0, the PDF above (very first post), no patches:

    from tika import parser
    v = parser.from_file("d0305b35-7e69-4e1d-a9ed-8a59178d1ff8.pdf")["metadata"]["pdf:charsPerPage"]
    print(len(v), sorted({type(e).__name__ for e in v}))
    print(type(v[0]).__name__, type(v[-1]).__name__)
    sum(int(x) for x in v)

    Before (current main):

    193 ['list', 'str']
    str list
    TypeError: int() argument must be a string ... not 'list'
    

    After #487:

    381 ['str']
    str str
    1151171
    

    This PDF is 3 nested PDFs. /rmeta returns charsPerPage as a list for each (lengths 191, 17, 173). _parse keeps the first one flat, then appends each later list as a single element instead of concatenating, so you end up with 191 strings followed by 2 lists-of-strings in the same value. Normal iteration over it breaks (the TypeError above). #487 flattens it to 381 strings and it works.

  9. modified the milestones: tika-next, 3.3.2 on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions