Skip to content

Commit

Permalink
Merge pull request #2 from mara004/patch-1
Browse files Browse the repository at this point in the history
Avoid explicit pointer usage in `page_to_device()`
  • Loading branch information
VikParuchuri authored May 2, 2024
2 parents a588678 + d18d0e0 commit 65cc3c1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pdftext/pdf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ def page_to_device(page, x, y, page_width, page_height, page_rotation: int):
page_rotation = 3
else:
page_rotation = 0
device_x = ctypes.c_int()
device_y = ctypes.c_int()
device_x_ptr = ctypes.pointer(device_x)
device_y_ptr = ctypes.pointer(device_y)
width = math.ceil(page_width)
height = math.ceil(page_height)
pdfium_c.FPDF_PageToDevice(page, 0, 0, width, height, page_rotation, x, y, device_x_ptr, device_y_ptr)
device_x = ctypes.c_int()
device_y = ctypes.c_int()
pdfium_c.FPDF_PageToDevice(page, 0, 0, width, height, page_rotation, x, y, device_x, device_y)
x = device_x.value
y = device_y.value
return x, y
Expand Down Expand Up @@ -135,4 +133,4 @@ def rotate_page_bbox(bbox, angle_deg, width, height):
bbox = rotate_page_bbox(bbox, 90, width, height)
bbox = rotate_page_bbox(bbox, 180, width, height)

return bbox
return bbox

0 comments on commit 65cc3c1

Please sign in to comment.