@kittl/pdfkit 0.17.3 → 0.17.5

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,76 @@
1
+ import PDFKit from './pdfkit';
2
+
3
+ /**
4
+ * Insert SVG into a PDF document created with PDFKit.
5
+ *
6
+ * @param doc the PDF document created with PDFKit
7
+ * @param svg the SVG object or XML code
8
+ * @param x the x position where the SVG will be added
9
+ * @param y the y position where the SVG will be added
10
+ * @param options See {@link SVGtoPDF.Options}
11
+ */
12
+ export default function SVGtoPDF(
13
+ doc: PDFKit.PDFDocument,
14
+ svg: SVGElement | string,
15
+ x?: number,
16
+ y?: number,
17
+ options?: SVGtoPDF.Options,
18
+ ): void;
19
+
20
+ declare namespace SVGtoPDF {
21
+ type RGBColor = [[number, number, number], number];
22
+ type CMYKColor = [[number, number, number, number], number];
23
+
24
+ interface Options {
25
+ /** initial viewport width, by default it's the page width */
26
+ width?: number;
27
+
28
+ /** initial viewport width, by default it's the page height */
29
+ height?: number;
30
+
31
+ /** override alignment of the SVG content inside its viewport */
32
+ preserveAspectRatio?: string;
33
+
34
+ /** use the CSS styles computed by the browser (for SVGElement only) */
35
+ useCSS?: boolean;
36
+
37
+ /** function called to get the fonts, see source code */
38
+ fontCallback?: (
39
+ family: string,
40
+ bold: boolean,
41
+ italic: boolean,
42
+ fontOptions: { fauxItalic: boolean; fauxBold: boolean },
43
+ ) => string;
44
+
45
+ /** same as above for the images (for Node.js) */
46
+ imageCallback?: (link: string) => { src: string | Uint8Array, properties?: BitmapProperties };
47
+
48
+ /** same as above for the external SVG documents */
49
+ documentCallback?: (
50
+ file: string,
51
+ ) => SVGElement | string | (SVGElement | string)[];
52
+
53
+ /** function called to get color, making mapping to CMYK possible */
54
+ colorCallback?: (
55
+ color: RGBColor | CMYKColor,
56
+ raw: string,
57
+ ) => RGBColor | CMYKColor;
58
+
59
+ /** function called when there is a warning */
60
+ warningCallback?: (warning: string, error?: unknown) => void;
61
+
62
+ /** assume that units are PDF points instead of SVG pixels */
63
+ assumePt?: boolean;
64
+
65
+ /** precision factor for approximate calculations (default = 3) */
66
+ precision?: number;
67
+ }
68
+
69
+ interface BitmapProperties {
70
+ width: number;
71
+ height: number;
72
+ channels: number;
73
+ colorSpace: string;
74
+ isBitmap: true;
75
+ }
76
+ }