Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table in wrong position if there is more than one table in the same page #347

Open
zhouxy-maker opened this issue Nov 14, 2024 · 0 comments

Comments

@zhouxy-maker
Copy link

zhouxy-maker commented Nov 14, 2024

For the file table.py in marker/tables/table.py , in the function format_tables(doc,pages: List[Page]):
The original code
table_insert_points[table_idx] = max(0, block_idx - len( blocks_to_remove)) # Where to insert the new table
The code below used to record the positions of the table blocks. blocks_to_remove, here means the other kind of blocks except table block. table_insert_points[table_idx] is used to record the where the table should be insert as follow:

insert_point = table_insert_points[table_idx]
insert_point = min(insert_point, len(new_page_blocks))
new_page_blocks.insert(insert_point, table_block)

When there is more than 1 table in the same pdf page. the index of the table should consider the previous tables in the same page inserted already.
The new code should be like this, in this way all the tables in the same page are in the correct order.

table_insert_points[table_idx] = max(0, block_idx - len( blocks_to_remove)+table_idx)  # Where to insert the new table
@zhouxy-maker zhouxy-maker changed the title table in wrong position if Table in wrong position if there is more than one table in the same page Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant