UNPKG

36.9 kBTypeScriptView Raw
1/** @license
2 *
3 * jsPDF - PDF Document creation from JavaScript
4 *
5 * Copyright (c) 2010-2021 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
6 * 2015-2021 yWorks GmbH, http://www.yworks.com
7 * 2015-2021 Lukas Holländer <lukas.hollaender@yworks.com>, https://github.com/HackbrettXXX
8 * 2016-2018 Aras Abbasi <aras.abbasi@gmail.com>
9 * 2018 Amber Schühmacher <https://github.com/amberjs>
10 * 2018 Kevin Gonnord <https://github.com/lleios>
11 * 2018 Jackie Weng <https://github.com/jemerald>
12 * 2010 Aaron Spike, https://github.com/acspike
13 * 2012 Willow Systems Corporation, https://github.com/willowsystems
14 * 2012 Pablo Hess, https://github.com/pablohess
15 * 2012 Florian Jenett, https://github.com/fjenett
16 * 2013 Warren Weckesser, https://github.com/warrenweckesser
17 * 2013 Youssef Beddad, https://github.com/lifof
18 * 2013 Lee Driscoll, https://github.com/lsdriscoll
19 * 2013 Stefan Slonevskiy, https://github.com/stefslon
20 * 2013 Jeremy Morel, https://github.com/jmorel
21 * 2013 Christoph Hartmann, https://github.com/chris-rock
22 * 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
23 * 2014 James Makes, https://github.com/dollaruw
24 * 2014 Diego Casorran, https://github.com/diegocr
25 * 2014 Steven Spungin, https://github.com/Flamenco
26 * 2014 Kenneth Glassey, https://github.com/Gavvers
27 *
28 * Permission is hereby granted, free of charge, to any person obtaining
29 * a copy of this software and associated documentation files (the
30 * "Software"), to deal in the Software without restriction, including
31 * without limitation the rights to use, copy, modify, merge, publish,
32 * distribute, sublicense, and/or sell copies of the Software, and to
33 * permit persons to whom the Software is furnished to do so, subject to
34 * the following conditions:
35 *
36 * The above copyright notice and this permission notice shall be
37 * included in all copies or substantial portions of the Software.
38 *
39 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
40 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
43 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
44 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
45 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 *
47 * Contributor(s):
48 * siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
49 * kim3er, mfo, alnorth, Flamenco
50 */
51
52declare module "jspdf" {
53 export interface Annotation {
54 type: "text" | "freetext" | "link";
55 title?: string;
56 bounds: {
57 x: number;
58 y: number;
59 w: number;
60 h: number;
61 };
62 contents: string;
63 open?: boolean;
64 color?: string;
65 name?: string;
66 top?: number;
67 pageNumber?: number;
68 }
69
70 export interface TextWithLinkOptions {
71 pageNumber?: number;
72 magFactor?: "Fit" | "FitH" | "FitV" | "XYZ";
73 zoom?: number;
74 }
75
76 //jsPDF plugin:AutoPrint
77
78 export interface AutoPrintInput {
79 variant: "non-conform" | "javascript";
80 }
81
82 //jsPDF plugn: HTML
83 export interface Html2CanvasOptions {
84 /** Whether to parse and render the element asynchronously */
85 async?: boolean;
86
87 /** Whether to allow cross-origin images to taint the canvas */
88 allowTaint?: boolean;
89
90 /** Canvas background color, if none is specified in DOM. Set null for transparent */
91 backgroundColor?: string | null;
92
93 /** Existing canvas element to use as a base for drawing on */
94 canvas?: any;
95
96 /** Whether to use ForeignObject rendering if the browser supports it */
97 foreignObjectRendering?: boolean;
98
99 /** Predicate function which removes the matching elements from the render. */
100 ignoreElements?: (element: HTMLElement) => boolean;
101
102 /** Timeout for loading images, in milliseconds. Setting it to 0 will result in no timeout. */
103 imageTimeout?: number;
104
105 /** Whether to render each letter seperately. Necessary if letter-spacing is used. */
106 letterRendering?: boolean;
107
108 /** Whether to log events in the console. */
109 logging?: boolean;
110
111 /** Callback function which is called when the Document has been cloned for rendering, can be used to modify the contents that will be rendered without affecting the original source document. */
112 onclone?: { (doc: HTMLDocument): void };
113
114 /** Url to the proxy which is to be used for loading cross-origin images. If left empty, cross-origin images won't be loaded. */
115 proxy?: string;
116
117 /** Whether to cleanup the cloned DOM elements html2canvas creates temporarily */
118 removeContainer?: boolean;
119
120 /** The scale to use for rendering. Defaults to the browsers device pixel ratio. */
121 scale?: number;
122
123 /** Use svg powered rendering where available (FF11+). */
124 svgRendering?: boolean;
125
126 /** Whether to test each image if it taints the canvas before drawing them */
127 taintTest?: boolean;
128
129 /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */
130 useCORS?: boolean;
131
132 /** Define the width of the canvas in pixels. If null, renders with full width of the window. */
133 width?: number;
134
135 /** Define the heigt of the canvas in pixels. If null, renders with full height of the window. */
136 height?: number;
137
138 /** Crop canvas x-coordinate */
139 x?: number;
140
141 /** Crop canvas y-coordinate */
142 y?: number;
143
144 /** The x-scroll position to used when rendering element, (for example if the Element uses position: fixed ) */
145 scrollX?: number;
146
147 /** The y-scroll position to used when rendering element, (for example if the Element uses position: fixed ) */
148 scrollY?: number;
149
150 /** Window width to use when rendering Element, which may affect things like Media queries */
151 windowWidth?: number;
152
153 /** Window height to use when rendering Element, which may affect things like Media queries */
154 windowHeight?: number;
155 }
156
157 export interface HTMLWorkerProgress extends Promise<any> {
158 val: number;
159 n: number;
160 ratio: number;
161 state: any;
162 stack: Function[];
163 }
164
165 export interface HTMLWorker extends Promise<any> {
166 from(
167 src: HTMLElement | string,
168 type: "container" | "canvas" | "img" | "pdf" | "context2d"
169 ): HTMLWorker;
170 progress: HTMLWorkerProgress;
171 error(msg: string): void;
172 save(filename: string): Promise<void>;
173 set(opt: HTMLOptions): HTMLWorker;
174 get(key: "string"): HTMLWorker;
175 get(key: "string", cbk: (value: string) => void): string;
176 doCallback(): Promise<void>;
177 outputImg(
178 type: "img" | "datauristring" | "dataurlstring" | "datauri" | "dataurl"
179 ): Promise<string>;
180 outputPdf: jsPDF["output"];
181 }
182
183 export interface HTMLOptionImage {
184 type: "jpeg" | "png" | "webp";
185 quality: number;
186 }
187
188 export interface HTMLFontFace {
189 family: string;
190 style?: "italic" | "oblique" | "normal";
191 stretch?:
192 | "ultra-condensed"
193 | "extra-condensed"
194 | "condensed"
195 | "semi-condensed"
196 | "normal"
197 | "semi-expanded"
198 | "expanded"
199 | "extra-expanded"
200 | "ultra-expanded";
201 weight?:
202 | "normal"
203 | "bold"
204 | 100
205 | 200
206 | 300
207 | 400
208 | 500
209 | 600
210 | 700
211 | 800
212 | 900
213 | "100"
214 | "200"
215 | "300"
216 | "400"
217 | "500"
218 | "600"
219 | "700"
220 | "800"
221 | "900";
222 src: Array<{
223 url: string;
224 format: "truetype";
225 }>;
226 }
227
228 export interface HTMLOptions {
229 callback?: (doc: jsPDF) => void;
230 margin?: number | number[];
231 autoPaging?: boolean | "slice" | "text";
232 filename?: string;
233 image?: HTMLOptionImage;
234 html2canvas?: Html2CanvasOptions;
235 jsPDF?: jsPDF;
236 x?: number;
237 y?: number;
238 width?: number;
239 windowWidth?: number;
240 fontFaces?: HTMLFontFace[];
241 }
242
243 //jsPDF plugin: viewerPreferences
244
245 export interface ViewerPreferencesInput {
246 HideToolbar?: boolean;
247 HideMenubar?: boolean;
248 HideWindowUI?: boolean;
249 FitWindow?: boolean;
250 CenterWindow?: boolean;
251 DisplayDocTitle?: boolean;
252 NonFullScreenPageMode?: "UseNone" | "UseOutlines" | "UseThumbs" | "UseOC";
253 Direction?: "L2R" | "R2L";
254 ViewArea?: "MediaBox" | "CropBox" | "TrimBox" | "BleedBox" | "ArtBox";
255 ViewClip?: "MediaBox" | "CropBox" | "TrimBox" | "BleedBox" | "ArtBox";
256 PrintArea?: "MediaBox" | "CropBox" | "TrimBox" | "BleedBox" | "ArtBox";
257 PrintClip?: "MediaBox" | "CropBox" | "TrimBox" | "BleedBox" | "ArtBox";
258 PrintScaling?: "AppDefault" | "None";
259 Duplex?: "Simplex" | "DuplexFlipShortEdge" | "DuplexFlipLongEdge" | "none";
260 PickTrayByPDFSize?: boolean;
261 PrintPageRange?: number[][];
262 NumCopies?: number;
263 }
264
265 //jsPDF plugin: Outline
266
267 export interface Outline {
268 add(parent: any, title: string, options: OutlineOptions): OutlineItem;
269 }
270 export interface OutlineItem {
271 title: string;
272 options: any;
273 children: any[];
274 }
275 export interface OutlineOptions {
276 pageNumber: number;
277 }
278 // jsPDF plugin: AcroForm
279 export abstract class AcroFormField {}
280 export interface AcroFormField {
281 constructor(): AcroFormField;
282 showWhenPrinted: boolean;
283 x: number;
284 y: number;
285 width: number;
286 height: number;
287 fieldName: string;
288 fontName: string;
289 fontStyle: string;
290 fontSize: number;
291 maxFontSize: number;
292 color: string;
293 defaultValue: string;
294 value: string;
295 hasAnnotation: boolean;
296 readOnly: boolean;
297 required: boolean;
298 noExport: boolean;
299 textAlign: "left" | "center" | "right";
300 }
301
302 export class AcroFormChoiceField {}
303 export interface AcroFormChoiceField extends AcroFormField {
304 topIndex: number;
305 getOptions(): string[];
306 setOptions(value: string[]): void;
307 addOption(value: string): void;
308 removeOption(value: string, allEntries: boolean): void;
309 combo: boolean;
310 edit: boolean;
311 sort: boolean;
312 multiSelect: boolean;
313 doNotSpellCheck: boolean;
314 commitOnSelChange: boolean;
315 }
316
317 export class AcroFormListBox {}
318 export interface AcroFormListBox extends AcroFormChoiceField {}
319
320 export class AcroFormComboBox {}
321 export interface AcroFormComboBox extends AcroFormListBox {}
322
323 export class AcroFormEditBox {}
324 export interface AcroFormEditBox extends AcroFormComboBox {}
325
326 export class AcroFormButton {}
327 export interface AcroFormButton extends AcroFormField {
328 noToggleToOff: boolean;
329 radio: boolean;
330 pushButton: boolean;
331 radioIsUnison: boolean;
332 caption: string;
333 appearanceState: any;
334 }
335
336 export class AcroFormPushButton {}
337 export interface AcroFormPushButton extends AcroFormButton {}
338
339 export class AcroFormChildClass {}
340 export interface AcroFormChildClass extends AcroFormField {
341 Parent: any;
342 optionName: string;
343 caption: string;
344 appearanceState: "On" | "Off";
345 }
346
347 export class AcroFormRadioButton {}
348 export interface AcroFormRadioButton extends AcroFormButton {
349 setAppearance(appearance: string): void;
350 createOption(name: string): AcroFormChildClass;
351 }
352
353 export class AcroFormCheckBox {}
354 export interface AcroFormCheckBox extends AcroFormButton {
355 appearanceState: "On" | "Off";
356 }
357
358 export class AcroFormTextField {}
359 export interface AcroFormTextField extends AcroFormField {
360 multiline: boolean;
361 fileSelect: boolean;
362 doNotSpellCheck: boolean;
363 doNotScroll: boolean;
364 comb: boolean;
365 richText: boolean;
366 maxLength: number;
367 hasAppearanceStream: boolean;
368 }
369
370 export class AcroFormPasswordField {}
371 export interface AcroFormPasswordField extends AcroFormTextField {}
372 // jsPDF plugin: Context2D
373
374 export interface Gradient {
375 addColorStop(position: number, color: string): void;
376 getColor(): string;
377 }
378
379 export interface Context2d {
380 autoPaging: boolean;
381 margin: number[];
382 fillStyle: string | Gradient;
383 filter: string;
384 font: string;
385 globalAlpha: number;
386 globalCompositeOperation: "source-over";
387 imageSmoothingEnabled: boolean;
388 imageSmoothingQuality: "low" | "high";
389 ignoreClearRect: boolean;
390 lastBreak: number;
391 lineCap: "butt" | "round" | "square";
392 lineDashOffset: number;
393 lineJoin: "bevel" | "round" | "miter";
394 lineWidth: number;
395 miterLimit: number;
396 pageBreaks: number[];
397 pageWrapXEnabled: boolean;
398 pageWrapYEnabled: boolean;
399 posX: number;
400 posY: number;
401 shadowBlur: number;
402 shadowColor: string;
403 shadowOffsetX: number;
404 shadowOffsetY: number;
405 strokeStyle: string | Gradient;
406 textAlign: "right" | "end" | "center" | "left" | "start";
407 textBaseline:
408 | "alphabetic"
409 | "bottom"
410 | "top"
411 | "hanging"
412 | "middle"
413 | "ideographic";
414 arc(
415 x: number,
416 y: number,
417 radius: number,
418 startAngle: number,
419 endAngle: number,
420 counterclockwise: boolean
421 ): void;
422 arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
423 beginPath(): void;
424 bezierCurveTo(
425 cp1x: number,
426 cp1y: number,
427 cp2x: number,
428 cp2y: number,
429 x: number,
430 y: number
431 ): void;
432 clearRect(x: number, y: number, w: number, h: number): void;
433 clip(): jsPDF;
434 clipEvenOdd(): jsPDF;
435 closePath(): void;
436 createLinearGradient(
437 x0: number,
438 y0: number,
439 x1: number,
440 y1: number
441 ): Gradient;
442 createPattern(): Gradient;
443 createRadialGradient(): Gradient;
444 drawImage(
445 img: string,
446 x: number,
447 y: number,
448 width: number,
449 height: number
450 ): void;
451 drawImage(
452 img: string,
453 sx: number,
454 sy: number,
455 swidth: number,
456 sheight: number,
457 x: number,
458 y: number,
459 width: number,
460 height: number
461 ): void;
462 fill(): void;
463 fillRect(x: number, y: number, w: number, h: number): void;
464 fillText(text: string, x: number, y: number, maxWidth?: number): void;
465 lineTo(x: number, y: number): void;
466 measureText(text: string): number;
467 moveTo(x: number, y: number): void;
468 quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
469 rect(x: number, y: number, w: number, h: number): void;
470 restore(): void;
471 rotate(angle: number): void;
472 save(): void;
473 scale(scalewidth: number, scaleheight: number): void;
474 setTransform(
475 a: number,
476 b: number,
477 c: number,
478 d: number,
479 e: number,
480 f: number
481 ): void;
482 stroke(): void;
483 strokeRect(x: number, y: number, w: number, h: number): void;
484 strokeText(text: string, x: number, y: number, maxWidth?: number): void;
485 transform(
486 a: number,
487 b: number,
488 c: number,
489 d: number,
490 e: number,
491 f: number
492 ): void;
493 translate(x: number, y: number): void;
494 }
495
496 export type ImageCompression = "NONE" | "FAST" | "MEDIUM" | "SLOW";
497 export type ColorSpace =
498 | "DeviceRGB"
499 | "DeviceGray"
500 | "DeviceCMYK"
501 | "CalGray"
502 | "CalRGB"
503 | "Lab"
504 | "ICCBased"
505 | "Indexed"
506 | "Pattern"
507 | "Separation"
508 | "DeviceN";
509
510 export type ImageFormat =
511 | "RGBA"
512 | "UNKNOWN"
513 | "PNG"
514 | "TIFF"
515 | "JPG"
516 | "JPEG"
517 | "JPEG2000"
518 | "GIF87a"
519 | "GIF89a"
520 | "WEBP"
521 | "BMP";
522
523 export interface ImageOptions {
524 imageData:
525 | string
526 | HTMLImageElement
527 | HTMLCanvasElement
528 | Uint8Array
529 | RGBAData;
530 x: number;
531 y: number;
532 width: number;
533 height: number;
534 alias?: string;
535 compression?: ImageCompression;
536 rotation?: number;
537 format?: ImageFormat;
538 }
539 export interface ImageProperties {
540 alias: number;
541 width: number;
542 height: number;
543 colorSpace: ColorSpace;
544 bitsPerComponent: number;
545 filter: string;
546 decodeParameters?: string;
547 transparency?: any;
548 palette?: any;
549 sMask?: any;
550 predictor?: number;
551 index: number;
552 data: string;
553 fileType: ImageFormat;
554 }
555
556 export interface TextOptionsLight {
557 align?: "left" | "center" | "right" | "justify";
558 angle?: number | Matrix;
559 baseline?:
560 | "alphabetic"
561 | "ideographic"
562 | "bottom"
563 | "top"
564 | "middle"
565 | "hanging";
566 flags?: {
567 noBOM: boolean;
568 autoencode: boolean;
569 };
570 rotationDirection?: 0 | 1;
571 charSpace?: number;
572 horizontalScale?: number;
573 lineHeightFactor?: number;
574 maxWidth?: number;
575 renderingMode?:
576 | "fill"
577 | "stroke"
578 | "fillThenStroke"
579 | "invisible"
580 | "fillAndAddForClipping"
581 | "strokeAndAddPathForClipping"
582 | "fillThenStrokeAndAddToPathForClipping"
583 | "addToPathForClipping";
584 isInputVisual?: boolean;
585 isOutputVisual?: boolean;
586 isInputRtl?: boolean;
587 isOutputRtl?: boolean;
588 isSymmetricSwapping?: boolean;
589 }
590 export interface TextOptions extends TextOptionsLight {
591 text: string | string[];
592 x: number;
593 y: number;
594 }
595
596 export interface TableRowData {
597 row?: number;
598 data?: any[];
599 }
600
601 export interface TableCellData {
602 row?: number;
603 col?: number;
604 data?: any;
605 }
606
607 export interface TableConfig {
608 printHeaders?: boolean;
609 autoSize?: boolean;
610 margins?: number;
611 fontSize?: number;
612 padding?: number;
613 headerBackgroundColor?: string;
614 headerTextColor?: string;
615 rowStart?: (e: TableRowData, doc: jsPDF) => void;
616 cellStart?: (e: TableCellData, doc: jsPDF) => void;
617 css?: {
618 "font-size": number;
619 };
620 }
621
622 export interface CellConfig {
623 name: string;
624 prompt: string;
625 align: "left" | "center" | "right";
626 padding: number;
627 width: number;
628 }
629
630 export interface EncryptionOptions {
631 userPassword?: string;
632 ownerPassword?: string;
633 userPermissions?: ("print" | "modify" | "copy" | "annot-forms")[];
634 }
635
636 export interface jsPDFOptions {
637 orientation?: "p" | "portrait" | "l" | "landscape";
638 unit?: "pt" | "px" | "in" | "mm" | "cm" | "ex" | "em" | "pc";
639 format?: string | number[];
640 compress?: boolean;
641 precision?: number;
642 filters?: string[];
643 userUnit?: number;
644 encryption?: EncryptionOptions;
645 putOnlyUsedFonts?: boolean;
646 hotfixes?: string[];
647 floatPrecision?: number | "smart";
648 }
649
650 export interface Point {
651 x: number;
652 y: number;
653 }
654
655 export interface Rectangle extends Point {
656 w: number;
657 h: number;
658 }
659
660 export interface PageInfo {
661 objId: number;
662 pageNumber: number;
663 pageContext: any;
664 }
665
666 export interface Font {
667 id: number;
668 encoding: string;
669 fontName: string;
670 fontStyle: string;
671 isStandardFont: boolean;
672 metadata: any;
673 objectNumber: number;
674 postScriptName: string;
675 }
676
677 export interface DocumentProperties {
678 title?: string;
679 subject?: string;
680 author?: string;
681 keywords?: string;
682 creator?: string;
683 }
684
685 export interface PatternData {
686 key: string;
687 matrix?: Matrix;
688 boundingBox?: number[];
689 xStep?: number;
690 yStep?: number;
691 }
692
693 // Single dimensional array of RGBA values. For example from canvas getImageData.
694 export interface RGBAData {
695 data: Uint8ClampedArray;
696 width: number;
697 height: number;
698 }
699
700 export interface PubSub {
701 subscribe(
702 topic: string,
703 callback: (...args: any[]) => void,
704 once?: boolean
705 ): string;
706 unsubscribe(token: string): boolean;
707 publish(topic: string, ...args: any[]): void;
708 getTopics(): Record<
709 string,
710 Record<string, [(...args: any[]) => void, boolean]>
711 >;
712 }
713
714 export class jsPDF {
715 constructor(options?: jsPDFOptions);
716 constructor(
717 orientation?: "p" | "portrait" | "l" | "landscape",
718 unit?: "pt" | "px" | "in" | "mm" | "cm" | "ex" | "em" | "pc",
719 format?: string | number[],
720 compressPdf?: boolean
721 );
722
723 CapJoinStyles: any;
724 version: string;
725
726 compatAPI(body?: (pdf: jsPDF) => void): void;
727 advancedAPI(body?: (pdf: jsPDF) => void): void;
728 isAdvancedAPI(): boolean;
729
730 addFont(
731 postScriptName: string,
732 id: string,
733 fontStyle: string,
734 fontWeight?: string | number,
735 encoding?:
736 | "StandardEncoding"
737 | "MacRomanEncoding"
738 | "Identity-H"
739 | "WinAnsiEncoding",
740 isStandardFont?: boolean
741 ): string;
742 addFont(
743 url: URL,
744 id: string,
745 fontStyle: string,
746 fontWeight?: string | number,
747 encoding?:
748 | "StandardEncoding"
749 | "MacRomanEncoding"
750 | "Identity-H"
751 | "WinAnsiEncoding"
752 ): string;
753 addGState(key: string, gState: GState): jsPDF;
754 addPage(
755 format?: string | number[],
756 orientation?: "p" | "portrait" | "l" | "landscape"
757 ): jsPDF;
758 beginFormObject(
759 x: number,
760 y: number,
761 width: number,
762 height: number,
763 matrix: any
764 ): jsPDF;
765 circle(x: number, y: number, r: number, style?: string | null): jsPDF;
766 clip(rule?: "evenodd"): jsPDF;
767 discardPath(): jsPDF;
768 deletePage(targetPage: number): jsPDF;
769 doFormObject(key: any, matrix: any): jsPDF;
770 ellipse(
771 x: number,
772 y: number,
773 rx: number,
774 ry: number,
775 style?: string | null
776 ): jsPDF;
777 endFormObject(key: any): jsPDF;
778 f2(number: number): string;
779 f3(number: number): string;
780 getCharSpace(): number;
781 getCreationDate(type: string): Date;
782 getCurrentPageInfo(): PageInfo;
783 getDrawColor(): string;
784 getFileId(): string;
785 getFillColor(): string;
786 getFont(): Font;
787 getFontList(): { [key: string]: string[] };
788 getFontSize(): number;
789 getFormObject(key: any): any;
790 getLineHeight(): number;
791 getLineHeightFactor(): number;
792 getLineWidth(): number;
793 getNumberOfPages(): number;
794 getPageInfo(pageNumberOneBased: number): PageInfo;
795 getR2L(): boolean;
796 getStyle(style: string): string;
797 getTextColor(): string;
798 insertPage(beforePage: number): jsPDF;
799 line(
800 x1: number,
801 y1: number,
802 x2: number,
803 y2: number,
804 style?: string | null
805 ): jsPDF;
806 lines(
807 lines: any[],
808 x: any,
809 y: any,
810 scale?: any,
811 style?: string | null,
812 closed?: boolean
813 ): jsPDF;
814 clipEvenOdd(): jsPDF;
815 close(): jsPDF;
816 stroke(): jsPDF;
817 fill(pattern?: PatternData): jsPDF;
818 fillEvenOdd(pattern?: PatternData): jsPDF;
819 fillStroke(pattern?: PatternData): jsPDF;
820 fillStrokeEvenOdd(pattern?: PatternData): jsPDF;
821 moveTo(x: number, y: number): jsPDF;
822 lineTo(x: number, y: number): jsPDF;
823 curveTo(
824 x1: number,
825 y1: number,
826 x2: number,
827 y2: number,
828 x3: number,
829 y3: number
830 ): jsPDF;
831 movePage(targetPage: number, beforePage: number): jsPDF;
832 output(): string;
833 output(type: "arraybuffer"): ArrayBuffer;
834 output(type: "blob"): Blob;
835 output(type: "bloburi" | "bloburl"): URL;
836 output(
837 type: "datauristring" | "dataurlstring",
838 options?: { filename?: string }
839 ): string;
840 output(
841 type: "pdfobjectnewwindow" | "pdfjsnewwindow" | "dataurlnewwindow",
842 options?: { filename?: string }
843 ): Window;
844 output(
845 type: "dataurl" | "datauri",
846 options?: { filename?: string }
847 ): boolean;
848 pdfEscape(text: string, flags: any): string;
849 path(lines?: any[], style?: string): jsPDF;
850 rect(
851 x: number,
852 y: number,
853 w: number,
854 h: number,
855 style?: string | null
856 ): jsPDF;
857 restoreGraphicsState(): jsPDF;
858 roundedRect(
859 x: number,
860 y: number,
861 w: number,
862 h: number,
863 rx: number,
864 ry: number,
865 style?: string | null
866 ): jsPDF;
867 save(filename: string, options: { returnPromise: true }): Promise<void>;
868 save(filename?: string): jsPDF;
869 saveGraphicsState(): jsPDF;
870 setCharSpace(charSpace: number): jsPDF;
871 setCreationDate(date?: Date | string): jsPDF;
872 setCurrentTransformationMatrix(matrix: Matrix): jsPDF;
873 setDisplayMode(
874 zoom:
875 | undefined
876 | null
877 | number
878 | "fullheight"
879 | "fullwidth"
880 | "fullpage"
881 | "original"
882 | string,
883 layout?:
884 | undefined
885 | null
886 | "continuous"
887 | "single"
888 | "twoleft"
889 | "tworight"
890 | "two",
891 pmode?: undefined | null | "UseOutlines" | "UseThumbs" | "FullScreen"
892 ): jsPDF;
893 setDocumentProperties(properties: DocumentProperties): jsPDF;
894 setProperties(properties: DocumentProperties): jsPDF;
895 setDrawColor(ch1: string): jsPDF;
896 setDrawColor(ch1: number): jsPDF;
897 setDrawColor(ch1: number, ch2: number, ch3: number, ch4?: number): jsPDF;
898 setFileId(value: string): jsPDF;
899 setFillColor(ch1: string): jsPDF;
900 setFillColor(ch1: number, ch2: number, ch3: number, ch4?: number): jsPDF;
901 setFont(
902 fontName: string,
903 fontStyle?: string,
904 fontWeight?: string | number
905 ): jsPDF;
906 setFontSize(size: number): jsPDF;
907 setGState(gState: any): jsPDF;
908 setLineCap(style: string | number): jsPDF;
909 setLineDashPattern(dashArray: number[], dashPhase: number): jsPDF;
910 setLineHeightFactor(value: number): jsPDF;
911 setLineJoin(style: string | number): jsPDF;
912 setLineMiterLimit(length: number): jsPDF;
913 setLineWidth(width: number): jsPDF;
914 setPage(pageNumber: number): jsPDF;
915 setR2L(value: boolean): jsPDF;
916 setTextColor(ch1: string): jsPDF;
917 setTextColor(ch1: number): jsPDF;
918 setTextColor(ch1: number, ch2: number, ch3: number, ch4?: number): jsPDF;
919 text(
920 text: string | string[],
921 x: number,
922 y: number,
923 options?: TextOptionsLight,
924 transform?: number | any
925 ): jsPDF;
926 triangle(
927 x1: number,
928 y1: number,
929 x2: number,
930 y2: number,
931 x3: number,
932 y3: number,
933 style?: string | null
934 ): jsPDF;
935 getHorizontalCoordinateString(value: number): number;
936 getVerticalCoordinateString(value: number): number;
937
938 internal: {
939 events: PubSub;
940 scaleFactor: number;
941 pageSize: {
942 width: number;
943 getWidth: () => number;
944 height: number;
945 getHeight: () => number;
946 };
947 pages: number[];
948 getEncryptor(objectId: number): (data: string) => string;
949 };
950
951 /**
952 * jsPDF plugins below:
953 *
954 * - AcroForm
955 * - AddImage
956 * - Annotations
957 * - AutoPrint
958 * - Canvas
959 * - Cell
960 * - Context2D
961 * - fileloading
962 * - html
963 * - JavaScript
964 * - split_text_to_size
965 * - SVG
966 * - total_pages
967 * - utf8
968 * - vfs
969 * - xmp_metadata
970 */
971
972 // jsPDF plugin: addImage
973 addImage(
974 imageData:
975 | string
976 | HTMLImageElement
977 | HTMLCanvasElement
978 | Uint8Array
979 | RGBAData,
980 format: string,
981 x: number,
982 y: number,
983 w: number,
984 h: number,
985 alias?: string,
986 compression?: ImageCompression,
987 rotation?: number
988 ): jsPDF;
989 addImage(
990 imageData:
991 | string
992 | HTMLImageElement
993 | HTMLCanvasElement
994 | Uint8Array
995 | RGBAData,
996 x: number,
997 y: number,
998 w: number,
999 h: number,
1000 alias?: string,
1001 compression?: ImageCompression,
1002 rotation?: number
1003 ): jsPDF;
1004 addImage(options: ImageOptions): jsPDF;
1005 getImageProperties(
1006 imageData: string | HTMLImageElement | HTMLCanvasElement | Uint8Array
1007 ): ImageProperties;
1008
1009 // jsPDF plugin: arabic
1010 processArabic(text: string): string;
1011
1012 // jsPDF plugin: Annotations
1013 createAnnotation(options: Annotation): void;
1014 link(x: number, y: number, w: number, h: number, options: any): void;
1015 textWithLink(text: string, x: number, y: number, options: any): number;
1016 getTextWidth(text: string): number;
1017
1018 // jsPDF plugin: AutoPrint
1019 autoPrint(options?: AutoPrintInput): jsPDF;
1020
1021 // jsPDF plugin: AcroForm
1022 addField(field: AcroFormField): jsPDF;
1023
1024 AcroForm: {
1025 ChoiceField(): AcroFormChoiceField;
1026 ListBox(): AcroFormListBox;
1027 ComboBox(): AcroFormComboBox;
1028 EditBox(): AcroFormEditBox;
1029 Button(): AcroFormButton;
1030 PushButton(): AcroFormPushButton;
1031 RadioButton(): AcroFormRadioButton;
1032 CheckBox(): AcroFormCheckBox;
1033 TextField(): AcroFormTextField;
1034 PasswordField(): AcroFormPasswordField;
1035 Appearance(): any;
1036 };
1037
1038 // jsPDF plugin: Canvas
1039 canvas: {
1040 pdf: jsPDF;
1041 width: number;
1042 height: number;
1043 getContext(type?: string): Context2d;
1044 style: any;
1045 };
1046
1047 // jsPDF plugin: Cell
1048 setHeaderFunction(
1049 func: (jsPDFInstance: jsPDF, pages: number) => number[]
1050 ): jsPDF;
1051 getTextDimensions(
1052 text: string,
1053 options?: {
1054 font?: string;
1055 fontSize?: number;
1056 maxWidth?: number;
1057 scaleFactor?: number;
1058 }
1059 ): { w: number; h: number };
1060
1061 cellAddPage(): jsPDF;
1062 cell(
1063 x: number,
1064 y: number,
1065 w: number,
1066 h: number,
1067 txt: string,
1068 ln: number,
1069 align: string
1070 ): jsPDF;
1071 table(
1072 x: number,
1073 y: number,
1074 data: { [key: string]: string }[],
1075 headers: string[] | CellConfig[],
1076 config: TableConfig
1077 ): jsPDF;
1078 calculateLineHeight(
1079 headerNames: string[],
1080 columnWidths: number[],
1081 model: any[]
1082 ): number;
1083 setTableHeaderRow(config: CellConfig[]): void;
1084 printHeaderRow(lineNumber: number, new_page?: boolean): void;
1085
1086 context2d: Context2d;
1087
1088 //jsPDF plugin: Outline
1089 outline: Outline;
1090 // jsPDF plugin: fileloading
1091 loadFile(url: string, sync?: true): string;
1092 loadFile(
1093 url: string,
1094 sync: false,
1095 callback: (data: string) => string
1096 ): void;
1097
1098 // jsPDF plugin: html
1099 html(src: string | HTMLElement, options?: HTMLOptions): HTMLWorker;
1100
1101 // jsPDF plugin: JavaScript
1102 addJS(javascript: string): jsPDF;
1103
1104 // jsPDF plugin: split_text_to_size
1105 getCharWidthsArray(text: string, options?: any): any[];
1106 getStringUnitWidth(text: string, options?: any): number;
1107 splitTextToSize(text: string, maxlen: number, options?: any): any;
1108
1109 // jsPDF plugin: SVG
1110 addSvgAsImage(
1111 svg: string,
1112 x: number,
1113 y: number,
1114 w: number,
1115 h: number,
1116 alias?: string,
1117 compression?: boolean,
1118 rotation?: number
1119 ): jsPDF;
1120 // jsPDF plugin: setlanguage
1121 setLanguage(
1122 langCode:
1123 | "af"
1124 | "sq"
1125 | "ar"
1126 | "ar-DZ"
1127 | "ar-BH"
1128 | "ar-EG"
1129 | "ar-IQ"
1130 | "ar-JO"
1131 | "ar-KW"
1132 | "ar-LB"
1133 | "ar-LY"
1134 | "ar-MA"
1135 | "ar-OM"
1136 | "ar-QA"
1137 | "ar-SA"
1138 | "ar-SY"
1139 | "ar-TN"
1140 | "ar-AE"
1141 | "ar-YE"
1142 | "an"
1143 | "hy"
1144 | "as"
1145 | "ast"
1146 | "az"
1147 | "eu"
1148 | "be"
1149 | "bn"
1150 | "bs"
1151 | "br"
1152 | "bg"
1153 | "my"
1154 | "ca"
1155 | "ch"
1156 | "ce"
1157 | "zh"
1158 | "zh-HK"
1159 | "zh-CN"
1160 | "zh-SG"
1161 | "zh-TW"
1162 | "cv"
1163 | "co"
1164 | "cr"
1165 | "hr"
1166 | "cs"
1167 | "da"
1168 | "nl"
1169 | "nl-BE"
1170 | "en"
1171 | "en-AU"
1172 | "en-BZ"
1173 | "en-CA"
1174 | "en-IE"
1175 | "en-JM"
1176 | "en-NZ"
1177 | "en-PH"
1178 | "en-ZA"
1179 | "en-TT"
1180 | "en-GB"
1181 | "en-US"
1182 | "en-ZW"
1183 | "eo"
1184 | "et"
1185 | "fo"
1186 | "fj"
1187 | "fi"
1188 | "fr"
1189 | "fr-BE"
1190 | "fr-CA"
1191 | "fr-FR"
1192 | "fr-LU"
1193 | "fr-MC"
1194 | "fr-CH"
1195 | "fy"
1196 | "fur"
1197 | "gd"
1198 | "gd-IE"
1199 | "gl"
1200 | "ka"
1201 | "de"
1202 | "de-AT"
1203 | "de-DE"
1204 | "de-LI"
1205 | "de-LU"
1206 | "de-CH"
1207 | "el"
1208 | "gu"
1209 | "ht"
1210 | "he"
1211 | "hi"
1212 | "hu"
1213 | "is"
1214 | "id"
1215 | "iu"
1216 | "ga"
1217 | "it"
1218 | "it-CH"
1219 | "ja"
1220 | "kn"
1221 | "ks"
1222 | "kk"
1223 | "km"
1224 | "ky"
1225 | "tlh"
1226 | "ko"
1227 | "ko-KP"
1228 | "ko-KR"
1229 | "la"
1230 | "lv"
1231 | "lt"
1232 | "lb"
1233 | "mk"
1234 | "ms"
1235 | "ml"
1236 | "mt"
1237 | "mi"
1238 | "mr"
1239 | "mo"
1240 | "nv"
1241 | "ng"
1242 | "ne"
1243 | "no"
1244 | "nb"
1245 | "nn"
1246 | "oc"
1247 | "or"
1248 | "om"
1249 | "fa"
1250 | "fa-IR"
1251 | "pl"
1252 | "pt"
1253 | "pt-BR"
1254 | "pa"
1255 | "pa-IN"
1256 | "pa-PK"
1257 | "qu"
1258 | "rm"
1259 | "ro"
1260 | "ro-MO"
1261 | "ru"
1262 | "ru-MO"
1263 | "sz"
1264 | "sg"
1265 | "sa"
1266 | "sc"
1267 | "sd"
1268 | "si"
1269 | "sr"
1270 | "sk"
1271 | "sl"
1272 | "so"
1273 | "sb"
1274 | "es"
1275 | "es-AR"
1276 | "es-BO"
1277 | "es-CL"
1278 | "es-CO"
1279 | "es-CR"
1280 | "es-DO"
1281 | "es-EC"
1282 | "es-SV"
1283 | "es-GT"
1284 | "es-HN"
1285 | "es-MX"
1286 | "es-NI"
1287 | "es-PA"
1288 | "es-PY"
1289 | "es-PE"
1290 | "es-PR"
1291 | "es-ES"
1292 | "es-UY"
1293 | "es-VE"
1294 | "sx"
1295 | "sw"
1296 | "sv"
1297 | "sv-FI"
1298 | "sv-SV"
1299 | "ta"
1300 | "tt"
1301 | "te"
1302 | "th"
1303 | "tig"
1304 | "ts"
1305 | "tn"
1306 | "tr"
1307 | "tk"
1308 | "uk"
1309 | "hsb"
1310 | "ur"
1311 | "ve"
1312 | "vi"
1313 | "vo"
1314 | "wa"
1315 | "cy"
1316 | "xh"
1317 | "ji"
1318 | "zu"
1319 ): jsPDF;
1320
1321 // jsPDF plugin: total_pages
1322 putTotalPages(pageExpression: string): jsPDF;
1323
1324 // jsPDF plugin: viewerpreferences
1325 viewerPreferences(
1326 options: ViewerPreferencesInput,
1327 doReset?: boolean
1328 ): jsPDF;
1329 viewerPreferences(arg: "reset"): jsPDF;
1330
1331 // jsPDF plugin: vfs
1332 existsFileInVFS(filename: string): boolean;
1333 addFileToVFS(filename: string, filecontent: string): jsPDF;
1334 getFileFromVFS(filename: string): string;
1335
1336 // jsPDF plugin: xmp_metadata
1337 addMetadata(metadata: string, namespaceuri?: string): jsPDF;
1338
1339 Matrix(
1340 a: number,
1341 b: number,
1342 c: number,
1343 d: number,
1344 e: number,
1345 f: number
1346 ): Matrix;
1347 matrixMult(m1: Matrix, m2: Matrix): Matrix;
1348 unitMatrix: Matrix;
1349
1350 GState(parameters: GState): GState;
1351
1352 ShadingPattern(
1353 type: ShadingPatternType,
1354 coords: number[],
1355 colors: ShadingPatterStop[],
1356 gState?: GState,
1357 matrix?: Matrix
1358 ): ShadingPattern;
1359 TilingPattern(
1360 boundingBox: number[],
1361 xStep: number,
1362 yStep: number,
1363 gState?: GState,
1364 matrix?: Matrix
1365 ): TilingPattern;
1366
1367 addShadingPattern(key: string, pattern: ShadingPattern): jsPDF;
1368 beginTilingPattern(pattern: TilingPattern): void;
1369 endTilingPattern(key: string, pattern: TilingPattern): void;
1370
1371 static API: jsPDFAPI;
1372 static version: string;
1373 }
1374
1375 export class GState {
1376 constructor(parameters: GState);
1377 }
1378
1379 export interface GState {
1380 opacity?: number;
1381 "stroke-opacity"?: number;
1382 }
1383
1384 export interface Matrix {
1385 a: number;
1386 b: number;
1387 c: number;
1388 d: number;
1389 e: number;
1390 f: number;
1391
1392 sx: number;
1393 shy: number;
1394 shx: number;
1395 sy: number;
1396 tx: number;
1397 ty: number;
1398
1399 join(separator?: string): string;
1400 multiply(matrix: Matrix): Matrix;
1401 decompose(): {
1402 scale: Matrix;
1403 translate: Matrix;
1404 rotate: Matrix;
1405 skew: Matrix;
1406 };
1407 toString(): string;
1408 inversed(): Matrix;
1409 applyToPoint(point: Point): Point;
1410 applyToRectangle(rect: Rectangle): Rectangle;
1411 clone(): Matrix;
1412 }
1413
1414 export interface Pattern {
1415 gState?: GState;
1416 matrix?: Matrix;
1417 }
1418
1419 export interface ShadingPatterStop {
1420 offset: number;
1421 color: number[];
1422 }
1423
1424 export type ShadingPatternType = "axial" | "radial";
1425
1426 export class ShadingPattern {
1427 constructor(
1428 type: ShadingPatternType,
1429 coords: number[],
1430 colors: ShadingPatterStop[],
1431 gState?: GState,
1432 matrix?: Matrix
1433 );
1434 }
1435 export interface ShadingPattern extends Pattern {
1436 coords: number[];
1437 colors: ShadingPatterStop[];
1438 }
1439
1440 export class TilingPattern {
1441 constructor(
1442 boundingBox: number[],
1443 xStep: number,
1444 yStep: number,
1445 gState?: GState,
1446 matrix?: Matrix
1447 );
1448 }
1449
1450 export interface TilingPattern extends Pattern {
1451 boundingBox: number[];
1452 xStep: number;
1453 yStep: number;
1454 }
1455
1456 export interface jsPDFAPI {
1457 events: any[];
1458 }
1459
1460 export default jsPDF;
1461}