jspdf-utils 0.1.28 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/html-to-pdf.d.ts +19 -11
- package/dist/html-to-pdf.js +1889 -1729
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# jsPDF Utils
|
|
2
2
|
|
|
3
3
|
Utilities for rendering HTML into paginated PDF output with `jsPDF` and
|
|
4
|
-
`html2canvas`.
|
|
4
|
+
`html2canvas-pro`.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
npm install jspdf-utils jspdf html2canvas
|
|
9
|
+
npm install jspdf-utils jspdf html2canvas-pro
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Exported API
|
package/dist/html-to-pdf.d.ts
CHANGED
|
@@ -48,9 +48,10 @@ export interface PrepareResult {
|
|
|
48
48
|
/**
|
|
49
49
|
* Render an HTML element to PDF using doc.html().
|
|
50
50
|
*/
|
|
51
|
-
declare function generatePDF(doc: jsPDF, source: HTMLElement, opts?: PageOptionsInput & Pick<ImagePDFOptions, "marginContent" | "forcedPageCount">): Promise<jsPDF>;
|
|
52
|
-
type
|
|
53
|
-
|
|
51
|
+
declare function generatePDF(doc: jsPDF, source: HTMLElement, opts?: PageOptionsInput & Pick<ImagePDFOptions, "marginContent" | "forcedPageCount" | "textBorder" | "border">): Promise<jsPDF>;
|
|
52
|
+
type MarginResult = HTMLElement | string | null | undefined | void;
|
|
53
|
+
type MarginFactory = (page: number, totalPages: number) => MarginResult;
|
|
54
|
+
export interface Border {
|
|
54
55
|
/** Stroke color (default: "#000000") */
|
|
55
56
|
color?: string;
|
|
56
57
|
/** Line width in mm (default: 0.3) */
|
|
@@ -85,20 +86,27 @@ export interface TextBorder {
|
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
export interface MarginContentInput {
|
|
88
|
-
top?: HTMLElement | MarginFactory;
|
|
89
|
-
right?: HTMLElement | MarginFactory;
|
|
90
|
-
bottom?: HTMLElement | MarginFactory;
|
|
91
|
-
left?: HTMLElement | MarginFactory;
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
top?: HTMLElement | string | MarginFactory;
|
|
90
|
+
right?: HTMLElement | string | MarginFactory;
|
|
91
|
+
bottom?: HTMLElement | string | MarginFactory;
|
|
92
|
+
left?: HTMLElement | string | MarginFactory;
|
|
93
|
+
/** Distance in mm from the page edge to the margin content area (default: uses page margins). */
|
|
94
|
+
margin?: number | {
|
|
95
|
+
top?: number;
|
|
96
|
+
right?: number;
|
|
97
|
+
bottom?: number;
|
|
98
|
+
left?: number;
|
|
99
|
+
};
|
|
96
100
|
}
|
|
97
101
|
export interface ImagePDFOptions {
|
|
98
102
|
imageFormat?: "JPEG" | "PNG";
|
|
99
103
|
imageQuality?: number;
|
|
100
104
|
scale?: number;
|
|
101
105
|
marginContent?: MarginContentInput;
|
|
106
|
+
/** Draw a rectangle border around the content area. */
|
|
107
|
+
border?: Border;
|
|
108
|
+
/** Draw a repeated-text border around the content area. */
|
|
109
|
+
textBorder?: TextBorder;
|
|
102
110
|
/**
|
|
103
111
|
* Force output to the first N pages only.
|
|
104
112
|
* Example: 1 means only page 1 is generated/exported.
|