fpdf2: Add missing files (#8836)

This commit is contained in:
Alex Waygood
2022-10-03 17:05:37 -07:00
committed by GitHub
parent f9b1289226
commit f801229f37
6 changed files with 762 additions and 0 deletions

View File

@@ -0,0 +1,392 @@
import decimal
from _typeshed import Incomplete
from collections import OrderedDict
from collections.abc import Generator
from contextlib import _GeneratorContextManager
from re import Pattern
from typing import ClassVar, NamedTuple
from typing_extensions import TypeAlias
from .syntax import Name, Raw
__pdoc__: dict[str, bool]
def force_nodocument(item): ...
def force_document(item): ...
Number: TypeAlias = int | float | decimal.Decimal
NumberClass: tuple[type, ...]
WHITESPACE: frozenset[str]
EOL_CHARS: frozenset[str]
DELIMITERS: frozenset[str]
STR_ESC: Pattern[str]
STR_ESC_MAP: dict[str, str]
class GraphicsStateDictRegistry(OrderedDict[Raw, Name]):
def register_style(self, style: GraphicsStyle): ...
def number_to_str(number): ...
def render_pdf_primitive(primitive): ...
class DeviceRGB:
OPERATOR: str
def __new__(cls, r, g, b, a: Incomplete | None = ...): ...
@property
def colors(self): ...
def pdf_repr(self) -> str: ...
class DeviceGray:
OPERATOR: str
def __new__(cls, g, a: Incomplete | None = ...): ...
@property
def colors(self): ...
def pdf_repr(self) -> str: ...
class DeviceCMYK:
OPERATOR: str
def __new__(cls, c, m, y, k, a: Incomplete | None = ...): ...
@property
def colors(self): ...
def pdf_repr(self) -> str: ...
def rgb8(r, g, b, a: Incomplete | None = ...): ...
def gray8(g, a: Incomplete | None = ...): ...
def cmyk8(c, m, y, k, a: Incomplete | None = ...): ...
def color_from_hex_string(hexstr): ...
def color_from_rgb_string(rgbstr): ...
class Point(NamedTuple):
x: Number
y: Number
def render(self): ...
def dot(self, other): ...
def angle(self, other): ...
def mag(self): ...
def __add__(self, other): ...
def __sub__(self, other): ...
def __neg__(self): ...
def __mul__(self, other): ...
def __rmul__(self, other): ...
def __truediv__(self, other): ...
def __floordiv__(self, other): ...
def __matmul__(self, other): ...
class Transform(NamedTuple):
a: Number
b: Number
c: Number
d: Number
e: Number
f: Number
@classmethod
def identity(cls): ...
@classmethod
def translation(cls, x, y): ...
@classmethod
def scaling(cls, x, y: Incomplete | None = ...): ...
@classmethod
def rotation(cls, theta): ...
@classmethod
def rotation_d(cls, theta_d): ...
@classmethod
def shearing(cls, x, y: Incomplete | None = ...): ...
def translate(self, x, y): ...
def scale(self, x, y: Incomplete | None = ...): ...
def rotate(self, theta): ...
def rotate_d(self, theta_d): ...
def shear(self, x, y: Incomplete | None = ...): ...
def about(self, x, y): ...
def __mul__(self, other): ...
def __rmul__(self, other): ...
def __matmul__(self, other): ...
def render(self, last_item): ...
class GraphicsStyle:
INHERIT: ClassVar[Incomplete]
MERGE_PROPERTIES: ClassVar[tuple[str, ...]]
TRANSPARENCY_KEYS: ClassVar[tuple[Name, ...]]
PDF_STYLE_KEYS: ClassVar[tuple[Name, ...]]
@classmethod
def merge(cls, parent, child): ...
def __init__(self) -> None: ...
@property
def allow_transparency(self): ...
@allow_transparency.setter
def allow_transparency(self, new): ...
@property
def paint_rule(self): ...
@paint_rule.setter
def paint_rule(self, new) -> None: ...
@property
def auto_close(self): ...
@auto_close.setter
def auto_close(self, new) -> None: ...
@property
def intersection_rule(self): ...
@intersection_rule.setter
def intersection_rule(self, new) -> None: ...
@property
def fill_color(self): ...
@fill_color.setter
def fill_color(self, color) -> None: ...
@property
def fill_opacity(self): ...
@fill_opacity.setter
def fill_opacity(self, new) -> None: ...
@property
def stroke_color(self): ...
@stroke_color.setter
def stroke_color(self, color) -> None: ...
@property
def stroke_opacity(self): ...
@stroke_opacity.setter
def stroke_opacity(self, new) -> None: ...
@property
def blend_mode(self): ...
@blend_mode.setter
def blend_mode(self, value) -> None: ...
@property
def stroke_width(self): ...
@stroke_width.setter
def stroke_width(self, width) -> None: ...
@property
def stroke_cap_style(self): ...
@stroke_cap_style.setter
def stroke_cap_style(self, value) -> None: ...
@property
def stroke_join_style(self): ...
@stroke_join_style.setter
def stroke_join_style(self, value) -> None: ...
@property
def stroke_miter_limit(self): ...
@stroke_miter_limit.setter
def stroke_miter_limit(self, value) -> None: ...
@property
def stroke_dash_pattern(self): ...
@stroke_dash_pattern.setter
def stroke_dash_pattern(self, value) -> None: ...
@property
def stroke_dash_phase(self): ...
@stroke_dash_phase.setter
def stroke_dash_phase(self, value): ...
def to_pdf_dict(self): ...
def resolve_paint_rule(self): ...
class Move(NamedTuple):
pt: Point
@property
def end_point(self): ...
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeMove(NamedTuple):
pt: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class Line(NamedTuple):
pt: Point
@property
def end_point(self): ...
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeLine(NamedTuple):
pt: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class HorizontalLine(NamedTuple):
x: Number
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeHorizontalLine(NamedTuple):
x: Number
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class VerticalLine(NamedTuple):
y: Number
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeVerticalLine(NamedTuple):
y: Number
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class BezierCurve(NamedTuple):
c1: Point
c2: Point
end: Point
@property
def end_point(self): ...
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeBezierCurve(NamedTuple):
c1: Point
c2: Point
end: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class QuadraticBezierCurve(NamedTuple):
ctrl: Point
end: Point
@property
def end_point(self): ...
def to_cubic_curve(self, start_point): ...
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeQuadraticBezierCurve(NamedTuple):
ctrl: Point
end: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class Arc(NamedTuple):
radii: Point
rotation: Number
large: bool
sweep: bool
end: Point
@staticmethod
def subdivde_sweep(sweep_angle) -> Generator[Incomplete, None, None]: ...
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RelativeArc(NamedTuple):
radii: Point
rotation: Number
large: bool
sweep: bool
end: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class Rectangle(NamedTuple):
org: Point
size: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class RoundedRectangle(NamedTuple):
org: Point
size: Point
corner_radii: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class Ellipse(NamedTuple):
radii: Point
center: Point
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class ImplicitClose(NamedTuple):
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class Close(NamedTuple):
def render(self, gsd_registry, style, last_item, initial_point): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class DrawingContext:
def __init__(self) -> None: ...
def add_item(self, item, _copy: bool = ...) -> None: ...
def render(self, gsd_registry, first_point, scale, height, starting_style): ...
def render_debug(self, gsd_registry, first_point, scale, height, starting_style, debug_stream): ...
class PaintedPath:
def __init__(self, x: int = ..., y: int = ...) -> None: ...
@property
def style(self): ...
@property
def transform(self): ...
@transform.setter
def transform(self, tf) -> None: ...
@property
def auto_close(self): ...
@auto_close.setter
def auto_close(self, should) -> None: ...
@property
def paint_rule(self): ...
@paint_rule.setter
def paint_rule(self, style) -> None: ...
@property
def clipping_path(self): ...
@clipping_path.setter
def clipping_path(self, new_clipath) -> None: ...
def transform_group(self, transform) -> _GeneratorContextManager[Incomplete]: ...
def add_path_element(self, item, _copy: bool = ...) -> None: ...
def rectangle(self, x, y, w, h, rx: int = ..., ry: int = ...): ...
def circle(self, cx, cy, r): ...
def ellipse(self, cx, cy, rx, ry): ...
def move_to(self, x, y): ...
def move_relative(self, x, y): ...
def line_to(self, x, y): ...
def line_relative(self, dx, dy): ...
def horizontal_line_to(self, x): ...
def horizontal_line_relative(self, dx): ...
def vertical_line_to(self, y): ...
def vertical_line_relative(self, dy): ...
def curve_to(self, x1, y1, x2, y2, x3, y3): ...
def curve_relative(self, dx1, dy1, dx2, dy2, dx3, dy3): ...
def quadratic_curve_to(self, x1, y1, x2, y2): ...
def quadratic_curve_relative(self, dx1, dy1, dx2, dy2): ...
def arc_to(self, rx, ry, rotation, large_arc, positive_sweep, x, y): ...
def arc_relative(self, rx, ry, rotation, large_arc, positive_sweep, dx, dy): ...
def close(self) -> None: ...
def render(
self, gsd_registry, style, last_item, initial_point, debug_stream: Incomplete | None = ..., pfx: Incomplete | None = ...
): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class ClippingPath(PaintedPath):
paint_rule: Incomplete
def __init__(self, x: int = ..., y: int = ...) -> None: ...
def render(
self, gsd_registry, style, last_item, initial_point, debug_stream: Incomplete | None = ..., pfx: Incomplete | None = ...
): ...
def render_debug(self, gsd_registry, style, last_item, initial_point, debug_stream, pfx): ...
class GraphicsContext:
style: GraphicsStyle
path_items: list[Incomplete]
def __init__(self) -> None: ...
@property
def transform(self): ...
@transform.setter
def transform(self, tf) -> None: ...
@property
def clipping_path(self): ...
@clipping_path.setter
def clipping_path(self, new_clipath) -> None: ...
def add_item(self, item, _copy: bool = ...) -> None: ...
def merge(self, other_context) -> None: ...
def build_render_list(
self,
gsd_registry,
style,
last_item,
initial_point,
debug_stream: Incomplete | None = ...,
pfx: Incomplete | None = ...,
_push_stack: bool = ...,
): ...
def render(
self,
gsd_registry,
style: DrawingContext,
last_item,
initial_point,
debug_stream: Incomplete | None = ...,
pfx: Incomplete | None = ...,
_push_stack: bool = ...,
): ...
def render_debug(
self, gsd_registry, style: DrawingContext, last_item, initial_point, debug_stream, pfx, _push_stack: bool = ...
): ...

View File

@@ -0,0 +1,101 @@
from typing import ClassVar
from .drawing import DeviceGray
class GraphicsStateMixin:
DEFAULT_DRAW_COLOR: ClassVar[DeviceGray]
DEFAULT_FILL_COLOR: ClassVar[DeviceGray]
DEFAULT_TEXT_COLOR: ClassVar[DeviceGray]
def __init__(self, *args, **kwargs) -> None: ...
@property
def draw_color(self): ...
@draw_color.setter
def draw_color(self, v) -> None: ...
@property
def fill_color(self): ...
@fill_color.setter
def fill_color(self, v) -> None: ...
@property
def text_color(self): ...
@text_color.setter
def text_color(self, v) -> None: ...
@property
def underline(self): ...
@underline.setter
def underline(self, v) -> None: ...
@property
def font_style(self): ...
@font_style.setter
def font_style(self, v) -> None: ...
@property
def font_stretching(self): ...
@font_stretching.setter
def font_stretching(self, v) -> None: ...
@property
def char_spacing(self): ...
@char_spacing.setter
def char_spacing(self, v) -> None: ...
@property
def font_family(self): ...
@font_family.setter
def font_family(self, v) -> None: ...
@property
def font_size_pt(self): ...
@font_size_pt.setter
def font_size_pt(self, v) -> None: ...
@property
def font_size(self): ...
@font_size.setter
def font_size(self, v) -> None: ...
@property
def current_font(self): ...
@current_font.setter
def current_font(self, v) -> None: ...
@property
def dash_pattern(self): ...
@dash_pattern.setter
def dash_pattern(self, v) -> None: ...
@property
def line_width(self): ...
@line_width.setter
def line_width(self, v) -> None: ...
@property
def text_mode(self): ...
@text_mode.setter
def text_mode(self, v) -> None: ...
@property
def char_vpos(self): ...
@char_vpos.setter
def char_vpos(self, v) -> None: ...
@property
def sub_scale(self): ...
@sub_scale.setter
def sub_scale(self, v) -> None: ...
@property
def sup_scale(self): ...
@sup_scale.setter
def sup_scale(self, v) -> None: ...
@property
def nom_scale(self): ...
@nom_scale.setter
def nom_scale(self, v) -> None: ...
@property
def denom_scale(self): ...
@denom_scale.setter
def denom_scale(self, v) -> None: ...
@property
def sub_lift(self): ...
@sub_lift.setter
def sub_lift(self, v) -> None: ...
@property
def sup_lift(self): ...
@sup_lift.setter
def sup_lift(self, v) -> None: ...
@property
def nom_lift(self): ...
@nom_lift.setter
def nom_lift(self, v) -> None: ...
@property
def denom_lift(self): ...
@denom_lift.setter
def denom_lift(self, v) -> None: ...

View File

@@ -0,0 +1,112 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from typing import NamedTuple
SOFT_HYPHEN: str
HYPHEN: str
SPACE: str
NEWLINE: str
class Fragment:
characters: list[str]
graphics_state: dict[str, Incomplete]
k: float
def __init__(self, characters: list[str] | str, graphics_state: dict[str, Incomplete], k: float) -> None: ...
@property
def font(self): ...
@font.setter
def font(self, v) -> None: ...
@property
def is_ttf_font(self): ...
@property
def font_style(self): ...
@property
def font_family(self): ...
@property
def font_size_pt(self): ...
@property
def font_size(self): ...
@property
def font_stretching(self): ...
@property
def char_spacing(self): ...
@property
def text_mode(self): ...
@property
def underline(self): ...
@property
def draw_color(self): ...
@property
def fill_color(self): ...
@property
def text_color(self): ...
@property
def line_width(self): ...
@property
def char_vpos(self): ...
@property
def lift(self): ...
@property
def string(self): ...
def trim(self, index: int): ...
def __eq__(self, other: Fragment) -> bool: ... # type: ignore[override]
def get_width(self, start: int = ..., end: int | None = ..., chars: str | None = ..., initial_cs: bool = ...): ...
def get_character_width(self, character: str, print_sh: bool = ..., initial_cs: bool = ...): ...
class TextLine(NamedTuple):
fragments: tuple[Incomplete, ...]
text_width: float
number_of_spaces: int
justify: bool
trailing_nl: bool = ...
class SpaceHint(NamedTuple):
original_fragment_index: int
original_character_index: int
current_line_fragment_index: int
current_line_character_index: int
line_width: float
number_of_spaces: int
class HyphenHint(NamedTuple):
original_fragment_index: int
original_character_index: int
current_line_fragment_index: int
current_line_character_index: int
line_width: float
number_of_spaces: int
curchar: str
curchar_width: float
graphics_state: dict[str, Incomplete]
k: float
class CurrentLine:
print_sh: Incomplete
fragments: Incomplete
width: int
number_of_spaces: int
space_break_hint: Incomplete
hyphen_break_hint: Incomplete
def __init__(self, print_sh: bool = ...) -> None: ...
def add_character(
self,
character: str,
character_width: float,
graphics_state: dict[str, Incomplete],
k: float,
original_fragment_index: int,
original_character_index: int,
): ...
def manual_break(self, justify: bool = ..., trailing_nl: bool = ...): ...
def automatic_break_possible(self): ...
def automatic_break(self, justify: bool): ...
class MultiLineBreak:
styled_text_fragments: Incomplete
justify: Incomplete
print_sh: Incomplete
fragment_index: int
character_index: int
idx_last_forced_break: Incomplete
def __init__(self, styled_text_fragments: Sequence[Fragment], justify: bool = ..., print_sh: bool = ...) -> None: ...
def get_line_of_given_width(self, maximum_width: float, wordsplit: bool = ...): ...

View File

@@ -0,0 +1,24 @@
from .enums import PageMode
class ViewerPreferences:
hide_toolbar: bool
hide_menubar: bool
hide_window_u_i: bool
fit_window: bool
center_window: bool
display_doc_title: bool
def __init__(
self,
hide_toolbar: bool = ...,
hide_menubar: bool = ...,
hide_window_u_i: bool = ...,
fit_window: bool = ...,
center_window: bool = ...,
display_doc_title: bool = ...,
non_full_screen_page_mode: PageMode | str = ...,
) -> None: ...
@property
def non_full_screen_page_mode(self): ...
@non_full_screen_page_mode.setter
def non_full_screen_page_mode(self, page_mode) -> None: ...
def serialize(self): ...

22
stubs/fpdf2/fpdf/sign.pyi Normal file
View File

@@ -0,0 +1,22 @@
from _typeshed import Incomplete
class Signature:
type: str
filter: str
sub_filter: str
contact_info: Incomplete | None
location: Incomplete | None
m: Incomplete | None
reason: Incomplete | None
byte_range: str
contents: str
def __init__(
self,
contact_info: Incomplete | None = ...,
location: Incomplete | None = ...,
m: Incomplete | None = ...,
reason: Incomplete | None = ...,
) -> None: ...
def serialize(self): ...
def sign_content(signer, buffer, key, cert, extra_certs, hashalgo, sign_time): ...

111
stubs/fpdf2/fpdf/svg.pyi Normal file
View File

@@ -0,0 +1,111 @@
from _typeshed import Incomplete
from collections.abc import Callable
from re import Pattern
from typing import NamedTuple
from .drawing import Point
__pdoc__: dict[str, bool]
def force_nodocument(item): ...
NUMBER_SPLIT: Pattern[str]
TRANSFORM_GETTER: Pattern[str]
class Percent(float): ...
unit_splitter: Pattern[str]
relative_length_units: set[str]
absolute_length_units: dict[str, int]
angle_units: dict[str, float]
def resolve_length(length_str, default_unit: str = ...): ...
def resolve_angle(angle_str, default_unit: str = ...): ...
def xmlns(space, name): ...
def xmlns_lookup(space, *names): ...
shape_tags: Incomplete
def svgcolor(colorstr): ...
def convert_stroke_width(incoming): ...
def convert_miterlimit(incoming): ...
def clamp_float(min_val, max_val): ...
def inheritable(value, converter=...): ...
def optional(value, converter=...): ...
svg_attr_map: dict[str, Callable[[Incomplete], tuple[str, Incomplete]]]
def parse_style(svg_element) -> None: ...
def apply_styles(stylable, svg_element) -> None: ...
class ShapeBuilder:
@staticmethod
def new_path(tag): ...
@classmethod
def rect(cls, tag): ...
@classmethod
def circle(cls, tag): ...
@classmethod
def ellipse(cls, tag): ...
@classmethod
def line(cls, tag): ...
@classmethod
def polyline(cls, tag): ...
@classmethod
def polygon(cls, tag): ...
def convert_transforms(tfstr): ...
class SVGSmoothCubicCurve(NamedTuple):
c2: Point
end: Point
@classmethod
def from_path_points(cls, path, c2x, c2y, ex, ey): ...
def render(self, path_gsds, style, last_item, initial_point): ...
def render_debug(self, path_gsds, style, last_item, initial_point, debug_stream, pfx): ...
class SVGRelativeSmoothCubicCurve(NamedTuple):
c2: Point
end: Point
@classmethod
def from_path_points(cls, path, c2x, c2y, ex, ey): ...
def render(self, path_gsds, style, last_item, initial_point): ...
def render_debug(self, path_gsds, style, last_item, initial_point, debug_stream, pfx): ...
class SVGSmoothQuadraticCurve(NamedTuple):
end: Point
@classmethod
def from_path_points(cls, path, ex, ey): ...
def render(self, path_gsds, style, last_item, initial_point): ...
def render_debug(self, path_gsds, style, last_item, initial_point, debug_stream, pfx): ...
class SVGRelativeSmoothQuadraticCurve(NamedTuple):
end: Point
@classmethod
def from_path_points(cls, path, ex, ey): ...
def render(self, path_gsds, style, last_item, initial_point): ...
def render_debug(self, path_gsds, style, last_item, initial_point, debug_stream, pfx): ...
def svg_path_converter(pdf_path, svg_path) -> None: ...
class SVGObject:
@classmethod
def from_file(cls, filename, *args, encoding: str = ..., **kwargs): ...
cross_references: Incomplete
def __init__(self, svg_text) -> None: ...
preserve_ar: Incomplete
width: Incomplete
height: Incomplete
viewbox: Incomplete
def extract_shape_info(self, root_tag) -> None: ...
base_group: Incomplete
def convert_graphics(self, root_tag) -> None: ...
def transform_to_page_viewport(self, pdf, align_viewbox: bool = ...): ...
def transform_to_rect_viewport(self, scale, width, height, align_viewbox: bool = ..., ignore_svg_top_attrs: bool = ...): ...
def draw_to_page(
self, pdf, x: Incomplete | None = ..., y: Incomplete | None = ..., debug_stream: Incomplete | None = ...
) -> None: ...
def handle_defs(self, defs) -> None: ...
def build_xref(self, xref): ...
def build_group(self, group, pdf_group: Incomplete | None = ...): ...
def build_path(self, path): ...