| 1 | from typing import Any |
| 2 | |
| 3 | class Error(Exception): |
| 4 | pass |
| 5 | |
| 6 | class PDFOutlineItem: |
| 7 | def __init__(self) -> None: |
| 8 | "PDF Outline items" |
| 9 | pass |
| 10 | |
| 11 | def create(self, title: str, pagenum: int, as_child: object = False, left: float = 0, top: float = 0, zoom: float = 0) -> PDFOutlineItem: |
| 12 | """create(title, pagenum, as_child=False) -> Create a new outline item with title |
| 13 | 'title', pointing to page number pagenum. If as_child is True the new item will |
| 14 | be a child of this item otherwise it will be a sibling. Returns the newly created |
| 15 | item. |
| 16 | """ |
| 17 | pass |
| 18 | |
| 19 | def erase(self) -> None: |
| 20 | "erase() -> Delete this item and all its children, removing it from the outline tree completely." |
| 21 | pass |
| 22 | |
| 23 | class PDFDoc: |
| 24 | title: str |
| 25 | author: str |
| 26 | subject: str |
| 27 | keywords: str |
| 28 | creator: str |
| 29 | producer: str |
| 30 | pages: int |
| 31 | version: str |
| 32 | |
| 33 | def __init__(self) -> None: |
| 34 | "PDF Documents" |
| 35 | pass |
| 36 | |
| 37 | def load(self, buffer: bytes) -> None: |
| 38 | "Load a PDF document from a byte buffer (string)" |
| 39 | pass |
| 40 | |
| 41 | def open(self, path: str) -> None: |
| 42 | "Load a PDF document from a file path (string)" |
| 43 | pass |
| 44 | |
| 45 | def save(self, path: str) -> None: |
| 46 | "Save the PDF document to a path on disk" |
| 47 | pass |
| 48 | |
| 49 | def write(self) -> bytes: |
| 50 | "Return the PDF document as a bytestring." |
| 51 | pass |
| 52 | |
| 53 | def save_to_fileobj(self, f: Any) -> None: |
| 54 | "Write the PDF document to the soecified file-like object." |
| 55 | pass |
| 56 | |
| 57 | def uncompress(self) -> None: |
| 58 | "Uncompress the PDF" |
| 59 | pass |
| 60 | |
| 61 | def extract_first_page(self) -> None: |
| 62 | "extract_first_page() -> Remove all but the first page." |
| 63 | pass |
| 64 | |
| 65 | def page_count(self) -> int: |
| 66 | "page_count() -> Number of pages in the PDF." |
| 67 | pass |
| 68 | |
| 69 | def image_count(self) -> int: |
| 70 | "image_count() -> Number of images in the PDF." |
| 71 | pass |
| 72 | |
| 73 | def extract_anchors(self) -> dict[str, tuple[int, float, float, int]]: |
| 74 | "extract_anchors() -> Extract information about links in the document." |
| 75 | pass |
| 76 | |
| 77 | def alter_links(self, alter_callback: Any, mark_links: bool) -> int: |
| 78 | "alter_links() -> Change links in the document." |
| 79 | pass |
| 80 | |
| 81 | def list_fonts(self, get_font_data: bool = False) -> list[dict[str, Any]]: |
| 82 | "list_fonts() -> Get list of fonts in document" |
| 83 | pass |
| 84 | |
| 85 | def remove_unused_fonts(self) -> int: |
| 86 | "remove_unused_fonts() -> Remove unused font objects." |
| 87 | pass |
| 88 | |
| 89 | def merge_fonts(self, data: bytes, references: tuple[tuple[int, int], ...]) -> None: |
| 90 | "merge_fonts() -> Merge the specified fonts." |
| 91 | pass |
| 92 | |
| 93 | def replace_font_data(self, data: bytes, num: int, generation: int) -> None: |
| 94 | "replace_font_data() -> Replace the data stream for the specified font." |
| 95 | pass |
| 96 | |
| 97 | def dedup_type3_fonts(self) -> int: |
| 98 | "dedup_type3_fonts() -> De-duplicate repeated glyphs in Type3 fonts" |
| 99 | pass |
| 100 | |
| 101 | def impose(self, dest_page_num: int, src_page_num: int, count: int) -> None: |
| 102 | "impose() -> impose pages onto each other" |
| 103 | pass |
| 104 | |
| 105 | def dedup_images(self) -> int: |
| 106 | "dedup_images() -> Remove duplicated images" |
| 107 | pass |
| 108 | |
| 109 | def delete_pages(self, page_num: int, count: int = 1) -> None: |
| 110 | "delete_page(page_num, count=1) -> Delete the specified pages from the pdf." |
| 111 | pass |
| 112 | |
| 113 | def get_page_box(self, which: str, page_num: int) -> tuple[float, float, float, float]: |
| 114 | "get_page_box(which, page_num) -> Get the specified box for the specified page as (left, bottom, width, height) in pts" |
| 115 | pass |
| 116 | |
| 117 | def set_page_box(self, which: str, page_num: int, left: float, bottom: float, width: float, height: float) -> None: |
| 118 | "set_page_box(which, page_num, left, bottom, width, height) -> Set the specified box (in pts) for the specified page." |
| 119 | pass |
| 120 | |
| 121 | def copy_page(self, from_: int, to: int) -> None: |
| 122 | "copy_page(from, to) -> Copy the specified page." |
| 123 | pass |
| 124 | |
| 125 | def append(self, *docs: PDFDoc) -> None: |
| 126 | "append(doc) -> Append doc (which must be a PDFDoc) to this document." |
| 127 | pass |
| 128 | |
| 129 | def insert_existing_page(self, src_doc: PDFDoc, src_page: int = 0, at: int = 0) -> None: |
| 130 | "insert_existing_page(src_doc, src_page, at) -> Insert the page src_page from src_doc at index: at." |
| 131 | pass |
| 132 | |
| 133 | def set_box(self, page_num: int, box: str, left: float, bottom: float, width: float, height: float) -> None: |
| 134 | """set_box(page_num, box, left, bottom, width, height) -> Set the PDF bounding box |
| 135 | for the page numbered nu, box must be one of: MediaBox, CropBox, TrimBox, |
| 136 | BleedBox, ArtBox. The numbers are interpreted as pts. |
| 137 | """ |
| 138 | pass |
| 139 | |
| 140 | def create_outline(self, title: str, pagenum: int, left: float = 0, top: float = 0, zoom: float = 0) -> PDFOutlineItem: |
| 141 | "create_outline(title, pagenum) -> Create an outline, return the first outline item." |
| 142 | pass |
| 143 | |
| 144 | def get_outline(self) -> dict[str, Any] | None: |
| 145 | "get_outline() -> Get the outline if any in the PDF file." |
| 146 | pass |
| 147 | |
| 148 | def get_xmp_metadata(self) -> bytes | None: |
| 149 | "get_xmp_metadata(raw) -> Get the XMP metadata as raw bytes" |
| 150 | pass |
| 151 | |
| 152 | def set_xmp_metadata(self, raw: bytes) -> None: |
| 153 | "set_xmp_metadata(raw) -> Set the XMP metadata to the raw bytes (which must be a valid XML packet)" |
| 154 | pass |
| 155 | |
| 156 | def add_image_page( |
| 157 | self, |
| 158 | image_data: bytes, |
| 159 | page_x: float, |
| 160 | page_y: float, |
| 161 | page_width: float, |
| 162 | page_height: float, |
| 163 | image_x: float, |
| 164 | image_y: float, |
| 165 | image_canvas_width: float, |
| 166 | image_canvas_height: float, |
| 167 | page_num: int = 1, |
| 168 | preserve_aspect_ratio: bool = True, |
| 169 | ) -> tuple[float, float]: |
| 170 | "add_image_page(image_data, page_idx=0) -> Add the specified image as a full page image, will use the size of the first existing page as page size." |
| 171 | pass |