Work with PDF Artifacts in Python
Contents
[
Hide
]
PDF artifacts mark page elements such as decorative backgrounds, running headers and footers, and watermarks. In a tagged PDF, assistive technologies can skip artifacts and focus on the document’s meaningful content.
Choose a guide
Add artifacts
Inspect artifacts
Remove artifacts
Work with the artifact API
Access a page’s artifacts through its artifacts property, which returns an ArtifactCollection. The Artifact class provides the properties shared by specialized classes such as BackgroundArtifact, WatermarkArtifact, HeaderArtifact, FooterArtifact, and BatesNArtifact.
| Task | Properties |
|---|---|
| Identify the artifact | Use type and subtype for standard classifications and custom_type and custom_subtype for custom names. |
| Inspect its content | Use text, image, and lines for text and images, or contents and form for PDF operators and the associated XForm. |
| Position it on the page | Use rectangle to inspect its bounds. Set position for explicit placement or use left_margin, right_margin, top_margin, bottom_margin, artifact_horizontal_alignment, and artifact_vertical_alignment. An explicit position overrides margins and alignment. |
| Control its appearance | Use rotation, opacity (from 0 to 1), and text_state. Set is_background to place the artifact behind page content. |