Skip to main content

Data Types

All result types are frozen dataclasses (immutable). They are importable from paperjam:

from paperjam import TextLine, TextSpan, Table, Metadata, ...

Text types

TextSpan

A positioned piece of text on a page.

AttributeTypeDescription
textstrThe text content
xfloatLeft edge in PDF points
yfloatBaseline y in PDF points
widthfloatWidth of the span in points
font_sizefloatFont size in points
font_namestrFont name as embedded in the PDF

TextLine

A line of text composed of one or more spans.

AttributeTypeDescription
textstrFull text of the line
spanstuple[TextSpan, ...]Individual spans making up the line
bboxtuple[float, float, float, float]Bounding box (x1, y1, x2, y2)

Table types

Table

An extracted table from a PDF page.

AttributeTypeDescription
rowstuple[Row, ...]All rows
col_countintNumber of columns
bboxtuple[float, float, float, float]Bounding box
strategystrExtraction strategy used
row_countint (property)Number of rows

Methods

MethodReturnsDescription
cell(row, col)Cell | NoneGet cell by 0-based row and column
to_list()list[list[str]]Convert to 2D list of strings
to_csv(delimiter=",")strConvert to CSV string
to_dataframe()DataFrameConvert to pandas DataFrame (pandas extra required)

Row

A row in a table.

AttributeTypeDescription
cellstuple[Cell, ...]Cells in the row
y_minfloatTop y coordinate
y_maxfloatBottom y coordinate

Cell

A single cell in a table.

AttributeTypeDescription
textstrCell text content
bboxtuple[float, float, float, float]Bounding box
col_spanintColumn span (merged cells)
row_spanintRow span (merged cells)

Document types

Metadata

PDF document metadata.

AttributeTypeDescription
titlestr | NoneDocument title
authorstr | NoneAuthor
subjectstr | NoneSubject
keywordsstr | NoneKeywords
creatorstr | NoneCreating application
producerstr | NonePDF-writing library
creation_datestr | NoneISO 8601 date
modification_datestr | NoneISO 8601 date
pdf_versionstrPDF spec version, e.g. "1.7"
page_countintTotal pages
is_encryptedboolWhether password-protected
xmp_metadatastr | NoneRaw XMP XML string

PageInfo

Basic page dimensions and orientation.

AttributeTypeDescription
numberint1-based page number
widthfloatWidth in points
heightfloatHeight in points
rotationintRotation: 0, 90, 180, or 270

Bookmark

A bookmark/outline entry.

AttributeTypeDescription
titlestrDisplay text
pageint1-based destination page
levelintNesting level (0 = top)
childrentuple[Bookmark, ...]Nested child bookmarks

Content types

ContentBlock

A structured content block extracted from a page.

AttributeTypeDescription
typestr"heading", "paragraph", "list_item", "table"
pageint1-based page number
textstr | NoneText content (None for tables)
levelint | NoneHeading level 1–6
indent_levelint | NoneList item nesting depth
bboxtuple | NoneBounding box
tableTable | NoneTable object (only for type="table")

Image

An image extracted from a page.

AttributeTypeDescription
widthintWidth in pixels
heightintHeight in pixels
color_spacestr | Nonee.g. "DeviceRGB"
bits_per_componentint | NoneBit depth
filterslist[str]Applied PDF stream filters
databytesRaw image data

Methods: save(path) — write raw bytes to a file.

SearchResult

A text search match.

AttributeTypeDescription
pageint1-based page number
textstrFull line text containing the match
line_numberint1-based line index on the page
bboxtuple | NoneBounding box of the matching line

A hyperlink extracted from a page.

AttributeTypeDescription
pageint1-based page number
recttupleClickable area (x1, y1, x2, y2)
urlstr | NoneExternal URL
destinationdict | NoneInternal page destination
contentsstr | NoneAlternative text

Annotation

A PDF annotation.

AttributeTypeDescription
typestrAnnotation type string
recttupleBounding box
contentsstr | NoneText / tooltip
authorstr | NoneAuthor name
colortuple | NoneRGB float (0.0–1.0 each)
creation_datestr | NoneISO 8601 date
opacityfloat | None0.0–1.0
urlstr | NoneURL (link annotations)
destinationdict | NoneInternal destination (link annotations)

