|
| 1 | +import datetime |
| 2 | +from collections.abc import Callable, Generator |
| 3 | +from enum import IntEnum |
| 4 | +from pathlib import Path |
| 5 | +from typing import Any, NamedTuple |
| 6 | +from typing_extensions import Literal |
| 7 | + |
| 8 | +from .actions import Action |
| 9 | +from .util import _Unit |
| 10 | + |
| 11 | +_Orientation = Literal["", "portrait", "P", "landscape", "L"] |
| 12 | +_Format = Literal["", "a3", "A3", "a4", "A4", "a5", "A5", "letter", "Letter", "legal", "Legal"] |
| 13 | +_FontStyle = Literal["", "B", "I"] |
| 14 | +_FontStyles = Literal["", "B", "I", "U", "BU", "UB", "BI", "IB", "IU", "UI", "BIU", "BUI", "IBU", "IUB", "UBI", "UIB"] |
| 15 | +PAGE_FORMATS: dict[_Format, tuple[float, float]] |
| 16 | + |
| 17 | +class DocumentState(IntEnum): |
| 18 | + UNINITIALIZED: int |
| 19 | + READY: int |
| 20 | + GENERATING_PAGE: int |
| 21 | + CLOSED: int |
| 22 | + |
| 23 | +class Annotation(NamedTuple): |
| 24 | + type: str |
| 25 | + x: int |
| 26 | + y: int |
| 27 | + width: int |
| 28 | + height: int |
| 29 | + contents: str | None = ... |
| 30 | + link: str | int | None = ... |
| 31 | + alt_text: str | None = ... |
| 32 | + action: Action | None = ... |
| 33 | + |
| 34 | +class TitleStyle(NamedTuple): |
| 35 | + font_family: str | None = ... |
| 36 | + font_style: str | None = ... |
| 37 | + font_size_pt: int | None = ... |
| 38 | + color: int | tuple[int, int, int] | None = ... |
| 39 | + underline: bool = ... |
| 40 | + t_margin: int | None = ... |
| 41 | + l_margin: int | None = ... |
| 42 | + b_margin: int | None = ... |
| 43 | + |
| 44 | +class ToCPlaceholder(NamedTuple): |
| 45 | + render_function: Callable[[FPDF, Any], object] |
| 46 | + start_page: int |
| 47 | + y: int |
| 48 | + pages: int = ... |
| 49 | + |
| 50 | +class SubsetMap: |
| 51 | + def __init__(self, identities: list[int]) -> None: ... |
| 52 | + def pick(self, unicode: int): ... |
| 53 | + def dict(self): ... |
| 54 | + |
| 55 | +def get_page_format(format: _Format | tuple[float, float], k: float | None = ...) -> tuple[float, float]: ... |
| 56 | +def
57AE
span> load_cache(filename: Path): ... |
| 57 | + |
| 58 | +class FPDF: |
| 59 | + MARKDOWN_BOLD_MARKER: str |
| 60 | + MARKDOWN_ITALICS_MARKER: str |
| 61 | + MARKDOWN_UNDERLINE_MARKER: str |
| 62 | + offsets: Any |
| 63 | + page: int |
| 64 | + n: int |
| 65 | + buffer: Any |
| 66 | + pages: Any |
| 67 | + state: Any |
| 68 | + fonts: Any |
| 69 | + font_files: Any |
| 70 | + diffs: Any |
| 71 | + images: Any |
| 72 | + annots: Any |
| 73 | + links: Any |
| 74 | + in_footer: int |
| 75 | + lasth: int |
| 76 | + current_font: Any |
| 77 | + font_family: str |
| 78 | + font_style: str |
| 79 | + font_size_pt: int |
| 80 | + font_stretching: int |
| 81 | + str_alias_nb_pages: str |
| 82 | + underline: int |
| 83 | + draw_color: str |
| 84 | + fill_color: str |
| 85 | + text_color: str |
| 86 | + ws: int |
| 87 | + angle: int |
| 88 | + font_cache_dir: Any |
| 89 | + xmp_metadata: Any |
| 90 | + image_filter: str |
| 91 | + page_duration: int |
| 92 | + page_transition: Any |
| 93 | + struct_builder: Any |
| 94 | + section_title_styles: Any |
| 95 | + core_fonts: Any |
| 96 | + core_fonts_encoding: str |
| 97 | + font_aliases: Any |
| 98 | + k: float |
| 99 | + def_orientation: Any |
| 100 | + font_size: Any |
| 101 | + c_margin: Any |
| 102 | + line_width: float |
| 103 | + compress: bool |
| 104 | + pdf_version: str |
| 105 | + |
| 106 | + x: float |
| 107 | + y: float |
| 108 | + t_margin: float |
| 109 | + r_margin: float |
| 110 | + l_margin: float |
| 111 | + def __init__( |
| 112 | + self, |
| 113 | + orientation: _Orientation = ..., |
| 114 | + unit: _Unit | float = ..., |
| 115 | + format: _Format | tuple[float, float] = ..., |
| 116 | + font_cache_dir: bool = ..., |
| 117 | + ) -> None: ... |
| 118 | + @property |
| 119 | + def unifontsubset(self): ... |
| 120 | + @property |
| 121 | + def epw(self): ... |
| 122 | + @property |
| 123 | + def eph(self): ... |
| 124 | + def set_margin(self, margin: float) -> None: ... |
| 125 | + def set_margins(self, left: float, top: float, right: float = ...) -> None: ... |
| 126 | + def set_left_margin(self, margin: float) -> None: ... |
| 127 | + def set_top_margin(self, margin: float) -> None: ... |
| 128 | + def set_right_margin(self, margin: float) -> None: ... |
| 129 | + auto_page_break: Any |
| 130 | + b_margin: Any |
| 131 | + page_break_trigger: Any |
| 132 | + def set_auto_page_break(self, auto: bool, margin: float = ...) -> None: ... |
| 133 | + zoom_mode: Any |
| 134 | + layout_mode: Any |
| 135 | + def set_display_mode(self, zoom, layout: str = ...) -> None: ... |
| 136 | + def set_compression(self, compress) -> None: ... |
| 137 | + title: Any |
| 138 | + def set_title(self, title: str) -> None: ... |
| 139 | + lang: Any |
| 140 | + def set_lang(self, lang: str) -> None: ... |
| 141 | + subject: Any |
| 142 | + def set_subject(self, subject: str) -> None: ... |
| 143 | + author: Any |
| 144 | + def set_author(self, author: str) -> None: ... |
| 145 | + keywords: Any |
| 146 | + def set_keywords(self, keywords: str) -> None: ... |
| 147 | + creator: Any |
| 148 | + def set_creator(self, creator: str) -> None: ... |
| 149 | + producer: Any |
| 150 | + def set_producer(self, producer: str) -> None: ... |
| 151 | + creation_date: Any |
| 152 | + def set_creation_date(self, date: datetime.datetime | None = ...) -> None: ... |
| 153 | + def set_xmp_metadata(self, xmp_metadata) -> None: ... |
| 154 | + def set_doc_option(self, opt, value) -> None: ... |
| 155 | + def set_image_filter(self, image_filter) -> None: ... |
| 156 | + def alias_nb_pages(self, alias: str = ...) -> None: ... |
| 157 | + def open(self) -> None: ... |
| 158 | + def close(self) -> None: ... |
| 159 | + def add_page( |
| 160 | + self, |
| 161 | + orientation: _Orientation = ..., |
| 162 | + format: _Format | tuple[float, float] = ..., |
| 163 | + same: bool = ..., |
| 164 | + duration: int = ..., |
| 165 | + transition: Any | None = ..., |
| 166 | + ) -> None: ... |
| 167 | + def header(self) -> None: ... |
| 168 | + def footer(self) -> None: ... |
| 169 | + def page_no(self): ... |
| 170 | + def set_draw_color(self, r, g: int = ..., b: int = ...) -> None: ... |
| 171 | + def set_fill_color(self, r, g: int = ..., b: int = ...) -> None: ... |
| 172 | + def set_text_color(self, r, g: int = ..., b: int = ...) -> None: ... |
| 173 | + def get_string_width(self, s, normalized: bool = ..., markdown: bool = ...): ... |
| 174 | + def set_line_width(self, width: float) -> None: ... |
| 175 | + def line(self, x1: float, y1: float, x2: float, y2: float) -> None: ... |
| 176 | + def polyline(self, point_list, fill: bool = ..., polygon: bool = ...) -> None: ... |
| 177 | + def polygon(self, point_list, fill: bool = ...) -> None: ... |
| 178 | + def dashed_line(self, x1, y1, x2, y2, dash_length: int = ..., space_length: int = ...) -> None: ... |
| 179 | + def rect(self, x, y, w, h, style: Any | None = ...) -> None: ... |
| 180 | + def ellipse(self, x, y, w, h, style: Any | None = ...) -> None: ... |
| 181 | + def circle(self, x, y, r, style: Any | None = ...) -> None: ... |
| 182 | + def add_font(self, family: str, style: _FontStyle = ..., fname: str | None = ..., uni: bool = ...) -> None: ... |
| 183 | + def set_font(self, family: str | None = ..., style: _FontStyles = ..., size: int = ...) -> None: ... |
| 184 | + def set_font_size(self, size: int) -> None: ... |
| 185 | + def set_stretching(self, stretching) -> None: ... |
| 186 | + def add_link(self): ... |
| 187 | + def set_link(self, link, y: int = ..., x: int = ..., page: int = ..., zoom: str = ...) -> None: ... |
| 188 | + def link(self, x, y, w, h, link, alt_text: Any | None = ...) -> None: ... |
| 189 | + def text_annotation(self, x, y, text) -> None: ... |
| 190 | + def add_action(self, action, x, y, w, h) -> None: ... |
| 191 | + def text(self, x, y, txt: str = ...) -> None: ... |
| 192 | + def rotate(self, angle, x: Any | None = ..., y: Any | None = ...) -> None: ... |
| 193 | + def rotation(self, angle, x: Any | None = ..., y: Any | None = ...) -> Generator[None, None, None]: ... |
| 194 | + @property |
| 195 | + def accept_page_break(self): ... |
| 196 | + def cell( |
| 197 | + self, |
| 198 | + w: float | None = ..., |
| 199 | + h: float | None = ..., |
| 200 | + txt: str = ..., |
| 201 | + border: bool | Literal[0, 1] | str = ..., |
| 202 | + ln: int = ..., |
| 203 | + align: str = ..., |
| 204 | + fill: bool = ..., |
| 205 | + link: str = ..., |
| 206 | + center: bool = ..., |
| 207 | + markdown: bool = ..., |
| 208 | + ): ... |
| 209 | + def will_page_break(self, height): ... |
| 210 | + def multi_cell( |
| 211 | + self, |
| 212 | + w: float, |
| 213 | + h: float | None = ..., |
| 214 | + txt: str = ..., |
| 215 | + border: bool | Literal[0, 1] | str = ..., |
| 216 | + align: str = ..., |
| 217 | + fill: bool = ..., |
| 218 | + split_only: bool = ..., |
| 219 | + link: str = ..., |
| 220 | + ln: int = ..., |
| 221 | + max_line_height: Any | None = ..., |
| 222 | + markdown: bool = ..., |
| 223 | + ): ... |
| 224 | + def write(self, h: Any | None = ..., txt: str = ..., link: str = ...) -> None: ... |
| 225 | + def image( |
| 226 | + self, |
| 227 | + name, |
| 228 | + x: float | None = ..., |
| 229 | + y: float | None = ..., |
| 230 | + w: float = ..., |
| 231 | + h: float = ..., |
| 232 | + type: str = ..., |
| 233 | + link: str = ..., |
| 234 | + title: str | None = ..., |
| 235 | + alt_text: str | None = ..., |
| 236 | + ): ... |
| 237 | + def ln(self, h: Any | None = ...) -> None: ... |
| 238 | + def get_x(self) -> float: ... |
| 239 | + def set_x(self, x: float) -> None: ... |
| 240 | + def get_y(self) -> float: ... |
| 241 | + def set_y(self, y: float) -> None: ... |
| 242 | + def set_xy(self, x: float, y: float) -> None: ... |
| 243 | + def output(self, name: str = ..., dest: str = ...): ... |
| 244 | + def normalize_text(self, txt): ... |
| 245 | + def interleaved2of5(self, txt, x, y, w: int = ..., h: int = ...) -> None: ... |
| 246 | + def code39(self, txt, x, y, w: float = ..., h: int = ...) -> None: ... |
| 247 | + def rect_clip(self, x, y, w, h) -> Generator[None, None, None]: ... |
| 248 | + def unbreakable(self) -> Generator[Any, None, None]: ... |
| 249 | + def insert_toc_placeholder(self, render_toc_function, pages: int = ...) -> None: ... |
| 250 | + def set_section_title_styles( |
| 251 | + self, |
| 252 | + level0, |
| 253 | + level1: Any | None = ..., |
| 254 | + level2: Any | None = ..., |
| 255 | + level3: Any | None = ..., |
| 256 | + level4: Any | None = ..., |
| 257 | + level5: Any | None = ..., |
| 258 | + level6: Any | None = ..., |
| 259 | + ) -> None: ... |
| 260 | + def start_section(self, name, level: int = ...) -> None: ... |
0 commit comments