mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Add some missing attributes and types to FPDF (#6618)
This commit is contained in:
3
stubs/fpdf2/@tests/stubtest_allowlist.txt
Normal file
3
stubs/fpdf2/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# The "dest" argument is unused and will be removed.
|
||||
fpdf.FPDF.output
|
||||
fpdf.fpdf.FPDF.output
|
||||
@@ -1 +1,2 @@
|
||||
version = "2.4.*"
|
||||
requires = ["types-Pillow"]
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import datetime
|
||||
from _typeshed import StrPath
|
||||
from collections import defaultdict
|
||||
from collections.abc import Callable, Generator
|
||||
from enum import IntEnum
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any, NamedTuple
|
||||
from typing import Any, NamedTuple, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from .actions import Action
|
||||
from .syntax import DestinationXYZ
|
||||
from .util import _Unit
|
||||
|
||||
_Orientation = Literal["", "portrait", "P", "landscape", "L"]
|
||||
_Orientation = Literal["", "portrait", "p", "P", "landscape", "l", "L"]
|
||||
_Format = Literal["", "a3", "A3", "a4", "A4", "a5", "A5", "letter", "Letter", "legal", "Legal"]
|
||||
_FontStyle = Literal["", "B", "I"]
|
||||
_FontStyles = Literal["", "B", "I", "U", "BU", "UB", "BI", "IB", "IU", "UI", "BIU", "BUI", "IBU", "IUB", "UBI", "UIB"]
|
||||
@@ -55,25 +61,31 @@ class SubsetMap:
|
||||
def get_page_format(format: _Format | tuple[float, float], k: float | None = ...) -> tuple[float, float]: ...
|
||||
def load_cache(filename: Path): ...
|
||||
|
||||
# TODO: TypedDicts
|
||||
_Page = dict[str, Any]
|
||||
_Font = dict[str, Any]
|
||||
_FontFile = dict[str, Any]
|
||||
_Image = dict[str, Any]
|
||||
|
||||
class FPDF:
|
||||
MARKDOWN_BOLD_MARKER: str
|
||||
MARKDOWN_ITALICS_MARKER: str
|
||||
MARKDOWN_UNDERLINE_MARKER: str
|
||||
offsets: Any
|
||||
offsets: dict[int, int]
|
||||
page: int
|
||||
n: int
|
||||
buffer: Any
|
||||
pages: Any
|
||||
state: Any
|
||||
fonts: Any
|
||||
font_files: Any
|
||||
diffs: Any
|
||||
images: Any
|
||||
annots: Any
|
||||
links: Any
|
||||
buffer: bytearray
|
||||
pages: dict[int, _Page]
|
||||
state: DocumentState
|
||||
fonts: dict[str, _Font]
|
||||
font_files: dict[str, _FontFile]
|
||||
diffs: dict[int, int]
|
||||
images: dict[str, _Image]
|
||||
annots: defaultdict[int, list[Annotation]]
|
||||
links: dict[int, DestinationXYZ]
|
||||
in_footer: int
|
||||
lasth: int
|
||||
current_font: Any
|
||||
current_font: _Font
|
||||
font_family: str
|
||||
font_style: str
|
||||
font_size_pt: int
|
||||
@@ -100,6 +112,8 @@ class FPDF:
|
||||
font_size: Any
|
||||
c_margin: Any
|
||||
line_width: float
|
||||
dw_pt: float
|
||||
dh_pt: float
|
||||
compress: bool
|
||||
pdf_version: str
|
||||
|
||||
@@ -108,6 +122,13 @@ class FPDF:
|
||||
t_margin: float
|
||||
r_margin: float
|
||||
l_margin: float
|
||||
|
||||
# Set during call to _set_orientation(), called from __init__().
|
||||
cur_orientation: Literal["P", "L"]
|
||||
w_pt: float
|
||||
h_pt: float
|
||||
w: float
|
||||
h: float
|
||||
def __init__(
|
||||
self,
|
||||
orientation: _Orientation = ...,
|
||||
@@ -166,7 +187,7 @@ class FPDF:
|
||||
) -> None: ...
|
||||
def header(self) -> None: ...
|
||||
def footer(self) -> None: ...
|
||||
def page_no(self): ...
|
||||
def page_no(self) -> int: ...
|
||||
def set_draw_color(self, r, g: int = ..., b: int = ...) -> None: ...
|
||||
def set_fill_color(self, r, g: int = ..., b: int = ...) -> None: ...
|
||||
def set_text_color(self, r, g: int = ..., b: int = ...) -> None: ...
|
||||
@@ -224,7 +245,7 @@ class FPDF:
|
||||
def write(self, h: Any | None = ..., txt: str = ..., link: str = ...) -> None: ...
|
||||
def image(
|
||||
self,
|
||||
name,
|
||||
name: str | Image.Image | BytesIO | StrPath,
|
||||
x: float | None = ...,
|
||||
y: float | None = ...,
|
||||
w: float = ...,
|
||||
@@ -233,14 +254,17 @@ class FPDF:
|
||||
link: str = ...,
|
||||
title: str | None = ...,
|
||||
alt_text: str | None = ...,
|
||||
): ...
|
||||
) -> _Image: ...
|
||||
def ln(self, h: Any | None = ...) -> None: ...
|
||||
def get_x(self) -> float: ...
|
||||
def set_x(self, x: float) -> None: ...
|
||||
def get_y(self) -> float: ...
|
||||
def set_y(self, y: float) -> None: ...
|
||||
def set_xy(self, x: float, y: float) -> None: ...
|
||||
def output(self, name: str = ..., dest: str = ...): ...
|
||||
@overload
|
||||
def output(self, name: Literal[""] = ...) -> bytearray: ... # type: ignore[misc]
|
||||
@overload
|
||||
def output(self, name: str) -> None: ...
|
||||
def normalize_text(self, txt): ...
|
||||
def interleaved2of5(self, txt, x, y, w: int = ..., h: int = ...) -> None: ...
|
||||
def code39(self, txt, x, y, w: float = ..., h: int = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user