Skip to content

Commit

Permalink
Page rotation patch
Browse files Browse the repository at this point in the history
  • Loading branch information
VikParuchuri committed Dec 3, 2024
1 parent 9f6dcf8 commit 9001bc2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pdftext/pdf/chars.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def get_pdfium_chars(pdf, page_range, flatten_pdf, fontname_sample_freq=settings
page = pdf.get_page(page_idx)

text_page = page.get_textpage()
page_rotation = page.get_rotation()
try:
page_rotation = page.get_rotation()
except KeyError:
# This happens on some PDFs, where pdfium_i.RotationToDegrees[ pdfium_c.FPDFPage_GetRotation(self) ] throws a KeyError -1
page_rotation = 0

bbox = page.get_bbox()
page_width = math.ceil(abs(bbox[2] - bbox[0]))
page_height = math.ceil(abs(bbox[1] - bbox[3]))
Expand Down

0 comments on commit 9001bc2

Please sign in to comment.