forked from eriese/SVG-to-PDFKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
62 lines (52 loc) · 1.95 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import type PDFDocument from "pdfkit"
/**
* Insert SVG into a PDF document created with PDFKit.
*
* @param doc the PDF document created with PDFKit
* @param svg the SVG object or XML code
* @param x the x position where the SVG will be added
* @param y the y position where the SVG will be added
* @param options See {@link SVGtoPDF.Options}
*/
declare function SVGtoPDF(
doc: typeof PDFDocument,
svg: SVGElement | string,
x: number,
y: number,
options: SVGtoPDF.Options,
): void
declare namespace SVGtoPDF {
export type Color = [[number, number, number], number]
export interface Options {
// initial viewport width, by default it's the page width
width?: number
// initial viewport width, by default it's the page height
height?: number
// override alignment of the SVG content inside its viewport
preserveAspectRatio?: string
// use the CSS styles computed by the browser (for SVGElement only)
useCSS?: boolean
// function called to get the fonts, see source code
fontCallback?: (
family: string,
bold: boolean,
italic: boolean,
fontOptions: { fauxItalic: boolean; fauxBold: boolean },
) => string
// same as above for the images (for Node.js)
imageCallback?: (link: string) => string
// same as above for the external SVG documents
documentCallback?: (
file: string,
) => SVGElement | string | (SVGElement | string)[]
// function called to get color, making mapping to CMYK possible
colorCallback?: (color: Color) => Color
// function called when there is a warning
warningCallback?: (warning: string) => void
// assume that units are PDF points instead of SVG pixels
assumePt?: boolean
// precision factor for approximate calculations (default = 3)
precision?: number
}
}
export = SVGtoPDF