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
8 from .actions import Action
9 from .util import _Unit
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]]
17 class DocumentState(IntEnum):
23 class Annotation(NamedTuple):
29 contents: str | None = ...
30 link: str | int | None = ...
31 alt_text: str | None = ...
32 action: Action | None = ...
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 = ...
40 t_margin: int | None = ...
41 l_margin: int | None = ...
42 b_margin: int | None = ...
44 class ToCPlaceholder(NamedTuple):
45 render_function: Callable[[FPDF, Any], object]
51 def __init__(self, identities: list[int]) -> None: ...
52 def pick(self, unicode: int): ...
55 def get_page_format(format: _Format | tuple[float, float], k: float | None = ...) -> tuple[float, float]: ...
56 def load_cache(filename: Path): ...
59 MARKDOWN_BOLD_MARKER: str
60 MARKDOWN_ITALICS_MARKER: str
61 MARKDOWN_UNDERLINE_MARKER: str
81 str_alias_nb_pages: str
94 section_title_styles: Any
96 core_fonts_encoding: str
113 orientation: _Orientation = ...,
114 unit: _Unit | float = ...,
115 format: _Format | tuple[float, float] = ...,
116 font_cache_dir: bool = ...,
119 def unifontsubset(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: ...
131 page_break_trigger: Any
132 def set_auto_page_break(self, auto: bool, margin: float = ...) -> None: ...
135 def set_display_mode(self, zoom, layout: str = ...) -> None: ...
136 def set_compression(self, compress) -> None: ...
138 def set_title(self, title: str) -> None: ...
140 def set_lang(self, lang: str) -> None: ...
142 def set_subject(self, subject: str) -> None: ...
144 def set_author(self, author: str) -> None: ...
146 def set_keywords(self, keywords: str) -> None: ...
148 def set_creator(self, creator: str) -> None: ...
150 def set_producer(self, producer: str) -> None: ...
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: ...
161 orientation: _Orientation = ...,
162 format: _Format | tuple[float, float] = ...,
165 transition: Any | 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]: ...
195 def accept_page_break(self): ...
198 w: float | None = ...,
199 h: float | None = ...,
201 border: bool | Literal[0, 1] | str = ...,
207 markdown: bool = ...,
209 def will_page_break(self, height): ...
213 h: float | None = ...,
215 border: bool | Literal[0, 1] | str = ...,
218 split_only: bool = ...,
221 max_line_height: Any | None = ...,
222 markdown: bool = ...,
224 def write(self, h: Any | None = ..., txt: str = ..., link: str = ...) -> None: ...
228 x: float | None = ...,
229 y: float | None = ...,
234 title: str | None = ...,
235 alt_text: str | None = ...,
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(
253 level1: Any | None = ...,
254 level2: Any | None = ...,
255 level3: Any | None = ...,
256 level4: Any | None = ...,
257 level5: Any | None = ...,
258 level6: Any | None = ...,
260 def start_section(self, name, level: int = ...) -> None: ...