| name | parxy |
| description | Document parsing and PDF manipulation using the Parxy library. Use when:
(1) Parsing PDFs or documents to extract text/structure
(2) Converting documents to markdown
(3) Batch processing multiple documents
(4) Merging, splitting, or optimizing PDFs
(5) Managing PDF attachments
|
Parxy Document Processing
Parsing Documents
from parxy_core.facade.parxy import Parxy
doc = Parxy.parse("document.pdf")
doc = Parxy.parse("document.pdf", driver_name="llamaparse", level="span")
doc = Parxy.parse(pdf_bytes)
Extraction Levels
| Level | Description |
|---|
page | Page text only |
block | Text blocks (default) |
line | Individual lines |
span | Text spans with styling |
character | Individual characters |
Document Structure
doc.filename
doc.pages
doc.metadata
page.number
page.text
page.blocks
block.text
block.bbox
block.role
Available Drivers
| Driver | Constant | Type | Best For |
|---|
| PyMuPDF | Parxy.PYMUPDF | Local | Fast local processing |
| PdfAct | Parxy.PDFACT | Self-hosted | Scientific papers, semantic roles |
| LlamaParse | Parxy.LLAMAPARSE | Cloud | Complex docs with OCR/tables |
| LLMWhisperer | Parxy.LLMWHISPERER | Cloud | Form extraction |
| Unstructured | Parxy.UNSTRUCTURED_LIBRARY | Local | Multi-format (DOCX, HTML) |
drivers = Parxy.drivers()
driver = Parxy.driver(Parxy.LLAMAPARSE)
Batch Processing
from parxy_core.facade.parxy import Parxy
from parxy_core.models import BatchTask
results = Parxy.batch(
tasks=["doc1.pdf", "doc2.pdf"],
drivers=["pymupdf"],
workers=4,
)
results = Parxy.batch(tasks=[
BatchTask(file="simple.pdf"),
BatchTask(file="complex.pdf", drivers=["llamaparse"], level="line"),
])
for result in Parxy.batch_iter(tasks=["doc1.pdf", "doc2.pdf"]):
if result.success:
print(f"{result.file}: {len(result.document.pages)} pages")
else:
print(f"{result.file} failed: {result.error}")
PDF Manipulation
Merge PDFs
from pathlib import Path
from parxy_core.facade.parxy import Parxy
Parxy.pdf.merge(
inputs=[
(Path("doc1.pdf"), None, None),
(Path("doc2.pdf"), None, None),
],
output=Path("merged.pdf"),
)
Parxy.pdf.merge(
inputs=[
(Path("doc1.pdf"), 0, 4),
(Path("doc2.pdf"), 0, 0),
],
output=Path("selected.pdf"),
)
Split PDF
pages = Parxy.pdf.split(
input_path=Path("document.pdf"),
output_dir=Path("./pages"),
prefix="doc",
)
Optimize PDF
result = Parxy.pdf.optimize(
input_path=Path("large.pdf"),
output_path=Path("small.pdf"),
scrub_metadata=True,
subset_fonts=True,
compress_images=True,
dpi_target=72,
image_quality=60,
convert_to_grayscale=False,
)
print(f"Reduced by {result['reduction_percent']:.1f}%")
PDF Attachments
from pathlib import Path
from parxy_core.services.pdf_service import PdfService
with PdfService(Path("document.pdf")) as pdf:
names = pdf.list_attachments()
pdf.add_attachment(Path("data.csv"), name="data", desc="Sales data")
content = pdf.extract_attachment("data")
pdf.remove_attachment("data")
pdf.save(Path("output.pdf"))
CLI Commands
Assuming uvx is installed, pipx can be used as well.
uvx parxy parse document.pdf --driver llamaparse --level block --format json
uvx parxy markdown document.pdf -o output/
uvx parxy markdown *.pdf --combine -o combined.md
uvx parxy pdf split document.pdf --pages 1-5 -o output/
uvx parxy pdf merge doc1.pdf doc2.pdf -o combined.pdf
uvx parxy drivers