@fauzi-dhuhuri/react-pdf-renderer 4.6.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.
@@ -0,0 +1,793 @@
1
+ /* eslint-disable max-classes-per-file */
2
+
3
+ import * as React from 'react';
4
+ import {
5
+ Style,
6
+ PageSize,
7
+ FontStore,
8
+ PDFVersion,
9
+ Orientation,
10
+ SourceObject,
11
+ SrcSet,
12
+ Sizes,
13
+ HyphenationCallback,
14
+ SVGPresentationAttributes,
15
+ Bookmark,
16
+ PageLayout,
17
+ PageMode,
18
+ HitSlop,
19
+ } from '@react-pdf/types';
20
+
21
+ declare class ReactPDF {
22
+ static default: typeof ReactPDF;
23
+ }
24
+
25
+ export = ReactPDF;
26
+
27
+ declare namespace ReactPDF {
28
+ interface Styles {
29
+ [key: string]: Style;
30
+ }
31
+ interface OnRenderProps {
32
+ blob?: Blob;
33
+ }
34
+
35
+ interface Permissions {
36
+ printing?: 'lowResolution' | 'highResolution';
37
+ modifying?: boolean;
38
+ copying?: boolean;
39
+ annotating?: boolean;
40
+ fillingForms?: boolean;
41
+ contentAccessibility?: boolean;
42
+ documentAssembly?: boolean;
43
+ }
44
+
45
+ interface DocumentProps {
46
+ style?: Style | Style[];
47
+ title?: string;
48
+ author?: string;
49
+ subject?: string;
50
+ creator?: string;
51
+ keywords?: string;
52
+ producer?: string;
53
+ language?: string;
54
+ creationDate?: Date;
55
+ modificationDate?: Date;
56
+ pdfVersion?: PDFVersion;
57
+ pageMode?: PageMode;
58
+ pageLayout?: PageLayout;
59
+ ownerPassword?: string;
60
+ userPassword?: string;
61
+ permissions?: Permissions;
62
+ onRender?: (props: OnRenderProps) => any;
63
+ }
64
+
65
+ /**
66
+ * This component represent the PDF document itself. It must be the root
67
+ * of your tree element structure, and under no circumstances should it be
68
+ * used as children of another react-pdf component. In addition, it should
69
+ * only have childs of type <Page />.
70
+ */
71
+ export class Document extends React.Component<
72
+ React.PropsWithChildren<DocumentProps>
73
+ > {}
74
+
75
+ interface NodeProps {
76
+ id?: string;
77
+ style?: Style | Style[];
78
+ /**
79
+ * Render component in all wrapped pages.
80
+ * @see https://react-pdf.org/advanced#fixed-components
81
+ */
82
+ fixed?: boolean;
83
+ /**
84
+ * Force the wrapping algorithm to start a new page when rendering the
85
+ * element.
86
+ * @see https://react-pdf.org/advanced#page-breaks
87
+ */
88
+ break?: boolean;
89
+ /**
90
+ * Hint that no page wrapping should occur between all sibling elements following the element within n points
91
+ * @see https://react-pdf.org/advanced#orphan-&-widow-protection
92
+ */
93
+ minPresenceAhead?: number;
94
+ }
95
+
96
+ interface PageProps extends NodeProps {
97
+ /**
98
+ * Enable page wrapping for this page.
99
+ * @see https://react-pdf.org/components#page-wrapping
100
+ */
101
+ wrap?: boolean;
102
+ /**
103
+ * Enables debug mode on page bounding box.
104
+ * @see https://react-pdf.org/advanced#debugging
105
+ */
106
+ debug?: boolean;
107
+ size?: PageSize;
108
+ orientation?: Orientation;
109
+ dpi?: number;
110
+ bookmark?: Bookmark;
111
+ }
112
+
113
+ /**
114
+ * Represents single page inside the PDF document, or a subset of them if
115
+ * using the wrapping feature. A <Document /> can contain as many pages as
116
+ * you want, but ensure not rendering a page inside any component besides
117
+ * Document.
118
+ */
119
+ export class Page extends React.Component<
120
+ React.PropsWithChildren<PageProps>
121
+ > {}
122
+
123
+ interface ViewProps extends NodeProps {
124
+ id?: string;
125
+ /**
126
+ * Enable/disable page wrapping for element.
127
+ * @see https://react-pdf.org/components#page-wrapping
128
+ */
129
+ wrap?: boolean;
130
+ /**
131
+ * Enables debug mode on page bounding box.
132
+ * @see https://react-pdf.org/advanced#debugging
133
+ */
134
+ debug?: boolean;
135
+ render?: (props: {
136
+ pageNumber: number;
137
+ subPageNumber: number;
138
+ }) => React.ReactNode;
139
+ }
140
+
141
+ /**
142
+ * The most fundamental component for building a UI and is designed to be
143
+ * nested inside other views and can have 0 to many children.
144
+ */
145
+ export class View extends React.Component<
146
+ React.PropsWithChildren<ViewProps>
147
+ > {}
148
+
149
+ interface BaseImageProps extends NodeProps {
150
+ /**
151
+ * Enables debug mode on page bounding box.
152
+ * @see https://react-pdf.org/advanced#debugging
153
+ */
154
+ debug?: boolean;
155
+ cache?: boolean;
156
+ /**
157
+ * A comma-separated list of image sources with width descriptors.
158
+ * Works like the HTML img srcSet attribute.
159
+ * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w"
160
+ */
161
+ srcSet?: SrcSet;
162
+ /**
163
+ * The intended display width of the image, used to select the best source
164
+ * from srcSet. Accepts a number (in points) or a string.
165
+ * Works like the HTML img sizes attribute.
166
+ * @example 300
167
+ * @example "300"
168
+ */
169
+ sizes?: Sizes;
170
+ }
171
+
172
+ interface ImageWithSrcProp extends BaseImageProps {
173
+ src: SourceObject;
174
+ }
175
+
176
+ interface ImageWithSourceProp extends BaseImageProps {
177
+ source: SourceObject;
178
+ }
179
+
180
+ type ImageProps = ImageWithSrcProp | ImageWithSourceProp;
181
+
182
+ /**
183
+ * A React component for displaying network or local (Node only) JPG or
184
+ * PNG images, as well as base64 encoded image strings.
185
+ */
186
+ export class Image extends React.Component<ImageProps> {}
187
+
188
+ interface BaseImageBackgroundProps extends NodeProps {
189
+ /**
190
+ * Enables debug mode on page bounding box.
191
+ * @see https://react-pdf.org/advanced#debugging
192
+ */
193
+ debug?: boolean;
194
+ cache?: boolean;
195
+ /**
196
+ * A comma-separated list of image sources with width descriptors.
197
+ * Works like the HTML img srcSet attribute.
198
+ * @example "small.jpg 300w, medium.jpg 600w, large.jpg 900w"
199
+ */
200
+ srcSet?: SrcSet;
201
+ /**
202
+ * The intended display width of the image, used to select the best source
203
+ * from srcSet. Accepts a number (in points) or a string.
204
+ * @example 300
205
+ */
206
+ sizes?: Sizes;
207
+ /**
208
+ * Style applied to the background image.
209
+ */
210
+ imageStyle?: Style;
211
+ }
212
+
213
+ interface ImageBackgroundWithSrcProp extends BaseImageBackgroundProps {
214
+ src: SourceObject;
215
+ }
216
+
217
+ interface ImageBackgroundWithSourceProp extends BaseImageBackgroundProps {
218
+ source: SourceObject;
219
+ }
220
+
221
+ type ImageBackgroundProps =
222
+ | ImageBackgroundWithSrcProp
223
+ | ImageBackgroundWithSourceProp;
224
+
225
+ /**
226
+ * A React component for displaying an image behind child content.
227
+ * Compatible with React Native's ImageBackground component.
228
+ * @see https://reactnative.dev/docs/imagebackground
229
+ */
230
+ export class ImageBackground extends React.Component<
231
+ React.PropsWithChildren<ImageBackgroundProps>
232
+ > {}
233
+
234
+ interface TextProps extends NodeProps {
235
+ id?: string;
236
+ /**
237
+ * Enable/disable page wrapping for element.
238
+ * @see https://react-pdf.org/components#page-wrapping
239
+ */
240
+ wrap?: boolean;
241
+ /**
242
+ * Enables debug mode on page bounding box.
243
+ * @see https://react-pdf.org/advanced#debugging
244
+ */
245
+ debug?: boolean;
246
+ render?: (props: {
247
+ pageNumber: number;
248
+ totalPages: number;
249
+ subPageNumber: number;
250
+ subPageTotalPages: number;
251
+ }) => React.ReactNode;
252
+ /**
253
+ * Override the default hyphenation-callback
254
+ * @see https://react-pdf.org/fonts#registerhyphenationcallback
255
+ */
256
+ hyphenationCallback?: HyphenationCallback;
257
+ /**
258
+ * Specifies the minimum number of lines in a text element that must be shown at the bottom of a page or its container.
259
+ * @see https://react-pdf.org/advanced#orphan-&-widow-protection
260
+ */
261
+ orphans?: number;
262
+ /**
263
+ * Specifies the minimum number of lines in a text element that must be shown at the top of a page or its container..
264
+ * @see https://react-pdf.org/advanced#orphan-&-widow-protection
265
+ */
266
+ widows?: number;
267
+ }
268
+
269
+ interface SVGTextProps extends SVGPresentationAttributes {
270
+ style?: SVGPresentationAttributes;
271
+ x: string | number;
272
+ y: string | number;
273
+ /**
274
+ * Override the default hyphenation-callback
275
+ * @see https://react-pdf.org/fonts#registerhyphenationcallback
276
+ */
277
+ hyphenationCallback?: HyphenationCallback;
278
+ }
279
+
280
+ /**
281
+ * A React component for displaying text. Text supports nesting of other
282
+ * Text or Link components to create inline styling.
283
+ */
284
+ export class Text extends React.Component<
285
+ React.PropsWithChildren<TextProps> | SVGTextProps
286
+ > {}
287
+
288
+ interface LinkProps extends NodeProps {
289
+ /**
290
+ * Enable/disable page wrapping for element.
291
+ * @see https://react-pdf.org/components#page-wrapping
292
+ */
293
+ wrap?: boolean;
294
+ /**
295
+ * Enables debug mode on page bounding box.
296
+ * @see https://react-pdf.org/advanced#debugging
297
+ */
298
+ debug?: boolean;
299
+ href?: string;
300
+ src?: string;
301
+ /**
302
+ * Extends the clickable area of the link beyond its visible bounds.
303
+ * Accepts a number (applied to all sides) or an object with top, bottom, left, right.
304
+ * @see https://reactnative.dev/docs/view#hitslop
305
+ */
306
+ hitSlop?: HitSlop;
307
+ }
308
+
309
+ /**
310
+ * A React component for displaying a hyperlink. Link’s can be nested
311
+ * inside a Text component, or being inside any other valid primitive.
312
+ */
313
+ export class Link extends React.Component<
314
+ React.PropsWithChildren<LinkProps>
315
+ > {}
316
+
317
+ interface FormCommonProps extends NodeProps {
318
+ name?: string;
319
+ required?: boolean;
320
+ noExport?: boolean;
321
+ readOnly?: boolean;
322
+ value?: number | string;
323
+ defaultValue?: number | string;
324
+ }
325
+
326
+ interface FieldSetProps extends NodeProps {
327
+ name: string;
328
+ }
329
+
330
+ export class FieldSet extends React.Component<
331
+ React.PropsWithChildren<FieldSetProps>
332
+ > {}
333
+
334
+ // see http://pdfkit.org/docs/forms.html#text_field_formatting
335
+ interface TextInputFormatting {
336
+ type:
337
+ | 'date'
338
+ | 'time'
339
+ | 'percent'
340
+ | 'number'
341
+ | 'zip'
342
+ | 'zipPlus4'
343
+ | 'phone'
344
+ | 'ssn';
345
+ param?: string;
346
+ nDec?: number;
347
+ sepComma?: boolean;
348
+ negStyle?: 'MinusBlack' | 'Red' | 'ParensBlack' | 'ParensRed';
349
+ currency?: string;
350
+ currencyPrepend?: boolean;
351
+ }
352
+
353
+ // see http://pdfkit.org/docs/forms.html#text_field_formatting
354
+ interface TextInputProps extends FormCommonProps {
355
+ align?: 'left' | 'center' | 'right';
356
+ multiline?: boolean;
357
+ /**
358
+ * The text will be masked (e.g. with asterisks).
359
+ */
360
+ password?: boolean;
361
+ /**
362
+ * If set, text entered in the field is not spell-checked
363
+ */
364
+ noSpell?: boolean;
365
+ format?: TextInputFormatting;
366
+ /**
367
+ * Sets the fontSize (default or 0 means auto sizing)
368
+ */
369
+ fontSize?: number;
370
+ /**
371
+ * Sets the maximum length (characters) of the text in the field
372
+ */
373
+ maxLength?: number;
374
+ }
375
+
376
+ export class TextInput extends React.Component<TextInputProps> {}
377
+
378
+ interface CheckboxProps extends FormCommonProps {
379
+ backgroundColor?: string;
380
+ borderColor?: string;
381
+ checked?: boolean;
382
+ onState?: string;
383
+ offState?: string;
384
+ xMark?: boolean;
385
+ }
386
+
387
+ export class Checkbox extends React.Component<CheckboxProps> {}
388
+
389
+ interface SelectAndListPropsBase extends FormCommonProps {
390
+ sort?: boolean;
391
+ edit?: boolean;
392
+ multiSelect?: boolean;
393
+ noSpell?: boolean;
394
+ select?: string[];
395
+ }
396
+
397
+ type SelectAndListPropsWithEdit = SelectAndListPropsBase & {
398
+ edit: true | false;
399
+ noSpell: boolean;
400
+ };
401
+
402
+ type SelectAndListPropsWithNoSpell = SelectAndListPropsBase & {
403
+ edit: boolean;
404
+ noSpell: true | false;
405
+ };
406
+
407
+ type SelectAndListProps =
408
+ | SelectAndListPropsWithEdit
409
+ | SelectAndListPropsWithNoSpell;
410
+
411
+ export class Select extends React.Component<SelectAndListProps> {}
412
+
413
+ export class List extends React.Component<SelectAndListProps> {}
414
+
415
+ interface NoteProps extends NodeProps {
416
+ children: string;
417
+ }
418
+
419
+ export class Note extends React.Component<NoteProps> {}
420
+
421
+ interface CanvasProps extends NodeProps {
422
+ /**
423
+ * Enables debug mode on page bounding box.
424
+ * @see https://react-pdf.org/advanced#debugging
425
+ */
426
+ debug?: boolean;
427
+ paint: (
428
+ painter: any,
429
+ availableWidth: number,
430
+ availableHeight: number,
431
+ ) => null;
432
+ }
433
+
434
+ export class Canvas extends React.Component<CanvasProps> {}
435
+
436
+ interface SVGProps extends NodeProps, SVGPresentationAttributes {
437
+ /**
438
+ * Enables debug mode on page bounding box.
439
+ * @see https://react-pdf.org/advanced#debugging
440
+ */
441
+ debug?: boolean;
442
+ width?: string | number;
443
+ height?: string | number;
444
+ viewBox?: string;
445
+ preserveAspectRatio?: string;
446
+ }
447
+
448
+ /**
449
+ * The <SVG /> element is a container that defines a new coordinate system and viewport. It is used as the outermost element of SVG documents.
450
+ */
451
+ export class Svg extends React.Component<React.PropsWithChildren<SVGProps>> {}
452
+
453
+ interface LineProps extends SVGPresentationAttributes {
454
+ style?: SVGPresentationAttributes;
455
+ x1: string | number;
456
+ x2: string | number;
457
+ y1: string | number;
458
+ y2: string | number;
459
+ }
460
+
461
+ /**
462
+ * The <Line /> element is used to create a line.
463
+ */
464
+ export class Line extends React.Component<
465
+ React.PropsWithChildren<LineProps>
466
+ > {}
467
+
468
+ interface PolylineProps extends SVGPresentationAttributes {
469
+ style?: SVGPresentationAttributes;
470
+ points: string;
471
+ }
472
+
473
+ /**
474
+ * The <Polyline /> element is used to create any shape that consists of only straight lines (that is connected at several points).
475
+ */
476
+ export class Polyline extends React.Component<
477
+ React.PropsWithChildren<PolylineProps>
478
+ > {}
479
+
480
+ interface PolygonProps extends SVGPresentationAttributes {
481
+ style?: SVGPresentationAttributes;
482
+ points: string;
483
+ }
484
+
485
+ /**
486
+ * The <Polygon /> element is used to create a graphic that contains at least three sides.
487
+ * Polygons are made of straight lines, and the shape is "closed" (all the lines connect up).
488
+ */
489
+ export class Polygon extends React.Component<
490
+ React.PropsWithChildren<PolygonProps>
491
+ > {}
492
+
493
+ interface PathProps extends SVGPresentationAttributes {
494
+ style?: SVGPresentationAttributes;
495
+ d: string;
496
+ }
497
+
498
+ /**
499
+ * The <Path /> element is the most powerful element in the SVG library of basic shapes. It can be used to create lines, curves, arcs, and more.
500
+ */
501
+ export class Path extends React.Component<
502
+ React.PropsWithChildren<PathProps>
503
+ > {}
504
+
505
+ interface RectProps extends SVGPresentationAttributes {
506
+ style?: SVGPresentationAttributes;
507
+ x?: string | number;
508
+ y?: string | number;
509
+ width: string | number;
510
+ height: string | number;
511
+ rx?: string | number;
512
+ ry?: string | number;
513
+ }
514
+
515
+ /**
516
+ * The <Rect /> element is used to create a rectangle and variations of a rectangle shape.
517
+ */
518
+ export class Rect extends React.Component<
519
+ React.PropsWithChildren<RectProps>
520
+ > {}
521
+
522
+ interface CircleProps extends SVGPresentationAttributes {
523
+ style?: SVGPresentationAttributes;
524
+ cx?: string | number;
525
+ cy?: string | number;
526
+ r: string | number;
527
+ }
528
+
529
+ /**
530
+ * The <Circle /> element is used to create a circle.
531
+ */
532
+ export class Circle extends React.Component<
533
+ React.PropsWithChildren<CircleProps>
534
+ > {}
535
+
536
+ interface EllipseProps extends SVGPresentationAttributes {
537
+ style?: SVGPresentationAttributes;
538
+ cx?: string | number;
539
+ cy?: string | number;
540
+ rx: string | number;
541
+ ry: string | number;
542
+ }
543
+
544
+ /**
545
+ * The <Ellipse /> element is used to create an ellipse.
546
+ * An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius.
547
+ */
548
+ export class Ellipse extends React.Component<
549
+ React.PropsWithChildren<EllipseProps>
550
+ > {}
551
+
552
+ interface TspanProps extends SVGPresentationAttributes {
553
+ x?: string | number;
554
+ y?: string | number;
555
+ }
556
+
557
+ /**
558
+ * The <Tspan /> element defines a subtext within a <Text /> element or another <Tspan /> element.
559
+ * It allows for adjustment of the style and/or position of that subtext as needed.
560
+ */
561
+ export class Tspan extends React.Component<
562
+ React.PropsWithChildren<TspanProps>
563
+ > {}
564
+
565
+ interface GProps extends SVGPresentationAttributes {
566
+ style?: Style;
567
+ }
568
+
569
+ /**
570
+ * The <G /> SVG element is a container used to group other SVG elements.
571
+ * Transformations applied to the <G /> element are performed on its child elements, and its attributes are inherited by its children.
572
+ */
573
+ export class G extends React.Component<React.PropsWithChildren<GProps>> {}
574
+
575
+ interface StopProps {
576
+ offset: string | number;
577
+ stopColor: string;
578
+ stopOpacity?: string | number;
579
+ }
580
+
581
+ /**
582
+ * The SVG <Stop /> element defines a color and its position to use on a gradient. This element is always a child of a <LinearGradient /> or <RadialGradient /> element
583
+ */
584
+ export class Stop extends React.Component<
585
+ React.PropsWithChildren<StopProps>
586
+ > {}
587
+
588
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
589
+ interface DefsProps {}
590
+
591
+ /**
592
+ * The <Defs /> element is used to store graphical objects that will be used at a later time. Objects created inside a <Defs /> element are not rendered directly. To display them you have to reference them
593
+ */
594
+ export class Defs extends React.Component<
595
+ React.PropsWithChildren<DefsProps>
596
+ > {}
597
+
598
+ interface ClipPathProps {
599
+ id?: string;
600
+ }
601
+
602
+ /**
603
+ * The <ClipPath /> SVG element defines a clipping path, to be used by the clipPath property.
604
+ * A clipping path restricts the region to which paint can be applied. Conceptually, parts of the drawing that lie outside of the region bounded by the clipping path are not drawn.
605
+ */
606
+ export class ClipPath extends React.Component<
607
+ React.PropsWithChildren<ClipPathProps>
608
+ > {}
609
+
610
+ interface MarkerProps {
611
+ id: string;
612
+ viewBox?: string;
613
+ refX?: string | number;
614
+ refY?: string | number;
615
+ markerWidth?: string | number;
616
+ markerHeight?: string | number;
617
+ orient?: 'auto' | 'auto-start-reverse' | number;
618
+ markerUnits?: 'strokeWidth' | 'userSpaceOnUse';
619
+ }
620
+
621
+ /**
622
+ * The <Marker /> SVG element defines a graphic used for drawing arrows or polymarkers on a given <Path />, <Line />, <Polyline />, or <Polygon /> element.
623
+ * Markers can be attached to shapes using the markerStart, markerMid, and markerEnd properties.
624
+ */
625
+ export class Marker extends React.Component<
626
+ React.PropsWithChildren<MarkerProps>
627
+ > {}
628
+
629
+ interface LinearGradientProps {
630
+ id: string;
631
+ x1?: string | number;
632
+ x2?: string | number;
633
+ y1?: string | number;
634
+ y2?: string | number;
635
+ xlinkHref?: string;
636
+ gradientTransform?: string;
637
+ gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
638
+ }
639
+
640
+ /**
641
+ * The <LinearGradient /> element lets authors define linear gradients that can be applied to fill or stroke of graphical elements.
642
+ */
643
+ export class LinearGradient extends React.Component<
644
+ React.PropsWithChildren<LinearGradientProps>
645
+ > {}
646
+
647
+ interface RadialGradientProps {
648
+ id: string;
649
+ cx?: string | number;
650
+ cy?: string | number;
651
+ r?: string | number;
652
+ fx?: string | number;
653
+ fy?: string | number;
654
+ xlinkHref?: string;
655
+ gradientTransform?: string;
656
+ gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
657
+ }
658
+
659
+ /**
660
+ * The <RadialGradient /> element lets authors define radial gradients that can be applied to fill or stroke of graphical elements.
661
+ */
662
+ export class RadialGradient extends React.Component<
663
+ React.PropsWithChildren<RadialGradientProps>
664
+ > {}
665
+
666
+ interface BlobProviderParams {
667
+ blob: Blob | null;
668
+ url: string | null;
669
+ loading: boolean;
670
+ error: Error | null;
671
+ }
672
+ interface BlobProviderProps {
673
+ document: React.ReactElement<DocumentProps>;
674
+ children: (params: BlobProviderParams) => React.ReactNode;
675
+ }
676
+
677
+ /**
678
+ * Easy and declarative way of getting document's blob data without
679
+ * showing it on screen.
680
+ * @see https://react-pdf.org/advanced#on-the-fly-rendering
681
+ * @platform web
682
+ */
683
+ export class BlobProvider extends React.Component<BlobProviderProps> {}
684
+
685
+ interface PDFViewerProps {
686
+ width?: number | string;
687
+ height?: number | string;
688
+ style?: Style | Style[];
689
+ className?: string;
690
+ children?: React.ReactElement<DocumentProps>;
691
+ innerRef?: React.Ref<HTMLIFrameElement>;
692
+ showToolbar?: boolean;
693
+ }
694
+
695
+ /**
696
+ * Iframe PDF viewer for client-side generated documents.
697
+ * @platform web
698
+ */
699
+ export class PDFViewer extends React.Component<PDFViewerProps> {}
700
+
701
+ interface PDFDownloadLinkProps
702
+ extends Omit<
703
+ React.AnchorHTMLAttributes<HTMLAnchorElement>,
704
+ 'href' | 'children'
705
+ > {
706
+ /** PDF filename. Alias for anchor tag `download` attribute. */
707
+ fileName?: string;
708
+ document: React.ReactElement<DocumentProps>;
709
+ children?: React.ReactNode | React.FC<BlobProviderParams>;
710
+ onClick?: React.AnchorHTMLAttributes<HTMLAnchorElement>['onClick'] &
711
+ ((
712
+ event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
713
+ instance: UsePDFInstance,
714
+ ) => void);
715
+ ref?: React.Ref<HTMLAnchorElement> | undefined;
716
+ }
717
+
718
+ /**
719
+ * Anchor tag to enable generate and download PDF documents on the fly.
720
+ * @see https://react-pdf.org/advanced#on-the-fly-rendering
721
+ * @platform web
722
+ */
723
+ export class PDFDownloadLink extends React.Component<PDFDownloadLinkProps> {}
724
+
725
+ interface UsePDFInstance {
726
+ loading: boolean;
727
+ blob: Blob | null;
728
+ url: string | null;
729
+ error: string | null;
730
+ }
731
+
732
+ /**
733
+ * React hook for creating and updating a PDF document instance
734
+ * @platform web
735
+ */
736
+ export function usePDF(options?: {
737
+ document?: React.ReactElement<DocumentProps>;
738
+ }): [
739
+ UsePDFInstance,
740
+ (newDocument: React.ReactElement<DocumentProps>) => void,
741
+ ];
742
+
743
+ export const Font: FontStore;
744
+
745
+ export const StyleSheet: {
746
+ create: <T extends Styles>(styles: T) => T;
747
+ };
748
+
749
+ export const version: any;
750
+
751
+ export const PDFRenderer: any;
752
+
753
+ export const pdf: (initialValue?: React.ReactElement<DocumentProps>) => {
754
+ container: any;
755
+ isDirty: () => boolean;
756
+ toString: () => string;
757
+ toBlob: () => Promise<Blob>;
758
+ toBuffer: () => Promise<NodeJS.ReadableStream>;
759
+ on: (event: 'change', callback: () => void) => void;
760
+ updateContainer: (
761
+ document: React.ReactElement<any>,
762
+ callback?: () => void,
763
+ ) => void;
764
+ removeListener: (event: 'change', callback: () => void) => void;
765
+ };
766
+
767
+ export const renderToStream: (
768
+ document: React.ReactElement<DocumentProps>,
769
+ ) => Promise<NodeJS.ReadableStream>;
770
+
771
+ /**
772
+ * @deprecated use the `renderToBuffer` method
773
+ */
774
+ export const renderToString: (
775
+ document: React.ReactElement<DocumentProps>,
776
+ ) => Promise<string>;
777
+
778
+ export const renderToFile: (
779
+ document: React.ReactElement<DocumentProps>,
780
+ filePath: string,
781
+ callback?: (output: NodeJS.ReadableStream, _filePath: string) => any,
782
+ ) => Promise<NodeJS.ReadableStream>;
783
+
784
+ const render: typeof renderToFile;
785
+
786
+ /**
787
+ * Render document into a nodejs buffer
788
+ * @platform node
789
+ */
790
+ export const renderToBuffer: (
791
+ document: React.ReactElement<ReactPDF.DocumentProps>,
792
+ ) => Promise<Buffer>;
793
+ }