Layout types

PageLayout

Layout analysis result for a single page.

AttributeTypeDescription
page_widthfloatPage width in points
page_heightfloatPage height in points
column_countintDetected column count
gutterstuple[float, ...]X positions of gutter centres
regionstuple[LayoutRegion, ...]Classified regions
is_multi_columnbool (property)column_count > 1

Methods: text() — all text in reading order.

LayoutRegion

A classified rectangular region of the page.

AttributeTypeDescription
kindstr"header", "footer", "body_column", "full_width"
column_indexint | None0-based column index
bboxtupleBounding box
linestuple[TextLine, ...]Lines in reading order

Security and optimization types

OptimizeResult

AttributeTypeDescription
original_sizeintSize before optimization (bytes)
optimized_sizeintSize after optimization (bytes)
objects_removedintNumber of objects removed
streams_compressedintNumber of streams compressed
reduction_percentfloat (property)Percentage size reduction

SanitizeResult

AttributeTypeDescription
javascript_removedintJS actions removed
embedded_files_removedintAttachments removed
actions_removedintOther actions removed
links_removedintLinks removed
itemstuple[SanitizedItem, ...]Detailed list
total_removedint (property)Sum of all four counters

SanitizedItem

AttributeTypeDescription
categorystrCategory of removed item
descriptionstrHuman-readable description
pageint | NonePage number if applicable

RedactResult

AttributeTypeDescription
pages_modifiedintNumber of pages with redactions
items_redactedintTotal items redacted
itemstuple[RedactedItem, ...]Details of each redaction

RedactedItem

AttributeTypeDescription
pageint1-based page number
textstrThe redacted text
recttupleBounding box of the redacted area

RedactRegion

A region to redact.

AttributeTypeDescription
pageint1-based page number
recttuple(x1, y1, x2, y2) in PDF points

EncryptResult

AttributeTypeDescription
algorithmstr"aes128" or "rc4"
key_lengthintKey length in bits

Permissions

Permission flags for an encrypted PDF.

All attributes are bool, default True:

AttributeDescription
printLow-quality printing
modifyDocument modification
copyText/image copying
annotateAdding annotations
fill_formsFilling form fields
accessibilityAccessibility tool access
assemblePage assembly
print_high_qualityHigh-quality printing

Class method: Permissions.none() — returns a Permissions with all flags set to False.


Form types

FormField

AttributeTypeDescription
namestrFully-qualified field name
field_typestr"text", "checkbox", etc.
valuestr | NoneCurrent value
default_valuestr | NoneDefault value
pageint | None1-based page
recttuple | NonePosition
read_onlyboolRead-only flag
requiredboolRequired flag
max_lengthintMax characters (0 = no limit)
optionstuple[ChoiceOption, ...]Options for combo/list boxes

ChoiceOption

An option in a combo or list box.

AttributeTypeDescription
displaystrDisplay text shown to the user
export_valuestrValue written to the field when selected

FillFormResult

AttributeTypeDescription
fields_filledintFields successfully filled
fields_not_foundintField names not found
not_found_namestuple[str, ...]Names of missing fields

CreateFieldResult

AttributeTypeDescription
field_namestrName of the created field
createdboolWhether creation succeeded

ModifyFieldResult

AttributeTypeDescription
field_namestrName of the targeted field
modifiedboolWhether modification succeeded

Diff types

DiffResult

AttributeTypeDescription
page_diffstuple[PageDiff, ...]Per-page results
summaryDiffSummaryAggregate statistics

DiffSummary

AttributeTypeDescription
pages_changedintPages with text differences
pages_addedintPages in doc_b only
pages_removedintPages in doc_a only
total_additionsintLines added
total_removalsintLines removed
total_changesintLines changed

PageDiff

AttributeTypeDescription
pageint1-based page number
opstuple[DiffOp, ...]Change operations

DiffOp

