react-vector-pdf 0.3.6 → 0.3.7

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/dist/index.d.ts CHANGED
@@ -1,4 +1,289 @@
1
- export * from './components';
2
- export { PdfList } from './components/PdfList';
3
- export { PdfRenderer } from './core/PdfRenderer';
4
- export * from './core/types';
1
+ import { default as default_2 } from 'react';
2
+ import { jsPDF } from 'jspdf';
3
+
4
+ export declare type Align = "left" | "center" | "right" | "justify";
5
+
6
+ export declare interface BoxStyle {
7
+ borderColor?: string;
8
+ borderWidth?: number;
9
+ fillColor?: string;
10
+ radius?: number;
11
+ padding?: number | {
12
+ top?: number;
13
+ right?: number;
14
+ bottom?: number;
15
+ left?: number;
16
+ };
17
+ paddingTop?: number;
18
+ paddingRight?: number;
19
+ paddingBottom?: number;
20
+ paddingLeft?: number;
21
+ }
22
+
23
+ export declare interface CenterLabelOptions {
24
+ enabled?: boolean;
25
+ position?: "header" | "footer";
26
+ text: string;
27
+ scope?: "all" | "first-only" | "except-first" | number[];
28
+ y?: number;
29
+ offsetX?: number;
30
+ style?: TextStyle;
31
+ }
32
+
33
+ declare type FontStyle = "normal" | "bold" | "italic" | "bolditalic";
34
+
35
+ export declare interface PageNumberOptions {
36
+ enabled?: boolean;
37
+ position?: "header" | "footer";
38
+ align?: "left" | "right" | "center";
39
+ preset?: PageNumberPreset;
40
+ template?: string;
41
+ y?: number;
42
+ offsetX?: number;
43
+ style?: TextStyle;
44
+ scope?: "all" | "first-only" | "except-first";
45
+ format?: "arabic" | "roman-upper" | "roman-lower";
46
+ }
47
+
48
+ export declare type PageNumberPreset = "page-slash-total" | "slash" | "page-of-total";
49
+
50
+ export declare const PdfBox: default_2.FC<PdfBoxProps>;
51
+
52
+ declare interface PdfBoxProps extends BoxStyle {
53
+ x?: number;
54
+ y?: number;
55
+ w?: number;
56
+ h?: number;
57
+ children?: default_2.ReactNode;
58
+ }
59
+
60
+ export declare const PdfDocument: default_2.FC<PdfDocumentProps>;
61
+
62
+ declare interface PdfDocumentProps {
63
+ options?: PDFOptions;
64
+ header?: (ctx: PdfRenderer, page: number, total: number) => void;
65
+ footer?: (ctx: PdfRenderer, page: number, total: number) => void;
66
+ pageNumbers?: PageNumberOptions;
67
+ centerLabel?: CenterLabelOptions;
68
+ metadata?: {
69
+ title?: string;
70
+ author?: string;
71
+ subject?: string;
72
+ keywords?: string[];
73
+ };
74
+ children: default_2.ReactNode;
75
+ onReady?: (ctx: PdfRenderer) => void;
76
+ filename?: string;
77
+ autoSave?: boolean;
78
+ }
79
+
80
+ export declare type PDFFormat = "a4" | "letter" | [number, number];
81
+
82
+ export declare const PdfImage: default_2.FC<PdfImageProps>;
83
+
84
+ declare interface PdfImageProps {
85
+ src: string;
86
+ x?: number;
87
+ y?: number;
88
+ w?: number;
89
+ h?: number;
90
+ mime?: "PNG" | "JPEG";
91
+ flow?: boolean;
92
+ align?: "left" | "center" | "right";
93
+ }
94
+
95
+ export declare const PdfList: default_2.FC<PdfListProps>;
96
+
97
+ declare interface PdfListProps {
98
+ items: string[];
99
+ ordered?: boolean;
100
+ style?: TextStyle;
101
+ indent?: number;
102
+ markerWidth?: number;
103
+ spacing?: number;
104
+ }
105
+
106
+ export declare interface PDFOptions {
107
+ format?: PDFFormat;
108
+ orientation?: "p" | "l";
109
+ unit?: "mm" | "pt";
110
+ margin?: {
111
+ top: number;
112
+ right: number;
113
+ bottom: number;
114
+ left: number;
115
+ };
116
+ font?: {
117
+ name?: string;
118
+ style?: "normal" | "bold" | "italic" | "bolditalic";
119
+ size?: number;
120
+ };
121
+ color?: string;
122
+ lineHeight?: number;
123
+ }
124
+
125
+ export declare const PdfPreview: default_2.FC<PdfPreviewProps>;
126
+
127
+ declare interface PdfPreviewProps extends Omit<PdfDocumentProps, "onReady" | "autoSave" | "filename"> {
128
+ width?: string | number;
129
+ height?: string | number;
130
+ className?: string;
131
+ style?: default_2.CSSProperties;
132
+ iframeClassName?: string;
133
+ iframeStyle?: default_2.CSSProperties;
134
+ }
135
+
136
+ export declare class PdfRenderer {
137
+ private pdf;
138
+ private pageWidth;
139
+ private pageHeight;
140
+ private options;
141
+ private cursorX;
142
+ private cursorY;
143
+ private contentWidth;
144
+ private margin;
145
+ private defaultFont;
146
+ private defaultColor;
147
+ private defaultLineHeight;
148
+ private headerDrawer?;
149
+ private footerDrawer?;
150
+ private pendingTasks;
151
+ private opQueue;
152
+ private generation;
153
+ constructor(opts?: PDFOptions);
154
+ get instance(): jsPDF;
155
+ get width(): number;
156
+ get height(): number;
157
+ get contentLeft(): number;
158
+ get contentRight(): number;
159
+ get contentTop(): number;
160
+ get contentBottom(): number;
161
+ get contentHeight(): number;
162
+ get contentAreaWidth(): number;
163
+ get baseFont(): {
164
+ name?: string;
165
+ style: FontStyle;
166
+ size: number;
167
+ };
168
+ get baseLineHeight(): number;
169
+ resetFlowCursor(): void;
170
+ reset(): void;
171
+ setHeaderFooter(header?: (pdf: jsPDF, pageNum: number, pageCount: number, renderer: PdfRenderer) => void, footer?: (pdf: jsPDF, pageNum: number, pageCount: number, renderer: PdfRenderer) => void): void;
172
+ private applyBaseFont;
173
+ addPage(): void;
174
+ private ensureSpace;
175
+ setTextStyle(style?: TextStyle): void;
176
+ textRaw(text: string, x: number, y: number, style?: TextStyle, maxWidth?: number, align?: TextStyle["align"]): void;
177
+ box(x: number, y: number, w: number, h: number, style?: BoxStyle): void;
178
+ line(x1: number, y1: number, x2: number, y2: number): void;
179
+ imageFromUrl(url: string, opts?: {
180
+ x?: number;
181
+ y?: number;
182
+ w?: number;
183
+ h?: number;
184
+ mime?: "PNG" | "JPEG";
185
+ align?: "left" | "center" | "right";
186
+ }): Promise<{
187
+ width: number;
188
+ height: number;
189
+ x: number | undefined;
190
+ y: number;
191
+ }>;
192
+ queueOperation(op: () => Promise<void> | void): void;
193
+ private registerTask;
194
+ waitForTasks(): Promise<void>;
195
+ private loadImageAsDataURL;
196
+ paragraph(text: string, style?: TextStyle, maxWidth?: number): number;
197
+ moveCursor(dx: number, dy: number): void;
198
+ setCursor(x: number, y: number): void;
199
+ getCursor(): {
200
+ x: number;
201
+ y: number;
202
+ };
203
+ getPageCount(): number;
204
+ applyHeaderFooter(): void;
205
+ measureText(text: string, style?: TextStyle, maxWidth?: number): {
206
+ width: number;
207
+ height: number;
208
+ };
209
+ setMetadata(metadata: {
210
+ title?: string;
211
+ author?: string;
212
+ subject?: string;
213
+ keywords?: string[];
214
+ }): void;
215
+ save(filename: string): void;
216
+ getBlobUrl(): URL;
217
+ }
218
+
219
+ export declare const PdfTable: default_2.FC<PdfTableProps>;
220
+
221
+ declare interface PdfTableProps {
222
+ data: any[];
223
+ columns: TableColumn[];
224
+ width?: number | string;
225
+ borderWidth?: number;
226
+ borderColor?: string;
227
+ cellPadding?: number | {
228
+ top?: number;
229
+ right?: number;
230
+ bottom?: number;
231
+ left?: number;
232
+ };
233
+ headerStyle?: TextStyle & BoxStyle;
234
+ rowStyle?: TextStyle & BoxStyle;
235
+ alternateRowStyle?: TextStyle & BoxStyle;
236
+ headerHeight?: number;
237
+ }
238
+
239
+ export declare const PdfText: default_2.FC<PdfTextProps>;
240
+
241
+ declare interface PdfTextProps extends TextStyle {
242
+ children: string;
243
+ x?: number;
244
+ y?: number;
245
+ maxWidth?: number;
246
+ spacingBelow?: number;
247
+ }
248
+
249
+ export declare const PdfView: default_2.FC<PdfViewProps>;
250
+
251
+ declare interface PdfViewProps {
252
+ style?: ViewStyle;
253
+ children?: default_2.ReactNode;
254
+ debug?: boolean;
255
+ }
256
+
257
+ declare interface TableColumn {
258
+ header?: string;
259
+ accessor?: string | ((row: any) => default_2.ReactNode);
260
+ width?: number | string;
261
+ align?: "left" | "center" | "right";
262
+ id?: string;
263
+ }
264
+
265
+ export declare interface TextStyle {
266
+ fontSize?: number;
267
+ fontStyle?: "normal" | "bold" | "italic" | "bolditalic";
268
+ color?: string;
269
+ align?: Align;
270
+ verticalAlign?: "top" | "middle" | "bottom";
271
+ lineHeight?: number;
272
+ }
273
+
274
+ export declare interface ViewStyle extends BoxStyle {
275
+ margin?: number | {
276
+ top?: number;
277
+ right?: number;
278
+ bottom?: number;
279
+ left?: number;
280
+ };
281
+ marginTop?: number;
282
+ marginRight?: number;
283
+ marginBottom?: number;
284
+ marginLeft?: number;
285
+ width?: number | string;
286
+ height?: number;
287
+ }
288
+
289
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-vector-pdf",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "private": false,
5
5
  "description": "Vector (text-selectable) PDF engine with React UI to configure page numbers, formats, scopes, and center labels. Powered by jsPDF.",
