Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PAW

License: Apache 2.0 Python 3.11+ Version 0.2.0

PAW — PDF Architecture Wizard

A layout-surgery engine for PDFs on a fully permissive stack (pypdfium2 · pikepdf · reportlab · pdfplumber · Pillow · fontTools). Read a page's text, vector art, and images with coordinates; erase text and art out of the content stream; draw replacements; subset and save.

Status: v0.2.0. Installable from source; live coverage suite; glyph-precision text erasure (simple and CID fonts); per-glyph font fallback; pdfium thread-lock.

Install

pip install .

Python 3.11+. Fonts are not bundled — supply your own (see NOTICE).

Usage

import paw

doc  = paw.open("form.pdf")
page = doc.pages[0]

# read
page.text_spans()              # text with font, size, colour, bbox
page.strokes(); page.fills()   # vector art (gridlines, highlight bars)
page.images()                  # placed images with bboxes
page.raster(dpi=200)           # a PIL image of the page

# write — region is (x0, y0, x1, y1) in points, origin top-left, y down
region = (72, 100, 300, 130)
page.erase_text(region)        # text out of the content stream
page.erase_art(region)         # covered rules and highlights out
page.draw_text("Hello", at=(72, 118), font=paw.Font.load("Noto.ttf"), size=12)
page.draw_box(region)
page.place_image(pil_image, region)

doc.save("form.out.pdf")

Coordinates are points, origin top-left, y growing down; draw_text(at=…) positions the baseline start.

API

Call Does
paw.open · paw.blank · doc.save · doc.subset open · create · write · keep only some pages
page.text_spans · page.text_lines text with font, size, colour, bbox
page.strokes · page.fills · page.images · page.links vector art · fills · images · links
page.raster(dpi) render the page to a PIL image
page.erase_text · page.erase_art remove text · path objects inside a region
page.draw_text · page.draw_box · page.draw_rule · page.place_image draw onto the page
paw.Font.load load a TTF for measuring and drawing

Coverage

python tests/coverage_check.py

Exercises every public call against a synthetic document and prints the status report.

Licences

Third-party component licences are listed in NOTICE.

About

PDF layout-surgery engine on a fully permissive stack — read, erase, and redraw text and vector art by coordinate

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages