UNPKG

8 kBTypeScriptView Raw
1// Generated by dts-bundle-generator v5.3.0
2
3export declare type jsPDFConstructor = any;
4export declare type jsPDFDocument = any;
5export declare type Opts = {
6 [key: string]: string | number;
7};
8declare class DocHandler {
9 private readonly jsPDFDocument;
10 readonly userStyles: Partial<Styles>;
11 constructor(jsPDFDocument: jsPDFDocument);
12 static setDefaults(defaults: UserOptions, doc?: jsPDFDocument | null): void;
13 private static unifyColor;
14 applyStyles(styles: Partial<Styles>, fontOnly?: boolean): void;
15 splitTextToSize(text: string | string[], size: number, opts: Opts): string[];
16 rect(x: number, y: number, width: number, height: number, fillStyle: string): any;
17 getLastAutoTable(): Table | null;
18 getTextWidth(text: string | string[]): number;
19 getDocument(): any;
20 setPage(page: number): void;
21 addPage(): any;
22 getFontList(): {
23 [key: string]: string[] | undefined;
24 };
25 getGlobalOptions(): UserOptions;
26 getDocumentOptions(): UserOptions;
27 pageSize(): {
28 width: number;
29 height: number;
30 };
31 scaleFactor(): number;
32 pageNumber(): number;
33}
34declare class HookData {
35 table: Table;
36 pageNumber: number;
37 pageCount: number;
38 settings: Settings;
39 doc: jsPDFDocument;
40 cursor: Pos | null;
41 constructor(doc: DocHandler, table: Table, cursor: Pos | null);
42}
43declare class CellHookData extends HookData {
44 cell: Cell;
45 row: Row;
46 column: Column;
47 section: "head" | "body" | "foot";
48 constructor(doc: DocHandler, table: Table, cell: Cell, row: Row, column: Column, cursor: Pos | null);
49}
50export declare type MarginPadding = {
51 top: number;
52 right: number;
53 bottom: number;
54 left: number;
55};
56export interface ContentInput {
57 body: RowInput[];
58 head: RowInput[];
59 foot: RowInput[];
60 columns: ColumnInput[];
61}
62export interface TableInput {
63 id: string | number | undefined;
64 settings: Settings;
65 styles: StylesProps;
66 hooks: HookProps;
67 content: ContentInput;
68}
69export declare type Pos = {
70 x: number;
71 y: number;
72};
73export declare type PageHook = (data: HookData) => void | boolean;
74export declare type CellHook = (data: CellHookData) => void | boolean;
75export interface HookProps {
76 didParseCell: CellHook[];
77 willDrawCell: CellHook[];
78 didDrawCell: CellHook[];
79 didDrawPage: PageHook[];
80}
81export interface Settings {
82 includeHiddenHtml: boolean;
83 useCss: boolean;
84 theme: "striped" | "grid" | "plain";
85 startY: number;
86 margin: MarginPadding;
87 pageBreak: "auto" | "avoid" | "always";
88 rowPageBreak: "auto" | "avoid";
89 tableWidth: "auto" | "wrap" | number;
90 showHead: "everyPage" | "firstPage" | "never";
91 showFoot: "everyPage" | "lastPage" | "never";
92 tableLineWidth: number;
93 tableLineColor: Color;
94}
95export interface StylesProps {
96 styles: Partial<Styles>;
97 headStyles: Partial<Styles>;
98 bodyStyles: Partial<Styles>;
99 footStyles: Partial<Styles>;
100 alternateRowStyles: Partial<Styles>;
101 columnStyles: {
102 [key: string]: Partial<Styles>;
103 };
104}
105export declare type ContentSettings = {
106 body: Row[];
107 head: Row[];
108 foot: Row[];
109 columns: Column[];
110};
111declare class Table {
112 readonly id?: string | number;
113 readonly settings: Settings;
114 readonly styles: StylesProps;
115 readonly hooks: HookProps;
116 readonly columns: Column[];
117 readonly head: Row[];
118 readonly body: Row[];
119 readonly foot: Row[];
120 pageNumber: number;
121 finalY?: number;
122 startPageNumber?: number;
123 pageCount: number;
124 constructor(input: TableInput, content: ContentSettings);
125 getHeadHeight(columns: Column[]): number;
126 getFootHeight(columns: Column[]): number;
127 allRows(): Row[];
128 callCellHooks(doc: DocHandler, handlers: CellHook[], cell: Cell, row: Row, column: Column, cursor: {
129 x: number;
130 y: number;
131 } | null): boolean;
132 callEndPageHooks(doc: DocHandler, cursor: {
133 x: number;
134 y: number;
135 }): void;
136 getWidth(pageWidth: number): number;
137}
138declare class Row {
139 readonly raw: HTMLTableRowElement | RowInput;
140 readonly element?: HTMLTableRowElement;
141 readonly index: number;
142 readonly section: Section;
143 readonly cells: {
144 [key: string]: Cell;
145 };
146 spansMultiplePages: boolean;
147 height: number;
148 constructor(raw: RowInput | HTMLTableRowElement, index: number, section: Section, cells: {
149 [key: string]: Cell;
150 }, spansMultiplePages?: boolean);
151 getMaxCellHeight(columns: Column[]): number;
152 hasRowSpan(columns: Column[]): boolean;
153 canEntireRowFit(height: number, columns: Column[]): boolean;
154 getMinimumRowHeight(columns: Column[], doc: DocHandler): number;
155}
156export declare type Section = "head" | "body" | "foot";
157declare class Cell {
158 raw: HTMLTableCellElement | CellInput;
159 styles: Styles;
160 text: string[];
161 section: Section;
162 colSpan: number;
163 rowSpan: number;
164 contentHeight: number;
165 contentWidth: number;
166 wrappedWidth: number;
167 minReadableWidth: number;
168 minWidth: number;
169 width: number;
170 height: number;
171 x: number;
172 y: number;
173 constructor(raw: CellInput, styles: Styles, section: Section);
174 getTextPos(): Pos;
175 getContentHeight(scaleFactor: number): number;
176 padding(name: "vertical" | "horizontal" | "top" | "bottom" | "left" | "right"): number;
177}
178declare class Column {
179 raw: ColumnInput | null;
180 dataKey: string | number;
181 index: number;
182 wrappedWidth: number;
183 minReadableWidth: number;
184 minWidth: number;
185 width: number;
186 constructor(dataKey: string | number, raw: ColumnInput | null, index: number);
187 getMaxCustomCellWidth(table: Table): number;
188}
189export interface Styles {
190 font: "helvetica" | "times" | "courier" | string;
191 fontStyle: "normal" | "bold" | "italic" | "bolditalic";
192 overflow: "linebreak" | "ellipsize" | "visible" | "hidden" | Function;
193 fillColor: Color;
194 textColor: Color;
195 halign: "left" | "center" | "right" | "justify";
196 valign: "top" | "middle" | "bottom";
197 fontSize: number;
198 cellPadding: MarginPaddingInput;
199 lineColor: Color;
200 lineWidth: number;
201 cellWidth: "auto" | "wrap" | number;
202 minCellHeight: number;
203 minCellWidth: number;
204}
205export interface UserOptions {
206 includeHiddenHtml?: boolean;
207 useCss?: boolean;
208 theme?: "striped" | "grid" | "plain" | null;
209 startY?: number | false;
210 margin?: MarginPaddingInput;
211 pageBreak?: "auto" | "avoid" | "always";
212 rowPageBreak?: "auto" | "avoid";
213 tableWidth?: "auto" | "wrap" | number;
214 showHead?: "everyPage" | "firstPage" | "never" | boolean;
215 showFoot?: "everyPage" | "lastPage" | "never" | boolean;
216 tableLineWidth?: number;
217 tableLineColor?: Color;
218 tableId?: string | number;
219 head?: RowInput[];
220 body?: RowInput[];
221 foot?: RowInput[];
222 html?: string | HTMLTableElement;
223 columns?: ColumnInput[];
224 styles?: Partial<Styles>;
225 bodyStyles?: Partial<Styles>;
226 headStyles?: Partial<Styles>;
227 footStyles?: Partial<Styles>;
228 alternateRowStyles?: Partial<Styles>;
229 columnStyles?: {
230 [key: string]: Partial<Styles>;
231 };
232 didParseCell?: CellHook;
233 willDrawCell?: CellHook;
234 didDrawCell?: CellHook;
235 didDrawPage?: PageHook;
236}
237export declare type ColumnInput = string | number | {
238 header?: CellInput;
239 title?: CellInput;
240 footer?: CellInput;
241 dataKey?: string | number;
242 key?: string | number;
243};
244export declare type Color = [number, number, number] | number | string | false;
245export declare type MarginPaddingInput = number | number[] | {
246 top?: number;
247 right?: number;
248 bottom?: number;
249 left?: number;
250 horizontal?: number;
251 vertical?: number;
252};
253export interface CellDef {
254 rowSpan?: number;
255 colSpan?: number;
256 styles?: Partial<Styles>;
257 content?: string | string[] | number;
258 title?: string;
259 _element?: HTMLTableCellElement;
260}
261declare class HtmlRowInput extends Array<CellDef> {
262 _element: HTMLTableRowElement;
263 constructor(element: HTMLTableRowElement);
264}
265export declare type CellInput = null | string | string[] | number | boolean | CellDef;
266export declare type RowInput = {
267 [key: string]: CellInput;
268} | HtmlRowInput | CellInput[];
269export declare type autoTable = (options: UserOptions) => void;
270export declare function applyPlugin(jsPDF: jsPDFConstructor): void;
271export default function autoTable(d: jsPDFDocument, options: UserOptions): void;
272export declare function __createTable(d: jsPDFDocument, options: UserOptions): Table;
273export declare function __drawTable(d: jsPDFDocument, table: Table): void;
274
275export {};