Skip to main content

Python wrapper for Exis.PdfEditor — comprehensive PDF toolkit (find/replace, merge, split, forms, redaction, watermark, encryption, signatures, PDF/A, and more)

Project description

Exis.PdfEditor for Python

Comprehensive PDF toolkit for Python — find/replace, merge, split, form filling, redaction, image editing, watermark, Bates stamping, page editing, encryption, optimization, digital signatures, PDF/A compliance, and more.

Powered by the Exis.PdfEditor .NET library, compiled to a native binary via .NET Native AOT. No .NET runtime required.

Installation

pip install exis-pdfeditor

Platform-specific wheels are available for:

  • Windows x64 (win_amd64)
  • Linux x64 (manylinux_2_17_x86_64)
  • macOS ARM64 / Apple Silicon (macosx_11_0_arm64)

Quick start

import exis_pdfeditor

# Optional: set a license key (or use EXIS_PDF_LICENSE_KEY env var).
# Without a key, a 14-day trial is activated automatically.
exis_pdfeditor.initialize("XXXX-XXXX-XXXX-XXXX")

# Inspect a PDF (free — no license required)
info = exis_pdfeditor.inspect("document.pdf")
print(f"{info.pageCount} pages, title: {info.title}")

# Find and replace text
result = exis_pdfeditor.find_replace(
    "input.pdf", "output.pdf",
    "old text", "new text",
    case_sensitive=False,
)
print(f"{result.totalReplacements} replacements made")

Features

Feature Function
Inspect inspect(path) — metadata, fonts, pages, encryption status
Text extraction extract_text(path), extract_text_structured(path)
Find & replace find_replace(...) — regex, case-insensitive, whole-word, styling
Merge merge(paths, output)
Split split(path, output_dir)
Extract pages extract_pages(path, output, pages=[1,3,5])
Form fields list_fields(path), fill_form(path, output, fields, flatten=True)
Redaction redact(path, output, redactions)
Watermark watermark(path, output, "DRAFT", position="across")
Stamp stamp(path, output, stamp_pdf, mode="overlay")
Bates stamping bates_stamp(path, output, prefix="ABC", digits=6)
Optimize optimize(path, output, downsample_images=True)
Encrypt / Decrypt encrypt(...), decrypt(...)
Page editing rotate(...), crop(...), reorder(...), delete_pages(...), insert_blank_pages(...)
Images find_images(path), replace_image(...)
Digital signatures sign(...), verify(...)
PDF/A pdfa_validate(path), pdfa_convert(path, output)

Inspect

Retrieve metadata, page info, fonts, encryption status, and form field counts. No license required.

info = exis_pdfeditor.inspect("document.pdf")

print(f"Version:    {info.version}")
print(f"Pages:      {info.pageCount}")
print(f"Title:      {info.title}")
print(f"Author:     {info.author}")
print(f"Encrypted:  {info.isEncrypted}")
print(f"Has forms:  {info.hasFormFields} ({info.formFieldCount} fields)")
print(f"Fonts:      {info.fontsUsed}")

for page in info.pages:
    print(f"  Page {page.pageNumber}: {page.widthInPoints}x{page.heightInPoints} pt, "
          f"{page.characterCount} chars")

Text extraction

Plain text

result = exis_pdfeditor.extract_text("document.pdf")
print(result.fullText)

for page in result.pages:
    print(f"Page {page.pageNumber}: {page.text[:100]}...")

Specific pages only

result = exis_pdfeditor.extract_text("document.pdf", pages=[1, 3, 5])

Structured text (with positions and font data)

result = exis_pdfeditor.extract_text_structured("document.pdf")

for page in result.pages:
    for block in page.textBlocks:
        print(f"  [{block.x:.0f}, {block.y:.0f}] {block.fontName} {block.fontSize}pt: "
              f"{block.text}")

Find & replace

Single pair

result = exis_pdfeditor.find_replace(
    "input.pdf", "output.pdf",
    "old text", "new text",
)
print(f"{result.totalReplacements} replacements across {result.pagesModified} pages")

Multiple pairs

result = exis_pdfeditor.find_replace(
    "input.pdf", "output.pdf",
    pairs=[
        {"search": "foo", "replace": "bar"},
        {"search": "hello", "replace": "world"},
    ],
)

Regex

