adsfolio.pdf.annotations

Annotation extraction and porting helpers for PDF upgrades.

class adsfolio.pdf.annotations.AnnotationRecord(annotation_type, text, context_before, context_after, color, content, page_num, opacity, type_code)[source]

Bases: object

Portable annotation information extracted from the source PDF.

Parameters:
  • annotation_type (str)

  • text (str)

  • context_before (str)

  • context_after (str)

  • color (Any | None)

  • content (str)

  • page_num (int)

  • opacity (float | None)

  • type_code (int)

annotation_type: str
color: Any | None
content: str
context_after: str
context_before: str
opacity: float | None
page_num: int
text: str
to_dict()[source]
Return type:

dict[str, Any]

type_code: int
class adsfolio.pdf.annotations.MatchedAnnotation(source_index, source, target_page, target_quads)[source]

Bases: object

Matched target location for one source annotation.

Parameters:
source: adsfolio.pdf.annotations.AnnotationRecord
source_index: int
target_page: int
target_quads: list[Any]
class adsfolio.pdf.annotations.PortingReport(total_portable, ported, failed, skipped_nonportable, output_path, unported=<factory>)[source]

Bases: object

Summary of annotation porting results.

Parameters:
failed: int
output_path: str
ported: int
skipped_nonportable: int
total_portable: int
unported: list[dict[str, Any]]
adsfolio.pdf.annotations.apply_annotations(matched, target_path, output_path)[source]

Apply matched annotations to target PDF and save output.

Parameters:
Return type:

int

adsfolio.pdf.annotations.extract_annotations(source_path, context_chars=150)[source]

Extract portable text annotations and contextual windows.

Parameters:
Return type:

list[adsfolio.pdf.annotations.AnnotationRecord]

adsfolio.pdf.annotations.match_annotations(records, target_path)[source]

Match source annotations to text locations in target PDF.

Parameters:
Return type:

list[adsfolio.pdf.annotations.MatchedAnnotation]

adsfolio.pdf.annotations.normalize_text(text)[source]

Normalize text for robust matching across PDF render variants.

Parameters:

text (str)

Return type:

str

adsfolio.pdf.annotations.port_annotations(source_path, target_path, output_path)[source]

Extract, match, and apply annotations to produce upgraded PDF.

Parameters:
Return type:

adsfolio.pdf.annotations.PortingReport