@kittl/pdfkit 0.17.4 → 0.17.51
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/.yarn/install-state.gz +0 -0
- package/js/pdfkit.es.js +114 -16
- package/js/pdfkit.es.js.map +1 -1
- package/js/pdfkit.js +114 -16
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +18594 -35280
- package/js/writeSvg.es.js +3684 -0
- package/js/writeSvg.es.js.map +1 -0
- package/js/writeSvg.js +3686 -0
- package/js/writeSvg.js.map +1 -0
- package/js/write_svg.es.js +3714 -0
- package/js/write_svg.es.js.map +1 -0
- package/js/write_svg.js +3716 -0
- package/js/write_svg.js.map +1 -0
- package/package.json +16 -5
- package/types/{index.d.ts → pdfkit.d.ts} +32 -32
- package/types/write_svg.d.ts +76 -0
- package/js/pdfkit.es5.js +0 -6091
- package/js/pdfkit.es5.js.map +0 -1
- package/js/pdfkit.esnext.js +0 -5392
- package/js/pdfkit.esnext.js.map +0 -1
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"document",
|
|
10
10
|
"vector"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.17.
|
|
12
|
+
"version": "0.17.51",
|
|
13
13
|
"homepage": "http://pdfkit.org/",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Devon Govett",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"scripts": {
|
|
59
59
|
"prepublishOnly": "npm run build",
|
|
60
60
|
"build": "rollup -c && npm run build-standalone",
|
|
61
|
-
"build-standalone": "browserify --standalone PDFDocument --ignore crypto
|
|
61
|
+
"build-standalone": "browserify js/pdfkit.js --standalone PDFDocument --ignore crypto --no-builtins -t brfs > js/pdfkit.standalone.js",
|
|
62
62
|
"browserify-example": "browserify examples/browserify/browser.js > examples/browserify/bundle.js",
|
|
63
63
|
"pdf-guide": "node docs/generate.js",
|
|
64
64
|
"website": "node docs/generate_website.js",
|
|
@@ -70,9 +70,20 @@
|
|
|
70
70
|
"test:visual": "jest visual/",
|
|
71
71
|
"test:unit": "jest unit/"
|
|
72
72
|
},
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
73
|
+
"types": "./types/pdfkit.d.ts",
|
|
74
|
+
"exports": {
|
|
75
|
+
".": {
|
|
76
|
+
"require": "./js/pdfkit.js",
|
|
77
|
+
"import": "./js/pdfkit.es.js",
|
|
78
|
+
"types": "./types/pdfkit.d.ts"
|
|
79
|
+
},
|
|
80
|
+
"./writeSVG": {
|
|
81
|
+
"require": "./js/write_svg.js",
|
|
82
|
+
"import": "./js/write_svg.es.js",
|
|
83
|
+
"types": "./types/write_svg.d.ts"
|
|
84
|
+
},
|
|
85
|
+
"./js/virtual-fs.js": "./js/virtual-fs.js"
|
|
86
|
+
},
|
|
76
87
|
"browserify": {
|
|
77
88
|
"transform": [
|
|
78
89
|
"brfs"
|
|
@@ -40,7 +40,7 @@ shader(fn: () => any): any;
|
|
|
40
40
|
data: Uint8Array | Buffer;
|
|
41
41
|
channels: number;
|
|
42
42
|
alternate: string | string[];
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
declare namespace PDFKit.Mixins {
|
|
@@ -388,8 +388,8 @@ declare namespace PDFKit.Mixins {
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
interface PDFColor {
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
beginColorSpace(label: string): this;
|
|
392
|
+
endColorSpace(): this;
|
|
393
393
|
fillColor(color: ColorValue, opacity?: number): this;
|
|
394
394
|
strokeColor(color: ColorValue, opacity?: number): this;
|
|
395
395
|
opacity(opacity: number): this;
|
|
@@ -877,26 +877,7 @@ declare namespace PDFKit {
|
|
|
877
877
|
fontLayoutCache?: boolean;
|
|
878
878
|
}
|
|
879
879
|
|
|
880
|
-
|
|
881
|
-
extends
|
|
882
|
-
NodeJS.ReadableStream,
|
|
883
|
-
Mixins.PDFMetadata,
|
|
884
|
-
Mixins.PDFAnnotation,
|
|
885
|
-
Mixins.PDFColor,
|
|
886
|
-
Mixins.PDFImage,
|
|
887
|
-
Mixins.PDFTable,
|
|
888
|
-
Mixins.PDFText,
|
|
889
|
-
Mixins.PDFVector,
|
|
890
|
-
Mixins.PDFFont,
|
|
891
|
-
Mixins.PDFAcroForm,
|
|
892
|
-
Mixins.PDFMarking,
|
|
893
|
-
Mixins.PDFAttachment,
|
|
894
|
-
Mixins.PDFMetadata,
|
|
895
|
-
Mixins.PDFSubset,
|
|
896
|
-
Mixins.PDFOutline,
|
|
897
|
-
Mixins.PDFColorSpace,
|
|
898
|
-
Mixins.PDFOutputIntent
|
|
899
|
-
{
|
|
880
|
+
class PDFDocument {
|
|
900
881
|
/**
|
|
901
882
|
* PDF Version
|
|
902
883
|
*/
|
|
@@ -917,11 +898,12 @@ declare namespace PDFKit {
|
|
|
917
898
|
* Represent the current page.
|
|
918
899
|
*/
|
|
919
900
|
page: PDFPage;
|
|
901
|
+
outline: PDFKit.PDFOutline;
|
|
920
902
|
|
|
921
903
|
x: number;
|
|
922
904
|
y: number;
|
|
923
905
|
|
|
924
|
-
|
|
906
|
+
constructor(options?: PDFDocumentOptions);
|
|
925
907
|
|
|
926
908
|
addPage(options?: PDFDocumentOptions): PDFDocument;
|
|
927
909
|
continueOnNewPage(options?: PDFDocumentOptions): PDFDocument;
|
|
@@ -951,21 +933,39 @@ declare namespace PDFKit {
|
|
|
951
933
|
addNamedEmbeddedFile(name: string, ref: PDFKitReference): void;
|
|
952
934
|
addNamedJavaScript(name: string, js: string): void;
|
|
953
935
|
|
|
954
|
-
ref(data:
|
|
955
|
-
addContent(data:
|
|
936
|
+
ref(data: Record<string, unknown>): PDFKitReference;
|
|
937
|
+
addContent(data: unknown): PDFDocument;
|
|
956
938
|
end(): void;
|
|
957
939
|
toString(): string;
|
|
958
940
|
}
|
|
959
|
-
}
|
|
960
941
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
942
|
+
interface PDFDocument
|
|
943
|
+
extends
|
|
944
|
+
NodeJS.ReadableStream,
|
|
945
|
+
Mixins.PDFMetadata,
|
|
946
|
+
Mixins.PDFAnnotation,
|
|
947
|
+
Mixins.PDFColor,
|
|
948
|
+
Mixins.PDFImage,
|
|
949
|
+
Mixins.PDFTable,
|
|
950
|
+
Mixins.PDFText,
|
|
951
|
+
Mixins.PDFVector,
|
|
952
|
+
Mixins.PDFFont,
|
|
953
|
+
Mixins.PDFAcroForm,
|
|
954
|
+
Mixins.PDFMarking,
|
|
955
|
+
Mixins.PDFAttachment,
|
|
956
|
+
Mixins.PDFSubset,
|
|
957
|
+
Mixins.PDFOutline,
|
|
958
|
+
Mixins.PDFColorSpace,
|
|
959
|
+
Mixins.PDFOutputIntent {}
|
|
964
960
|
}
|
|
965
961
|
|
|
962
|
+
declare const PDFDocument: typeof PDFKit.PDFDocument;
|
|
963
|
+
|
|
964
|
+
export default PDFDocument;
|
|
965
|
+
|
|
966
966
|
declare module "pdfkit/js/pdfkit.standalone" {
|
|
967
|
-
|
|
968
|
-
export
|
|
967
|
+
const PDFDocument: typeof PDFKit.PDFDocument;
|
|
968
|
+
export default PDFDocument;
|
|
969
969
|
}
|
|
970
970
|
|
|
971
971
|
declare module "pdfkit/js/gradient" {
|
|
@@ -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
|
+
export 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
|
+
}
|