result = exis_pdfeditor.find_replace(
    "input.pdf", "output.pdf",
    pairs=[
        {"search": r"\d{3}-\d{2}-\d{4}", "replace": "XXX-XX-XXXX", "isRegex": True},
    ],
)

All options

result = exis_pdfeditor.find_replace(
    "input.pdf", "output.pdf",
    "confidential", "[REDACTED]",
    case_sensitive=False,
    whole_word=True,
    use_regex=False,
    page_range=[1, 2, 3],
    text_fitting="adaptive",         # none, preserve_width, fit_to_page, adaptive
    min_horizontal_scale=70,
    max_font_size_reduction=1.5,
    replacement_text_color={"r": 1, "g": 0, "b": 0},
    replacement_highlight_color={"r": 1, "g": 1, "b": 0},
    replacement_bold=True,
    replacement_underline=False,
    replacement_strikethrough=False,
    preserve_form_fields=True,
    use_incremental_update=True,
)

for detail in result.details:
    print(f"  Page {detail.pageNumber}: '{detail.originalText}' -> '{detail.replacementText}'")

Merge

exis_pdfeditor.merge(["part1.pdf", "part2.pdf", "part3.pdf"], "merged.pdf")

Split

Split a PDF into one file per page:

result = exis_pdfeditor.split("document.pdf", "output_folder/")
print(f"Split into {result.pageCount} files")
for path in result.files:
    print(f"  {path}")

Extract pages

Extract specific pages into a new PDF:

exis_pdfeditor.extract_pages("document.pdf", "pages_1_and_3.pdf", pages=[1, 3])

Form fields

List all fields

fields = exis_pdfeditor.list_fields("form.pdf")

for field in fields:
    print(f"  {field.name} ({field.type}): {field.value}")
    if field.displayName:
        print(f"    Label: {field.displayName}")
    if field.options:
        print(f"    Options: {field.options}")

Fill a form

result = exis_pdfeditor.fill_form(
    "form.pdf", "filled.pdf",
    fields={
        "FirstName": "John",
        "LastName": "Doe",
        "Email": "john@example.com",
        "AgreeToTerms": "Yes",
    },
)
print(f"Filled {result.fieldsFilled} fields, {result.fieldsNotFound} not found")

Fill and flatten (make fields non-editable)

result = exis_pdfeditor.fill_form(
    "form.pdf", "filled_flat.pdf",
    fields={"Name": "Jane Doe"},
    flatten=True,
)

Redaction

Redact text

result = exis_pdfeditor.redact(
    "document.pdf", "redacted.pdf",
    redactions=[
        {"text": "John Doe", "replaceWith": "[NAME REDACTED]"},
        {"text": r"\d{3}-\d{2}-\d{4}", "isRegex": True, "replaceWith": "[SSN]"},
    ],
)
print(f"{result.redactionsApplied} redactions applied")

Redact a specific area on a page

result = exis_pdfeditor.redact(
    "document.pdf", "redacted.pdf",
    redactions=[
        {
            "area": {"x": 100, "y": 700, "width": 200, "height": 20},
            "pageNumber": 1,
        },
    ],
)

Combined text + area redaction

result = exis_pdfeditor.redact(
    "document.pdf", "redacted.pdf",
    redactions=[
        {"text": "confidential", "caseSensitive": False},
        {"area": {"x": 50, "y": 50, "width": 500, "height": 30}, "pageNumber": 2},
    ],
)

Watermark

Basic diagonal watermark

result = exis_pdfeditor.watermark("input.pdf", "watermarked.pdf", "DRAFT")
print(f"Watermarked {result.pagesWatermarked} of {result.totalPages} pages")

All watermark options

result = exis_pdfeditor.watermark(
    "input.pdf", "watermarked.pdf",
    "CONFIDENTIAL",
    position="across",          # top, bottom, center, across
    font_size=72,
    text_color={"r": 1, "g": 0, "b": 0},
    opacity=0.15,
    page_range=[1, 2],
)

Stamp (PDF overlay / underlay)

Overlay a letterhead on top

result = exis_pdfeditor.stamp(
    "document.pdf", "stamped.pdf",
    "letterhead.pdf",
    mode="overlay",
)
print(f"Stamped {result.pagesStamped} pages")

Underlay a background behind content

result = exis_pdfeditor.stamp(
    "document.pdf", "stamped.pdf",
    "background.pdf",
    mode="underlay",
    opacity=0.5,
    page_range=[1],
)

Bates stamping

Sequential page numbering for legal production and discovery workflows. Each page receives a zero-padded identifier (e.g. ABC000001, ABC000002) rendered in a chosen corner of the visual page. Placement is relative to the page's /Rotate orientation, so mixed-rotation documents render consistently. An XMP audit block recording the range, digit width, and prefix/suffix is written to the document catalog by default.

Defaults (number starts at 1, 6 digits, bottom-right corner)

result = exis_pdfeditor.bates_stamp("input.pdf", "stamped.pdf")
print(f"Stamped pages {result.firstNumber}-{result.lastNumber}")
print(f"Digits used: {result.digitsUsed}")

Prefix, custom position, color, confidentiality label

result = exis_pdfeditor.bates_stamp(
    "input.pdf", "stamped.pdf",
    prefix="ABC",
    start_number=1,
    digits=6,                                 # -> "ABC000001"
    position="bottom_right",                  # top_left, top_center, top_right,
                                              # bottom_left, bottom_center, bottom_right
    font_size=10,
    text_color={"r": 0, "g": 0, "b": 0},
    background_color={"r": 1, "g": 1, "b": 1},  # opaque box behind stamp
    margin_inches=0.5,
    confidentiality_label="CONFIDENTIAL",     # stacked above the Bates number
)

Continuous numbering across a batch

Thread lastNumber + 1 into the next call:

next_n = 1
for path in docs:
    r = exis_pdfeditor.bates_stamp(
        path, path + ".stamped.pdf",
        prefix="ABC", start_number=next_n,
    )
    next_n = r.lastNumber + 1

Skip the cover page (legal convention)

The cover is ABC000001 in the production log even if physically unstamped:

exis_pdfeditor.bates_stamp(
    "input.pdf", "stamped.pdf",
    prefix="ABC",
    skip_first_page=True,
    counter_advances_on_skipped_pages=True,   # default
)

Stamp only selected pages

exis_pdfeditor.bates_stamp(
    "input.pdf", "stamped.pdf",
    page_range=[2, 3, 5],                     # 1-based
)

Signed input

Stamping invalidates signatures — opt in explicitly:

result = exis_pdfeditor.bates_stamp(
    "signed.pdf", "stamped.pdf",
    allow_signed_input=True,                  # result.warnings will record it
)
for w in result.warnings:
    print(f"  warning: {w}")

Suppress the XMP audit block

exis_pdfeditor.bates_stamp(
    "input.pdf", "stamped.pdf",
    write_xmp_metadata=False,
)

All options at a glance

Parameter Default Purpose
prefix / suffix "" Text bracketing the number
start_number 1 First Bates number (for batch continuation)
digits 6 Minimum zero-padded width; auto-expands if needed
position "bottom_right" Corner/edge on the visual page
font_size 10.0 Point size (Helvetica)
text_color black RGB dict {"r": 0, "g": 0, "b": 0}
background_color none Opaque rectangle behind stamp for legibility
margin_inches 0.5 Distance from trimmed page edge
confidentiality_label none e.g. "CONFIDENTIAL"
confidentiality_position same corner Override to place label elsewhere
confidentiality_font_size matches font_size Label point size
page_range all pages 1-based page numbers to stamp
skip_first_page False Skip page 1 (cover sheets)
counter_advances_on_skipped_pages True Advance counter on skipped pages
allow_signed_input False Stamp PDFs with digital signatures
write_xmp_metadata True Write an XMP audit block to the catalog

Result fields: firstNumber, lastNumber, pagesStamped, digitsUsed (equals digits unless auto-expanded), warnings (non-fatal diagnostics: digit expansion, signed-input stamped anyway, etc.).

Optimize

Default optimization (compress + deduplicate)

result = exis_pdfeditor.optimize("large.pdf", "smaller.pdf")
print(f"Reduced {result.originalSize:,} -> {result.optimizedSize:,} bytes "
      f"({result.reductionPercent:.1f}% smaller)")
print(f"  Streams compressed: {result.streamsCompressed}")
print(f"  Duplicates removed: {result.duplicatesRemoved}")

With image downsampling

result = exis_pdfeditor.optimize(
    "large.pdf", "smaller.pdf",
    downsample_images=True,
    max_image_dpi=150,
    remove_metadata=True,
)
print(f"Images downsampled: {result.imagesDownsampled}")

Encrypt & decrypt

Encrypt with a password

exis_pdfeditor.encrypt(
    "document.pdf", "protected.pdf",
    user_password="openme",
    owner_password="secret",
    permissions=["Print", "CopyText"],
)

Available permissions: Print, ModifyContents, CopyText, AddAnnotations, FillForms, PrintHighQuality, All.

Decrypt

exis_pdfeditor.decrypt("protected.pdf", "unlocked.pdf", password="openme")

Page editing

Rotate pages

result = exis_pdfeditor.rotate("input.pdf", "rotated.pdf", angle=90)
print(f"Rotated {result.pagesModified} pages")

# Rotate only specific pages
result = exis_pdfeditor.rotate("input.pdf", "rotated.pdf", angle=180, pages=[2, 4])

Crop pages

result = exis_pdfeditor.crop(
    "input.pdf", "cropped.pdf",
    rect={"x": 50, "y": 50, "width": 500, "height": 700},
)

Reorder pages

exis_pdfeditor.reorder("input.pdf", "reordered.pdf", order=[3, 1, 2])

Delete pages

exis_pdfeditor.delete_pages("input.pdf", "trimmed.pdf", pages=[2, 4])

Insert blank pages

Each insertion specifies a 0-based "after page" anchor (0 = before page 1) and an optional page size. Supported sizes: letter (default), legal, a4, a3, a5, tabloid.

exis_pdfeditor.insert_blank_pages(
    "input.pdf", "with_blanks.pdf",
    insertions=[
        {"afterPage": 0, "size": "a4"},       # before page 1
        {"afterPage": 3, "size": "letter"},   # after page 3
    ],
)

Images

Find all images

result = exis_pdfeditor.find_images("document.pdf")
print(f"Found {result.totalImages} images across {result.pagesSearched} pages")

for img in result.images:
    print(f"  Image {img.index}: {img.pixelWidth}x{img.pixelHeight} "
          f"{img.colorSpace} {img.format}")
    print(f"    Pages: {img.pageNumbers}")

Find images and save to disk

result = exis_pdfeditor.find_images("document.pdf", output_dir="extracted_images/")

Replace all images

result = exis_pdfeditor.replace_image(
    "document.pdf", "replaced.pdf",
    "new_logo.png",
)
print(f"Replaced {result.imagesReplaced} of {result.imagesFound} images")

Replace specific images by index or page

result = exis_pdfeditor.replace_image(
    "document.pdf", "replaced.pdf",
    "new_logo.jpg",
    image_indices=[0, 2],
    page_range=[1],
    scale_mode="scale_to_fit",  # match_original_size, preserve_aspect_ratio, scale_to_fit
)

Digital signatures

Sign a PDF

exis_pdfeditor.sign(
    "document.pdf", "signed.pdf",
    cert_path="certificate.pfx",
    cert_password="certpass",
    reason="Approved",
    location="New York, NY",
    signer_name="John Doe",
)

Sign with a visible signature

exis_pdfeditor.sign(
    "document.pdf", "signed.pdf",
    cert_path="certificate.pfx",
    cert_password="certpass",
    visible=True,
    page=1,
    rect={"x": 50, "y": 50, "width": 200, "height": 60},
    reason="Reviewed and approved",
)

Verify signatures

info = exis_pdfeditor.verify("signed.pdf")
print(f"Signed: {info.isSigned}")
print(f"Signer: {info.signerName}")
print(f"Valid:  {info.isValid}")
print(f"Reason: {info.reason}")
print(f"Date:   {info.signDate}")

# Verify all signatures in a multi-signed document
signatures = exis_pdfeditor.verify("multi_signed.pdf", all_signatures=True)
for sig in signatures:
    print(f"  {sig.signerName}: valid={sig.isValid}")

PDF/A compliance

Validate

result = exis_pdfeditor.pdfa_validate("document.pdf", level="2b")
print(f"Compliant: {result.isCompliant}")

if not result.isCompliant:
    for v in result.violations:
        print(f"  [{v.code}] {v.message} (auto-fixable: {v.canAutoFix})")

Convert to PDF/A