AttributeTypeDescription
kindstr"added", "removed", "changed"
pageint1-based page number
text_astr | NoneText in document A
text_bstr | NoneText in document B
bbox_atuple | NoneBbox in document A
bbox_btuple | NoneBbox in document B
line_index_aint | NoneLine index in document A
line_index_bint | NoneLine index in document B

Visual diff types

VisualDiffResult

AttributeTypeDescription
pagestuple[VisualDiffPage, ...]Per-page visual results
overall_similarityfloatAverage similarity (0.0–1.0)
text_diff_summaryDiffSummaryText-level summary

VisualDiffPage

AttributeTypeDescription
pageint1-based page number
image_abytesRendered image from document A
image_bbytesRendered image from document B
diff_imagebytesDiff visualization
similarityfloatPixel similarity for this page
changed_pixel_countintNumber of differing pixels

Rendering types

RenderedImage

AttributeTypeDescription
databytesRaw image bytes
widthintWidth in pixels
heightintHeight in pixels
formatstr"png", "jpeg", or "bmp"
pageint1-based source page

Methods: save(path) — write image bytes to a file.


Signature types

SignatureInfo

AttributeTypeDescription
namestrSignature field name
signerstr | NoneSigner's name
reasonstr | NoneReason for signing
locationstr | NoneSigning location
datestr | NoneSigning date
contact_infostr | NoneContact info
byte_rangetuple | NoneSigned byte ranges
certificateCertificateInfo | NoneEmbedded certificate
covers_whole_documentboolWhether it covers the full file
has_timestampboolWhether an RFC 3161 timestamp is present
timestamp_datestr | NoneTimestamp date from the TSA
has_ocspboolWhether OCSP responses are embedded
has_crlsboolWhether CRLs are embedded

CertificateInfo

AttributeTypeDescription
subjectstrCertificate subject DN
issuerstrCertificate issuer DN
serial_numberstrSerial number (hex)
not_beforestrValidity start
not_afterstrValidity end
is_self_signedboolSubject equals issuer

SignatureValidity

AttributeTypeDescription
namestrSignature field name
integrity_okboolHash verification passed
certificate_validboolCertificate date range valid
messagestrStatus message
signerstr | NoneSigner name
timestamp_validbool | NoneTimestamp token validity
revocation_okbool | NoneRevocation info validity
is_ltvboolHas long-term validation info

Validation types

ValidationReport

AttributeTypeDescription
levelstrValidation level: "1b", "1a", "2b"
is_compliantboolWhether document passed
issuestuple[ValidationIssue, ...]Problems found
fonts_checkedintNumber of fonts inspected
pages_checkedintNumber of pages inspected

ValidationIssue

AttributeTypeDescription
severitystr"error", "warning", "info"
rulestrRule identifier
messagestrDescription
pageint | NonePage number if applicable

ConversionResult

AttributeTypeDescription
levelstrTarget conformance level
successboolWhether all issues were resolved
actions_takentuple[ConversionAction, ...]Actions performed
remaining_issuestuple[ValidationIssue, ...]Unresolved problems

ConversionAction

AttributeTypeDescription
categorystrAction category
descriptionstrHuman-readable description
pageint | NonePage number if applicable

PdfUaReport

AttributeTypeDescription
levelstrValidation level ("1")
is_compliantboolWhether the document passed
issuestuple[ValidationIssue, ...]Problems found
pages_checkedintNumber of pages inspected
structure_elements_checkedintStructure elements inspected

Conversion types

ConvertReport

Statistics from a format conversion operation.

AttributeTypeDescription
from_formatstrSource format name
to_formatstrTarget format name
content_blocksintNumber of content blocks processed
tablesintNumber of tables found
imagesintNumber of images found

Pipeline types

PipelineResult

Result of pipeline execution.

AttributeTypeDescription
total_filesintTotal input files
succeededintFiles processed successfully
failedintFiles that failed
skippedintFiles skipped due to errors
file_resultslist[FileResult]Per-file details

FileResult

Result for a single file in a pipeline.

AttributeTypeDescription
pathstrFile path
statusstr"Success", "Failed", or "Skipped"
errorstr | NoneError message if failed
duration_msfloatProcessing time in milliseconds