6
6
  "repository": {
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "homepage": "https://github.com/adithyavalsaraj/react-vector-pdf#readme",
14
14
  "type": "module",
15
- "main": "./dist/react-vector-pdf.umd.js",
16
- "module": "./dist/react-vector-pdf.es.js",
15
+ "main": "./dist/react-vector-pdf.js",
16
+ "module": "./dist/react-vector-pdf.js",
17
17
  "types": "./dist/index.d.ts",
18
18
  "files": [
19
19
  "dist"
@@ -21,15 +21,16 @@
21
21
  "exports": {
22
22
  ".": {
23
23
  "types": "./dist/index.d.ts",
24
- "import": "./dist/react-vector-pdf.es.js",
25
- "require": "./dist/react-vector-pdf.umd.js"
24
+ "import": "./dist/react-vector-pdf.js",
25
+ "require": "./dist/react-vector-pdf.js"
26
26
  }
27
27
  },
28
28
  "scripts": {
29
29
  "dev": "vite",
30
30
  "build": "vite build",
31
31
  "preview": "vite preview",
32
- "prepublishOnly": "npm run build"
32
+ "prepublishOnly": "npm run build",
33
+ "release": "release-it"
33
34
  },
34
35
  "keywords": [
35
36
  "pdf",
@@ -51,14 +52,16 @@
51
52
  "jspdf": "^3.0.4"
52
53
  },
53
54
  "devDependencies": {
55
+ "@release-it/conventional-changelog": "^10.0.4",
54
56
  "@types/node": "^25.0.3",
55
57
  "@types/react": "^19.2.7",
56
58
  "@types/react-dom": "^19.2.3",
57
59
  "@vitejs/plugin-react": "^5.1.2",
58
60
  "baseline-browser-mapping": "^2.9.11",
61
+ "release-it": "^19.1.0",
59
62
  "sass": "^1.97.1",
60
63
  "typescript": "^5.9.3",
61
64
  "vite": "^7.3.0",
62
65
  "vite-plugin-dts": "^4.5.4"
63
66
  }
64
- }
67
+ }
@@ -1,10 +0,0 @@
1
- import { default as React } from 'react';
2
- import { BoxStyle } from '../core/types';
3
- export interface PdfBoxProps extends BoxStyle {
4
- x?: number;
5
- y?: number;
6
- w?: number;
7
- h?: number;
8
- children?: React.ReactNode;
9
- }
10
- export declare const PdfBox: React.FC<PdfBoxProps>;
@@ -1,12 +0,0 @@
1
- import { default as React } from 'react';
2
- export interface PdfImageProps {
3
- src: string;
4
- x?: number;
5
- y?: number;
6
- w?: number;
7
- h?: number;
8
- mime?: "PNG" | "JPEG";
9
- flow?: boolean;
10
- align?: "left" | "center" | "right";
11
- }
12
- export declare const PdfImage: React.FC<PdfImageProps>;
@@ -1,11 +0,0 @@
1
- import { default as React } from 'react';
2
- import { TextStyle } from '../core/types';
3
- export interface PdfListProps {
4
- items: string[];
5
- ordered?: boolean;
6
- style?: TextStyle;
7
- indent?: number;
8
- markerWidth?: number;
9
- spacing?: number;
10
- }
11
- export declare const PdfList: React.FC<PdfListProps>;
@@ -1,11 +0,0 @@
1
- import { default as React } from 'react';
2
- import { PdfDocumentProps } from './PdfProvider';
3
- export interface PdfPreviewProps extends Omit<PdfDocumentProps, "onReady" | "autoSave" | "filename"> {
4
- width?: string | number;
5
- height?: string | number;
6
- className?: string;
7
- style?: React.CSSProperties;
8
- iframeClassName?: string;
9
- iframeStyle?: React.CSSProperties;
10
- }
11
- export declare const PdfPreview: React.FC<PdfPreviewProps>;
@@ -1,22 +0,0 @@
1
- import { default as React } from 'react';
2
- import { PdfRenderer } from '../core/PdfRenderer';
3
- import { CenterLabelOptions, PDFOptions, PageNumberOptions } from '../core/types';
4
- export declare const usePdf: () => PdfRenderer;
5
- export interface PdfDocumentProps {
6
- options?: PDFOptions;
7
- header?: (ctx: PdfRenderer, page: number, total: number) => void;
8
- footer?: (ctx: PdfRenderer, page: number, total: number) => void;
9
- pageNumbers?: PageNumberOptions;
10
- centerLabel?: CenterLabelOptions;
11
- metadata?: {
12
- title?: string;
13
- author?: string;
14
- subject?: string;
15
- keywords?: string[];
16
- };
17
- children: React.ReactNode;
18
- onReady?: (ctx: PdfRenderer) => void;
19
- filename?: string;
20
- autoSave?: boolean;
21
- }
22
- export declare const PdfDocument: React.FC<PdfDocumentProps>;
@@ -1,33 +0,0 @@
1
- import { default as React } from 'react';
2
- import { BoxStyle, TextStyle } from '../core/types';
3
- export interface TableColumn {
4
- header?: string;
5
- accessor?: string | ((row: any) => React.ReactNode);
6
- width?: number | string;
7
- align?: "left" | "center" | "right";
8
- id?: string;
9
- }
10
- export interface TableCell {
11
- content?: string | number;
12
- colSpan?: number;
13
- rowSpan?: number;
14
- style?: TextStyle & BoxStyle;
15
- }
16
- export interface PdfTableProps {
17
- data: any[];
18
- columns: TableColumn[];
19
- width?: number | string;
20
- borderWidth?: number;
21
- borderColor?: string;
22
- cellPadding?: number | {
23
- top?: number;
24
- right?: number;
25
- bottom?: number;
26
- left?: number;
27
- };
28
- headerStyle?: TextStyle & BoxStyle;
29
- rowStyle?: TextStyle & BoxStyle;
30
- alternateRowStyle?: TextStyle & BoxStyle;
31
- headerHeight?: number;
32
- }
33
- export declare const PdfTable: React.FC<PdfTableProps>;
@@ -1,10 +0,0 @@
1
- import { default as React } from 'react';
2
- import { TextStyle } from '../core/types';
3
- export interface PdfTextProps extends TextStyle {
4
- children: string;
5
- x?: number;
6
- y?: number;
7
- maxWidth?: number;
8
- spacingBelow?: number;
9
- }
10
- export declare const PdfText: React.FC<PdfTextProps>;
@@ -1,8 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ViewStyle } from '../core/types';
3
- export interface PdfViewProps {
4
- style?: ViewStyle;
5
- children?: React.ReactNode;
6
- debug?: boolean;
7
- }
8
- export declare const PdfView: React.FC<PdfViewProps>;
@@ -1,8 +0,0 @@
1
- export { PdfBox } from './PdfBox';
2
- export { PdfImage } from './PdfImage';
3
- export { PdfList } from './PdfList';
4
- export { PdfPreview } from './PdfPreview';
5
- export { PdfDocument } from './PdfProvider';
6
- export { PdfTable } from './PdfTable';
7
- export { PdfText } from './PdfText';
8
- export { PdfView } from './PdfView';
@@ -1,86 +0,0 @@
1
- import { jsPDF } from 'jspdf';
2
- import { BoxStyle, PDFOptions, TextStyle } from './types';
3
- type FontStyle = "normal" | "bold" | "italic" | "bolditalic";
4
- export declare class PdfRenderer {
5
- private pdf;
6
- private pageWidth;
7
- private pageHeight;
8
- private options;
9
- private cursorX;
10
- private cursorY;
11
- private contentWidth;
12
- private margin;
13
- private defaultFont;
14
- private defaultColor;
15
- private defaultLineHeight;
16
- private headerDrawer?;
17
- private footerDrawer?;
18
- private pendingTasks;
19
- private opQueue;
20
- private generation;
21
- constructor(opts?: PDFOptions);
22
- get instance(): jsPDF;
23
- get width(): number;
24
- get height(): number;
25
- get contentLeft(): number;
26
- get contentRight(): number;
27
- get contentTop(): number;
28
- get contentBottom(): number;
29
- get contentHeight(): number;
30
- get contentAreaWidth(): number;
31
- get baseFont(): {
32
- name?: string;
33
- style: FontStyle;
34
- size: number;
35
- };
36
- get baseLineHeight(): number;
37
- resetFlowCursor(): void;
38
- reset(): void;
39
- setHeaderFooter(header?: (pdf: jsPDF, pageNum: number, pageCount: number, renderer: PdfRenderer) => void, footer?: (pdf: jsPDF, pageNum: number, pageCount: number, renderer: PdfRenderer) => void): void;
40
- private applyBaseFont;
41
- addPage(): void;
42
- private ensureSpace;
43
- setTextStyle(style?: TextStyle): void;
44
- textRaw(text: string, x: number, y: number, style?: TextStyle, maxWidth?: number, align?: TextStyle["align"]): void;
45
- box(x: number, y: number, w: number, h: number, style?: BoxStyle): void;
46
- line(x1: number, y1: number, x2: number, y2: number): void;
47
- imageFromUrl(url: string, opts?: {
48
- x?: number;
49
- y?: number;
50
- w?: number;
51
- h?: number;
52
- mime?: "PNG" | "JPEG";
53
- align?: "left" | "center" | "right";
54
- }): Promise<{
55
- width: number;
56
- height: number;
57
- x: number | undefined;
58
- y: number;
59
- }>;
60
- queueOperation(op: () => Promise<void> | void): void;
61
- private registerTask;
62
- waitForTasks(): Promise<void>;
63
- private loadImageAsDataURL;
64
- paragraph(text: string, style?: TextStyle, maxWidth?: number): number;
65
- moveCursor(dx: number, dy: number): void;
66
- setCursor(x: number, y: number): void;
67
- getCursor(): {
68
- x: number;
69
- y: number;
70
- };
71
- getPageCount(): number;
72
- applyHeaderFooter(): void;
73
- measureText(text: string, style?: TextStyle, maxWidth?: number): {
74
- width: number;
75
- height: number;
76
- };
77
- setMetadata(metadata: {
78
- title?: string;
79
- author?: string;
80
- subject?: string;
81
- keywords?: string[];
82
- }): void;
83
- save(filename: string): void;
84
- getBlobUrl(): URL;
85
- }
86
- export {};
@@ -1,80 +0,0 @@
1
- export type PDFFormat = "a4" | "letter" | [number, number];
2
- export type Align = "left" | "center" | "right" | "justify";
3
- export interface PDFOptions {
4
- format?: PDFFormat;
5
- orientation?: "p" | "l";
6
- unit?: "mm" | "pt";
7
- margin?: {
8
- top: number;
9
- right: number;
10
- bottom: number;
11
- left: number;
12
- };
13
- font?: {
14
- name?: string;
15
- style?: "normal" | "bold" | "italic" | "bolditalic";
16
- size?: number;
17
- };
18
- color?: string;
19
- lineHeight?: number;
20
- }
21
- export interface TextStyle {
22
- fontSize?: number;
23
- fontStyle?: "normal" | "bold" | "italic" | "bolditalic";
24
- color?: string;
25
- align?: Align;
26
- verticalAlign?: "top" | "middle" | "bottom";
27
- lineHeight?: number;
28
- }
29
- export interface BoxStyle {
30
- borderColor?: string;
31
- borderWidth?: number;
32
- fillColor?: string;
33
- radius?: number;
34
- padding?: number | {
35
- top?: number;
36
- right?: number;
37
- bottom?: number;
38
- left?: number;
39
- };
40
- paddingTop?: number;
41
- paddingRight?: number;
42
- paddingBottom?: number;
43
- paddingLeft?: number;
44
- }
45
- export interface ViewStyle extends BoxStyle {
46
- margin?: number | {
47
- top?: number;
48
- right?: number;
49
- bottom?: number;
50
- left?: number;
51
- };
52
- marginTop?: number;
53
- marginRight?: number;
54
- marginBottom?: number;
55
- marginLeft?: number;
56
- width?: number | string;
57
- height?: number;
58
- }
59
- export type PageNumberPreset = "page-slash-total" | "slash" | "page-of-total";
60
- export interface PageNumberOptions {
61
- enabled?: boolean;
62
- position?: "header" | "footer";
63
- align?: "left" | "right" | "center";
64
- preset?: PageNumberPreset;
65
- template?: string;
66
- y?: number;
67
- offsetX?: number;
68
- style?: TextStyle;
69
- scope?: "all" | "first-only" | "except-first";
70
- format?: "arabic" | "roman-upper" | "roman-lower";
71
- }
72
- export interface CenterLabelOptions {
73
- enabled?: boolean;
74
- position?: "header" | "footer";
75
- text: string;
76
- scope?: "all" | "first-only" | "except-first" | number[];
77
- y?: number;
78
- offsetX?: number;
79
- style?: TextStyle;
80
- }
@@ -1,14 +0,0 @@
1
- export declare const mm: (v: number) => number;
2
- export declare function resolvePadding(p?: number | {
3
- top?: number;
4
- right?: number;
5
- bottom?: number;
6
- left?: number;
7
- }): {
8
- top: number;
9
- right: number;
10
- bottom: number;
11
- left: number;
12
- };
13
- export declare function hexToRgb(hex: string): [number, number, number] | null;
14
- export declare function toRoman(n: number, uppercase?: boolean): string;
@@ -1,6 +0,0 @@
1
- import { default as React } from 'react';
2
- interface CodeBlockProps {
3
- code: string;
4
- }
5
- export declare const CodeBlock: React.FC<CodeBlockProps>;
6
- export {};
@@ -1,2 +0,0 @@
1
- import { default as React } from 'react';
2
- export declare const DemoApp: React.FC;
@@ -1,36 +0,0 @@
1
- import { default as React } from 'react';
2
- export interface DemoPdfContentProps {
3
- tableHeaderColor: string;
4
- tableStriped: boolean;
5
- tableBorderWidth: string;
6
- }
7
- export declare const DemoPdfContent: React.FC<DemoPdfContentProps>;
8
- export interface DemoPdfProps {
9
- pnEnabled: boolean;
10
- pnPos: "header" | "footer";
11
- pnAlign: "left" | "center" | "right";
12
- pnPreset: "page-slash-total" | "slash" | "page-of-total";
13
- pnTemplate: string;
14
- pnFormat: "arabic" | "roman-upper" | "roman-lower";
15
- pnScope: "all" | "first-only" | "except-first" | "custom";
16
- pnCustomPages: string;
17
- pnY: string;
18
- pnOffsetX: string;
19
- pnFontSize: string;
20
- pnColor: string;
21
- clEnabled: boolean;
22
- clPos: "header" | "footer";
23
- clText: string;
24
- clScope: "all" | "first-only" | "except-first" | "custom";
25
- clCustomPages: string;
26
- clY: string;
27
- clOffsetX: string;
28
- clFontSize: string;
29
- clColor: string;
30
- tableStriped: boolean;
31
- tableBorderWidth: string;
32
- tableHeaderColor: string;
33
- onReady: (pdf: any) => void;
34
- filename: string;
35
- }
36
- export declare const DemoPdfDocument: React.FC<DemoPdfProps>;
package/dist/main.d.ts DELETED
File without changes
@@ -1,6 +0,0 @@
1
- (function(A,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("jspdf")):typeof define=="function"&&define.amd?define(["exports","react","jspdf"],T):(A=typeof globalThis<"u"?globalThis:A||self,T(A.ReactVectorPdf={},A.React,A.jsPDF))})(this,(function(A,T,et){"use strict";var Q={exports:{}},V={};var rt;function ct(){if(rt)return V;rt=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,o,s){var a=null;if(s!==void 0&&(a=""+s),o.key!==void 0&&(a=""+o.key),"key"in o){s={};for(var c in o)c!=="key"&&(s[c]=o[c])}else s=o;return o=s.ref,{$$typeof:i,type:n,key:a,ref:o!==void 0?o:null,props:s}}return V.Fragment=t,V.jsx=r,V.jsxs=r,V}var G={};var ot;function lt(){return ot||(ot=1,process.env.NODE_ENV!=="production"&&(function(){function i(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===R?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case B:return"Profiler";case O:return"StrictMode";case K:return"Suspense";case b:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case S:return"Portal";case $:return e.displayName||"Context";case q:return(e._context.displayName||"Context")+".Consumer";case N:var l=e.render;return e=e.displayName,e||(e=l.displayName||l.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case P:return l=e.displayName||null,l!==null?l:i(e.type)||"Memo";case y:l=e._payload,e=e._init;try{return i(e(l))}catch{}}return null}function t(e){return""+e}function r(e){try{t(e);var l=!1}catch{l=!0}if(l){l=console;var g=l.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return g.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),t(e)}}function n(e){if(e===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var l=i(e);return l?"<"+l+">":"<...>"}catch{return"<...>"}}function o(){var e=p.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function a(e){if(z.call(e,"key")){var l=Object.getOwnPropertyDescriptor(e,"key").get;if(l&&l.isReactWarning)return!1}return e.key!==void 0}function c(e,l){function g(){C||(C=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}g.isReactWarning=!0,Object.defineProperty(e,"key",{get:g,configurable:!0})}function u(){var e=i(this.type);return w[e]||(w[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function m(e,l,g,E,M,_){var k=g.ref;return e={$$typeof:Y,type:e,key:l,props:g,_owner:E},(k!==void 0?k:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:u}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,l,g,E,M,_){var k=l.children;if(k!==void 0)if(E)if(D(k)){for(E=0;E<k.length;E++)x(k[E]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(k);if(z.call(l,"key")){k=i(e);var X=Object.keys(l).filter(function(Tt){return Tt!=="key"});E=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",j[k+E]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,E,k,X,k),j[k+E]=!0)}if(k=null,g!==void 0&&(r(g),k=""+g),a(l)&&(r(l.key),k=""+l.key),"key"in l){g={};for(var tt in l)tt!=="key"&&(g[tt]=l[tt])}else g=l;return k&&c(g,typeof e=="function"?e.displayName||e.name||"Unknown":e),m(e,k,g,o(),M,_)}function x(e){d(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?d(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function d(e){return typeof e=="object"&&e!==null&&e.$$typeof===Y}var H=T,Y=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),$=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),p=H.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,D=Array.isArray,L=console.createTask?console.createTask:function(){return null};H={react_stack_bottom_frame:function(e){return e()}};var C,w={},F=H.react_stack_bottom_frame.bind(H,s)(),v=L(n(s)),j={};G.Fragment=h,G.jsx=function(e,l,g){var E=1e4>p.recentlyCreatedOwnerStacks++;return f(e,l,g,!1,E?Error("react-stack-top-frame"):F,E?L(n(e)):v)},G.jsxs=function(e,l,g){var E=1e4>p.recentlyCreatedOwnerStacks++;return f(e,l,g,!0,E?Error("react-stack-top-frame"):F,E?L(n(e)):v)}})()),G}var nt;function ut(){return nt||(nt=1,process.env.NODE_ENV==="production"?Q.exports=ct():Q.exports=lt()),Q.exports}var I=ut();function Z(i){return!i&&i!==0?{top:0,right:0,bottom:0,left:0}:typeof i=="number"?{top:i,right:i,bottom:i,left:i}:{top:i.top??0,right:i.right??0,bottom:i.bottom??0,left:i.left??0}}function J(i){const t=i.replace("#","");if(t.length===3){const r=parseInt(t[0]+t[0],16),n=parseInt(t[1]+t[1],16),o=parseInt(t[2]+t[2],16);return[r,n,o]}if(t.length===6){const r=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return[r,n,o]}return null}function it(i,t=!0){if(i<=0)return String(i);const r=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let n=i,o="";for(const[s,a]of r)for(;n>=s;)o+=a,n-=s;return t?o:o.toLowerCase()}class st{constructor(t={}){this.cursorX=0,this.cursorY=0,this.contentWidth=0,this.margin={top:15,right:15,bottom:15,left:15},this.defaultFont={name:void 0,style:"normal",size:12},this.defaultColor="#111827",this.defaultLineHeight=1.25,this.pendingTasks=new Set,this.opQueue=Promise.resolve(),this.generation=0,this.options=t,this.margin=t.margin??this.margin,this.defaultFont={name:t.font?.name,style:t.font?.style??"normal",size:t.font?.size??12},this.defaultColor=t.color??this.defaultColor,this.defaultLineHeight=t.lineHeight??this.defaultLineHeight,this.pdf=new et.jsPDF({unit:t.unit??"mm",format:t.format??"a4",orientation:t.orientation??"p"}),this.pageWidth=this.pdf.internal.pageSize.getWidth(),this.pageHeight=this.pdf.internal.pageSize.getHeight(),this.resetFlowCursor(),this.applyBaseFont()}get instance(){return this.pdf}get width(){return this.pageWidth}get height(){return this.pageHeight}get contentLeft(){return this.margin.left}get contentRight(){return this.pageWidth-this.margin.right}get contentTop(){return this.margin.top}get contentBottom(){return this.pageHeight-this.margin.bottom}get contentHeight(){return this.contentBottom-this.contentTop}get contentAreaWidth(){return this.contentWidth}get baseFont(){return this.defaultFont}get baseLineHeight(){return this.defaultLineHeight}resetFlowCursor(){this.cursorX=this.margin.left,this.cursorY=this.margin.top,this.contentWidth=this.pageWidth-this.margin.left-this.margin.right}reset(){if(this.pdf=new et.jsPDF({unit:this.options.unit??"mm",format:this.options.format??"a4",orientation:this.options.orientation??"p"}),this.generation++,this.cursorX=0,this.cursorY=0,this.pendingTasks=new Set,this.opQueue=Promise.resolve(),this.resetFlowCursor(),this.applyBaseFont(),this.options.color){const t=J(this.options.color);t&&this.pdf.setTextColor(...t)}}setHeaderFooter(t,r){this.headerDrawer=t,this.footerDrawer=r}applyBaseFont(){const t=this.defaultFont.name??this.pdf.getFont().fontName;this.pdf.setFont(t,this.defaultFont.style),this.pdf.setFontSize(this.defaultFont.size);const r=J(this.defaultColor);r&&this.pdf.setTextColor(...r)}addPage(){this.pdf.addPage(),this.resetFlowCursor()}ensureSpace(t){this.cursorY+t>this.contentBottom&&this.addPage()}setTextStyle(t){if(t){if(t.fontSize&&this.pdf.setFontSize(t.fontSize),t.fontStyle){const r=this.pdf.getFont().fontName;this.pdf.setFont(r,t.fontStyle)}if(t.color){const r=J(t.color);r&&this.pdf.setTextColor(...r)}}}textRaw(t,r,n,o,s,a="left"){this.setTextStyle(o);const c={align:a};typeof s=="number"&&(c.maxWidth=s),this.pdf.text(t,r,n,c),this.applyBaseFont()}box(t,r,n,o,s){const a=s??{};if(a.fillColor){const c=J(a.fillColor);c&&this.pdf.setFillColor(...c),this.pdf.rect(t,r,n,o,"F")}if(a.borderWidth||a.borderColor){if(a.borderWidth&&this.pdf.setLineWidth(a.borderWidth),a.borderColor){const c=J(a.borderColor);c&&this.pdf.setDrawColor(...c)}this.pdf.rect(t,r,n,o),this.pdf.setLineWidth(.2),this.pdf.setDrawColor(0,0,0)}}line(t,r,n,o){this.pdf.line(t,r,n,o)}async imageFromUrl(t,r={}){const n=(async()=>{try{const{dataUrl:o,width:s,height:a}=await this.loadImageAsDataURL(t),c=.264583,u=s*c,m=a*c;let f=r.w,x=r.h;f===void 0&&x===void 0?(f=u,x=m):f===void 0&&x!==void 0?f=x*(u/m):x===void 0&&f!==void 0&&(x=f*(m/u));const d=f??u,H=x??m;let Y=r.x,S=r.y??this.cursorY;if(r.y===void 0&&S+H>this.contentBottom&&(this.addPage(),S=this.cursorY),Y===void 0){const h=r.align??"left";h==="left"?Y=this.contentLeft:h==="center"?Y=(this.contentLeft+this.contentRight)/2-d/2:h==="right"&&(Y=this.contentRight-d)}return this.pdf.addImage(o,r.mime??"PNG",Y,S,d,H),{width:d,height:H,x:Y,y:S}}catch(o){return console.error("Failed to load image",t,o),{width:0,height:0,x:0,y:0}}})();return this.registerTask(n),n}queueOperation(t){const r=this.generation,n=this.opQueue.then(async()=>{if(this.generation===r)try{await t()}catch(o){console.error("Operation failed",o)}});this.opQueue=n,this.registerTask(n)}registerTask(t){this.pendingTasks.add(t),t.finally(()=>{this.pendingTasks.delete(t)})}async waitForTasks(){await Promise.all(this.pendingTasks),await this.opQueue}loadImageAsDataURL(t){return new Promise((r,n)=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{const s=document.createElement("canvas");s.width=o.width,s.height=o.height;const a=s.getContext("2d");if(!a)return n(new Error("Canvas 2D context not available"));a.drawImage(o,0,0),r({dataUrl:s.toDataURL("image/png"),width:o.width,height:o.height})},o.onerror=s=>n(s),o.src=t})}paragraph(t,r,n){const o=n??this.contentWidth;this.setTextStyle(r);const s=r?.lineHeight??this.defaultLineHeight,a=r?.fontSize??this.defaultFont.size,c=a*s*.3528,u=this.pdf.splitTextToSize(t,o),m=r?.align??"left";let f=0;return u.forEach(x=>{this.cursorY+c>this.contentBottom&&this.addPage();const d=this.cursorY+a*.3528;this.pdf.text(x,this.cursorX,d,{align:m,maxWidth:o}),this.cursorY+=c,f+=c}),this.cursorY+=1,this.applyBaseFont(),f}moveCursor(t,r){this.cursorX+=t,this.cursorY+=r}setCursor(t,r){this.cursorX=t,this.cursorY=r}getCursor(){return{x:this.cursorX,y:this.cursorY}}getPageCount(){return this.pdf.getNumberOfPages()}applyHeaderFooter(){const t=this.getPageCount();if(!(!this.headerDrawer&&!this.footerDrawer)){for(let r=1;r<=t;r++)this.pdf.setPage(r),this.headerDrawer&&this.headerDrawer(this.pdf,r,t,this),this.footerDrawer&&this.footerDrawer(this.pdf,r,t,this);this.pdf.setPage(t)}}measureText(t,r,n){this.setTextStyle(r);const o=r?.fontSize??this.defaultFont.size,s=r?.lineHeight??this.defaultLineHeight,a=o*s*.3528;if(n){const c=this.pdf.splitTextToSize(t,n);return{width:n,height:c.length*a}}else{const c=this.pdf.getTextDimensions(t);return{width:c.w,height:c.h}}}setMetadata(t){t.title&&this.pdf.setDocumentProperties({title:t.title}),t.author&&this.pdf.setDocumentProperties({author:t.author}),t.subject&&this.pdf.setDocumentProperties({subject:t.subject}),t.keywords&&this.pdf.setDocumentProperties({keywords:t.keywords.join(", ")})}save(t){this.applyHeaderFooter(),this.pdf.save(t)}getBlobUrl(){return this.applyHeaderFooter(),this.pdf.output("bloburl")}}const at=T.createContext(null),U=()=>{const i=T.useContext(at);if(!i)throw new Error("usePdf must be used within <PdfDocument>");return i},ft=({options:i,header:t,footer:r,pageNumbers:n,centerLabel:o,metadata:s,children:a,onReady:c,filename:u,autoSave:m=!1})=>{const f=T.useMemo(()=>new st(i),[i]);return T.useEffect(()=>{s&&f.setMetadata(s)},[f,s]),T.useEffect(()=>{const x=(S,h)=>!h||h==="all"?!0:h==="first-only"?S===1:h==="except-first"?S>1:Array.isArray(h)?h.includes(S):!0,d=(S,h)=>h==="roman-upper"?it(S,!0):h==="roman-lower"?it(S,!1):String(S),H=(S,h,O)=>{if(!n?.enabled||!x(h,n.scope))return;const B=n.preset??"page-slash-total",$=(n.template??(B==="page-slash-total"?"Page {page}/{total}":B==="page-of-total"?"Page {page} of {total}":"{page}/{total}")).replace("{page}",d(h,n.format)).replace("{total}",d(O,n.format)),N=n.align??"right",K=N==="left"?f.contentLeft+(n.offsetX??0):N==="right"?f.contentRight-(n.offsetX??0):(f.contentLeft+f.contentRight)/2+(n.offsetX??0),b=S==="header"?10:f.height-7,P=typeof n.y=="number"?n.y:b;f.textRaw($,K,P,n.style,void 0,N)},Y=(S,h,O)=>{if(!o?.enabled||!x(h,o.scope))return;const B="center",q=(f.contentLeft+f.contentRight)/2+(o.offsetX??0),$=S==="header"?10:f.height-7,N=typeof o.y=="number"?o.y:$;f.textRaw(o.text,q,N,o.style,void 0,B)};return f.setHeaderFooter((S,h,O)=>{t&&t(f,h,O),n?.position==="header"&&H("header",h,O),o?.position==="header"&&Y("header",h)},(S,h,O)=>{n?.position==="footer"&&H("footer",h,O),r&&r(f,h,O),o?.position==="footer"&&Y("footer",h)}),f.waitForTasks().then(()=>{c?.(f)}),()=>{f.reset()}},[f]),T.useEffect(()=>{m&&u&&f.save(u)},[m,u]),I.jsx(at.Provider,{value:f,children:a})},ht=({x:i,y:t,w:r,h:n,children:o,...s})=>{const a=U(),c=Z(s.padding),u={top:s.paddingTop??c.top,right:s.paddingRight??c.right,bottom:s.paddingBottom??c.bottom,left:s.paddingLeft??c.left},m=T.useRef({}).current;return typeof i=="number"&&typeof t=="number"&&typeof r=="number"&&typeof n=="number"?(T.useEffect(()=>{a.queueOperation(()=>{a.box(i,t,r,n,s)})},[a,i,t,r,n]),I.jsx(T.Fragment,{children:o})):(T.useEffect(()=>{a.queueOperation(()=>{const f=a.getCursor();m.start={...f};const x=f.x+u.left,d=f.y+u.top;a.setCursor(x,d)})},[a]),I.jsxs(T.Fragment,{children:[o,I.jsx(dt,{boxState:m,pad:u,style:s})]}))},dt=({boxState:i,style:t,pad:r})=>{const n=U();return T.useEffect(()=>{n.queueOperation(()=>{const o=i.start;if(!o)return;const s=n.getCursor(),c=Math.max(s.y-o.y-r.top,0)+r.top+r.bottom;n.box(o.x,o.y,n.contentAreaWidth,c,t),n.setCursor(o.x,o.y+c)})},[n]),null},gt=({src:i,x:t,y:r,w:n,h:o,mime:s="PNG",flow:a,align:c="left"})=>{const u=U();return T.useEffect(()=>{const m=a===!0||t===void 0&&r===void 0,f=t,x=r;u.queueOperation(async()=>{const d=await u.imageFromUrl(i,{x:f,y:x,w:n,h:o,mime:s,align:c});m&&d&&u.moveCursor(0,d.height+2)})},[u,i,t,r,n,o,s,a,c]),null},pt=({items:i,ordered:t=!1,style:r,indent:n=5,markerWidth:o=5,spacing:s=2})=>{const a=U();return T.useEffect(()=>{a.queueOperation(()=>{i.forEach((c,u)=>{const m=t?`${u+1}.`:"•",f=a.getCursor().y,x=a.getCursor().x,d=x+n+o,H=r?.fontSize??a.baseFont.size,Y=f+H*.3528;a.textRaw(m,x+n,Y,r,o,"right"),a.setCursor(d,f);const S=a.contentRight-d;a.paragraph(c,r,S);const h=a.getCursor().y;a.setCursor(x,h+s)})})},[a,i,t,r,n,o,s]),null},mt=({width:i="100%",height:t="500px",className:r,style:n,iframeClassName:o,iframeStyle:s,...a})=>{const[c,u]=T.useState(null),m=f=>{const x=f.getBlobUrl();u(x.toString())};return I.jsxs("div",{className:r,style:{width:i,height:t,...n},children:[I.jsx("div",{style:{display:"none"},children:I.jsx(ft,{...a,onReady:m,autoSave:!1,children:a.children})}),c?I.jsx("iframe",{src:c,width:"100%",height:"100%",className:o,style:{border:"none",...s},title:"PDF Preview"}):I.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f3f4f6",color:"#6b7280"},children:"Generating Preview..."})]})},bt=({data:i,columns:t,width:r="100%",borderWidth:n=.1,borderColor:o="#000000",cellPadding:s=2,headerStyle:a,rowStyle:c,alternateRowStyle:u,headerHeight:m})=>{const f=U();return T.useEffect(()=>{f.queueOperation(()=>{const x=typeof r=="number"?r:parseFloat(r)/100*f.contentAreaWidth,d=t.map(b=>typeof b.width=="number"?b.width:typeof b.width=="string"&&b.width.endsWith("%")?parseFloat(b.width)/100*x:0),H=d.reduce((b,P)=>b+P,0),Y=Math.max(0,x-H),S=d.filter(b=>b===0).length;if(S>0){const b=Y/S;for(let P=0;P<d.length;P++)d[P]===0&&(d[P]=b)}const h=(b,P,y,W,R,p,z="left",D=!0)=>{D&&f.box(P,y,W,R,{borderColor:p.borderColor??o,borderWidth:p.borderWidth??n,fillColor:p.fillColor});const L=Z(p.padding??s),C={top:p.paddingTop??L.top,right:p.paddingRight??L.right,bottom:p.paddingBottom??L.bottom,left:p.paddingLeft??L.left},w=W-C.left-C.right,F=f.instance.splitTextToSize(b,w,p),v=(p.fontSize??f.baseFont.size)*(p.lineHeight??f.baseLineHeight)*.3528,j=(p.fontSize??f.baseFont.size)*.3528,e=F.length*v,l=R-C.top-C.bottom;let g=0;p.verticalAlign==="middle"?g=Math.max(0,(l-e)/2):p.verticalAlign==="bottom"&&(g=Math.max(0,l-e));let E=y+C.top+g+j;const M=p.align??z,_=f.getCursor();F.forEach(k=>{let X=P+C.left;M==="center"?X=P+W/2:M==="right"&&(X=P+W-C.right),f.textRaw(k,X,E,p,void 0,M),E+=v}),f.setCursor(_.x,_.y)};let O=f.getCursor().y;const B=f.getCursor().x,q=m??10;O+q>f.contentBottom&&(f.addPage(),O=f.getCursor().y);let $=B;t.forEach((b,P)=>{const y=d[P];h(b.header??"",$,O,y,q,a??{fontStyle:"bold"},b.align??"left"),$+=y}),O+=q,f.setCursor(B,O);const N=(b,P,y)=>{const W=Z(s),R={top:y.paddingTop??W.top,right:y.paddingRight??W.right,bottom:y.paddingBottom??W.bottom,left:y.paddingLeft??W.left},p=P-R.left-R.right;return f.measureText(b,y,p).height+R.top+R.bottom};new Array(t.length).fill(0),(()=>{const b=new Array(i.length).fill(0);for(let R=0;R<i.length;R++){const p=i[R];let z=0;for(let D=0;D<t.length;D++){const L=t[D],C=typeof L.accessor=="function"?L.accessor(p):p[L.accessor];let w="",F=c,v=1,j=1;if(C&&typeof C=="object"&&C.content!==void 0?(w=String(C.content),C.style&&(F=C.style),C.colSpan&&(v=C.colSpan),C.rowSpan&&(j=C.rowSpan)):w=String(C??""),j>1){D+=v-1;continue}let e=d[D];for(let g=1;g<v;g++)D+g<d.length&&(e+=d[D+g]);const l=N(w,e,F??{});l>z&&(z=l),D+=v-1}z<8&&(z=8),b[R]=z}let P=O;const y=new Array(t.length).fill(0),W=f.getCursor().x;for(let R=0;R<i.length;R++){const p=i[R],z=b[R];let D=z;for(let w=0;w<t.length;w++){const F=t[w],v=typeof F.accessor=="function"?F.accessor(p):p[F.accessor];let j=1;if(v&&typeof v=="object"&&v.rowSpan&&(j=v.rowSpan),j>1){let e=0;for(let l=0;l<j;l++)R+l<b.length&&(e+=b[R+l]);e>D&&(D=e)}}const L=Math.abs(P-(f.contentTop+(m??10)))<1;if(P+D>f.contentBottom&&!L&&(f.addPage(),P=f.getCursor().y,m!==0)){let w=W;t.forEach((F,v)=>{const j=d[v];h(F.header??"",w,P,j,m??10,a??{fontStyle:"bold"},F.align??"left"),w+=j}),P+=m??10}let C=W;for(let w=0;w<t.length;w++){if(y[w]>0){y[w]--,C+=d[w];continue}const F=t[w],v=typeof F.accessor=="function"?F.accessor(p):p[F.accessor];let j=1,e=1,l=R%2===1&&u?u:c,g="";v&&typeof v=="object"&&v.content!==void 0?(g=String(v.content),v.colSpan&&(j=v.colSpan),v.rowSpan&&(e=v.rowSpan),v.style&&(l={...l,...v.style})):g=String(v??"");let E=d[w];for(let _=1;_<j;_++)w+_<d.length&&(E+=d[w+_]);let M=z;if(e>1)for(let _=1;_<e;_++)R+_<b.length&&(M+=b[R+_]);if(h(g,C,P,E,M,l??{},F.align??"left",!0),e>1){y[w]=e-1;for(let _=1;_<j;_++)w+_<y.length&&(y[w+_]=e-1)}C+=E,w+=j-1}P+=z}f.setCursor(W,P)})()})},[f,i,t,r]),null},wt=({children:i,x:t,y:r,maxWidth:n,spacingBelow:o=2,...s})=>{const a=U();return T.useEffect(()=>{a.queueOperation(()=>{if(typeof t=="number"&&typeof r=="number")a.textRaw(i,t,r,s,n,s.align);else{a.paragraph(i,s,n);const c=a.getCursor();a.setCursor(c.x,c.y+o)}})},[a,i,t,r,n,o,s.fontSize,s.align]),null};function vt(i){return typeof i=="number"?{top:i,right:i,bottom:i,left:i}:{top:i?.top??0,right:i?.right??0,bottom:i?.bottom??0,left:i?.left??0}}const xt=({style:i={},children:t})=>{const r=U(),n=Z(i.padding),o={top:i.paddingTop??n.top,right:i.paddingRight??n.right,bottom:i.paddingBottom??n.bottom,left:i.paddingLeft??n.left},s=vt(i.margin),a={top:i.marginTop??s.top,right:i.marginRight??s.right,bottom:i.marginBottom??s.bottom,left:i.marginLeft??s.left},c=T.useRef({}).current;return T.useEffect(()=>{r.queueOperation(()=>{a.top>0&&r.moveCursor(0,a.top);const u=r.getCursor();c.start={...u},r.setCursor(u.x+o.left,u.y+o.top)})},[r]),I.jsxs(T.Fragment,{children:[t,I.jsx(Pt,{viewState:c,style:i,pad:o,margin:a})]})},Pt=({viewState:i,style:t,pad:r,margin:n})=>{const o=U();return T.useEffect(()=>{o.queueOperation(()=>{const s=i.start;if(!s)return;const a=o.getCursor();let u=Math.max(a.y-s.y-r.top,0)+r.top+r.bottom;t.height&&(u=t.height);let m=o.contentAreaWidth;typeof t.width=="number"&&(m=t.width),(t.borderColor||t.fillColor||t.borderWidth)&&o.box(s.x,s.y,m,u,t);const f=s.y+u+n.bottom;o.setCursor(s.x,f)})},[o]),null};A.PdfBox=ht,A.PdfDocument=ft,A.PdfImage=gt,A.PdfList=pt,A.PdfPreview=mt,A.PdfRenderer=st,A.PdfTable=bt,A.PdfText=wt,A.PdfView=xt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));