exis_pdfeditor.pdfa_convert("document.pdf", "archive.pdf", level="2b")

Supported levels: 1b, 2b, 2u, 3b, 3u.

Diagnostic structure dump

When a PDF fails to process and you can't share the file, dump_structure() produces a self-contained report you can paste into a bug report. It walks every object in the file, tallies filter chains and font subtypes, lists encryption details, and records any streams that fail to decode — without needing the original file. No license required.

Human-readable report

dump = exis_pdfeditor.dump_structure("problem.pdf")

# The dump has a built-in text report — just print it
# (or paste it into a support email / bug report)
print(dump)

Individual fields

dump = exis_pdfeditor.dump_structure("problem.pdf")

print(f"PDF version:    {dump.version}")
print(f"Pages:          {dump.pageCount}")
print(f"Total objects:  {dump.totalObjects}")
print(f"Stream objects: {dump.streamObjectCount}")
print(f"Xref entries:   {dump.xrefEntryCount}")
print(f"Xref streams:   {dump.usesXrefStreams}")
print(f"Producer:       {dump.producer}")
print(f"Creator:        {dump.creator}")

# Encryption details
print(f"Encrypted:      {dump.isEncrypted}")
if dump.isEncrypted:
    print(f"  Version:      {dump.encryptionVersion}")
    print(f"  Revision:     {dump.encryptionRevision}")
    print(f"  Key length:   {dump.encryptionKeyLengthBits} bits")

# Catalog flags
print(f"AcroForm:       {dump.hasAcroForm}")
print(f"Signed:         {dump.hasDigitalSignature}")
print(f"Embedded files: {dump.hasEmbeddedFiles}")

# Filter chains — which compression methods are used and how often
for chain in dump.filterChains:
    print(f"  {chain}: {dump.filterChains[chain]} streams")

# Font subtypes
for subtype in dump.fontSubtypes:
    print(f"  /{subtype}: {dump.fontSubtypes[subtype]}")

# Streams that failed to decode (capped at 50)
for bad in dump.unsupportedStreams:
    print(f"  obj {bad.objectNumber} [{bad.filterChain}]: {bad.error}")

# Free-form notes about parse anomalies
for note in dump.notes:
    print(f"  {note}")

Licensing

  • Free: inspect(), pdfa_validate(), and dump_structure() work without a license.
  • Trial: Call exis_pdfeditor.initialize() with no key for a 14-day full-feature trial.
  • Licensed: Pass your key to exis_pdfeditor.initialize("XXXX-XXXX-XXXX-XXXX") or set the EXIS_PDF_LICENSE_KEY environment variable.
  • Evaluation: After trial expiry, all features work on documents up to 3 pages.

Purchase a license at pdfbatcheditor.com/developers.

Requirements

  • Python 3.9+
  • No external dependencies — the native binary is bundled in the wheel.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

exis_pdfeditor-3.6.2-py3-none-win_amd64.whl (4.0 MB view details)

Uploaded Python 3Windows x86-64

exis_pdfeditor-3.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

exis_pdfeditor-3.6.2-py3-none-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file exis_pdfeditor-3.6.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for exis_pdfeditor-3.6.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d797ce0ce05d823424dabb3574c42440f252eb6e2ee7839a81ac127dacc4f545
MD5 c2ec0f69167d03afa6b0c22e7e386dcf
BLAKE2b-256 c35a9bc4dc854ea3dfa5f60abd1d674f15a3f5f8f3082cfd7ca5244639fc7d43

See more details on using hashes here.

File details

Details for the file exis_pdfeditor-3.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for exis_pdfeditor-3.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 355065403e11889d0f00cd4d3bafc4600d821308c65775d8ae70e83370c1de86
MD5 6625d2d2d5527469ce140238f4e71da6
BLAKE2b-256 da350db8a6442c95a0871305b184c21acd06d8da9ee03b6e0b0940bf1b5650d5

See more details on using hashes here.

File details

Details for the file exis_pdfeditor-3.6.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for exis_pdfeditor-3.6.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e27673ef8fe62c84e7bce7424b2a8335a1993cbc4eaced255c0f4bcb1f5ab2ca
MD5 61de90c479c1e5abeb5203fb5f3a3cf0
BLAKE2b-256 edc3f8165a973e23150108b85b5d15593e46759396d552c25f704520e4fe39c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page