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:
objectPortable annotation information extracted from the source PDF.
- Parameters:
- class adsfolio.pdf.annotations.MatchedAnnotation(source_index, source, target_page, target_quads)[source]
Bases:
objectMatched target location for one source annotation.
- class adsfolio.pdf.annotations.PortingReport(total_portable, ported, failed, skipped_nonportable, output_path, unported=<factory>)[source]
Bases:
objectSummary of annotation porting results.
- Parameters:
- adsfolio.pdf.annotations.apply_annotations(matched, target_path, output_path)[source]
Apply matched annotations to target PDF and save output.
- Parameters:
matched (list[adsfolio.pdf.annotations.MatchedAnnotation])
target_path (pathlib.Path)
output_path (pathlib.Path)
- Return type:
- adsfolio.pdf.annotations.extract_annotations(source_path, context_chars=150)[source]
Extract portable text annotations and contextual windows.
- Parameters:
source_path (pathlib.Path)
context_chars (int)
- Return type:
- adsfolio.pdf.annotations.match_annotations(records, target_path)[source]
Match source annotations to text locations in target PDF.
- Parameters:
records (list[adsfolio.pdf.annotations.AnnotationRecord])
target_path (pathlib.Path)
- Return type:
- adsfolio.pdf.annotations.normalize_text(text)[source]
Normalize text for robust matching across PDF render variants.
- adsfolio.pdf.annotations.port_annotations(source_path, target_path, output_path)[source]
Extract, match, and apply annotations to produce upgraded PDF.
- Parameters:
source_path (pathlib.Path)
target_path (pathlib.Path)
output_path (pathlib.Path)
- Return type: