Skip to content

Commit

Permalink
remove byref
Browse files Browse the repository at this point in the history
  • Loading branch information
iammosespaulr committed Jan 15, 2025
1 parent 38f1500 commit 69c2df0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 5 additions & 1 deletion pdftext/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ def dictionary_output(
workers=None
) -> Pages:
pages: Pages = _get_pages(pdf_path, page_range, workers=workers, flatten_pdf=flatten_pdf, quote_loosebox=quote_loosebox)

if not disable_links:
add_links_and_refs(pages, _load_pdf(pdf_path, False))
pdf = _load_pdf(pdf_path, False)
add_links_and_refs(pages, pdf)
pdf.close()

for page in pages:
page_width, page_height = page["width"], page["height"]
for block in page["blocks"]:
Expand Down
11 changes: 3 additions & 8 deletions pdftext/pdf/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ def _get_dest_position(dest) -> Optional[Tuple[float, float]]:
y_coord = ctypes.c_float()
zoom_level = ctypes.c_float()
success = pdfium_c.FPDFDest_GetLocationInPage(
dest,
ctypes.byref(has_x),
ctypes.byref(has_y),
ctypes.byref(has_zoom),
ctypes.byref(x_coord),
ctypes.byref(y_coord),
ctypes.byref(zoom_level)
dest, has_x, has_y, has_zoom,
x_coord, y_coord, zoom_level
)
if success:
if has_x.value and has_y.value:
Expand Down Expand Up @@ -78,7 +73,7 @@ def get_links(page_idx: int, pdf: pdfium.PdfDocument) -> List[Link]:
continue

fs_rect = pdfium_c.FS_RECTF()
success = pdfium_c.FPDFAnnot_GetRect(annot, ctypes.byref(fs_rect))
success = pdfium_c.FPDFAnnot_GetRect(annot, fs_rect)
if not success:
continue

Expand Down

0 comments on commit 69c2df0

Please sign in to comment.