Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
pypdf_get_text,
pypdf_image_extraction,
pypdf_watermarking, tika_get_text, pdfium_image_extraction,
unpdf_markdown_get_text,
)
from pdf_benchmark.output import write_benchmark_report
from pdf_benchmark.score import get_text_extraction_score
Expand Down Expand Up @@ -218,6 +219,15 @@ def write_single_result(
last_release_date="-",
license="GPL",
),
"unpdf_markdown": Library(
"unpdf-markdown",
"unpdf_markdown",
"https://pypi.org/project/unpdf-markdown/",
text_extraction_function=unpdf_markdown_get_text,
version="0.6.4",
license="MIT",
last_release_date="2026-05-20",
),
# "borb": Library(
# "Borb",
# "borb",
Expand Down
17 changes: 17 additions & 0 deletions pdf_benchmark/library_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,23 @@ def pdfrw_watermarking(watermark_data: bytes, data: bytes) -> bytes:
return out_buffer.read()


def unpdf_markdown_get_text(data: bytes) -> str:
import unpdf
new_file, filename = tempfile.mkstemp(suffix=".pdf")
try:
with open(filename, "wb") as fp:
fp.write(data)
try:
text = unpdf.to_text(filename)
except RuntimeError as exc:
print(f"unpdf text extraction failed: {exc}")
text = ""
finally:
os.close(new_file)
os.remove(filename)
return text


def tika_get_text(data: bytes) -> str:
from tika import parser

Expand Down
1 change: 1 addition & 0 deletions requirements/main.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pymupdf
pypdfium2
pdfrw
lxml
unpdf-markdown