You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original document where pages were rotated is changed after running find_tables. page_rotation_reset does not return page to original state.
How to reproduce the bug
Steps to reproduce:
Find tables on page, that is rotated. Page rotation is 90 degrees in the example.
Save current document
Page has changed rotation in the original document
Expected behavior:
Original document page is not changed after finding tables
page_rotation_reset returns page to original state
Actual behavior:
Original document page is rotated after finding tables
page_rotation_reset does not return page to original state
Looks like the rotated page is the result page from page_rotation_set0
import fitz
from fitz.table import find_tables
doc = fitz.Document("sample.pdf")
for page in doc.pages():
for table in find_tables(page):
for cell in table.cells:
rect = fitz.Rect(*cell)
highlight = page.add_rect_annot(rect)
highlight.update()
doc.save("sample_output.pdf")
Error identified and fixed developed. Will soon be published.
If you are interested in testing the solution, use this table.py in the branch that fixes it.
BTW: to mark table cells in a rotated page, you must multiply them with page.derotation_matrix, as shown here:
Description of the bug
Original document where pages were rotated is changed after running
find_tables
.page_rotation_reset
does not return page to original state.How to reproduce the bug
Steps to reproduce:
Expected behavior:
page_rotation_reset
returns page to original stateActual behavior:
page_rotation_reset
does not return page to original statepage_rotation_set0
Sample document and document with changed page are attached:
sample.pdf
sample_output.pdf
PyMuPDF version
1.23.15
Operating system
Windows
Python version
3.9
The text was updated successfully, but these errors were encountered: