pdfv8 0.0.1

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.
Files changed (76) hide show
  1. package/.cursor/settings.json +7 -0
  2. package/CHANGELOG.md +148 -0
  3. package/LICENSE +8 -0
  4. package/README.md +195 -0
  5. package/bun.lock +1549 -0
  6. package/js/pdfkit.es.js +498 -0
  7. package/js/pdfkit.es.js.map +1 -0
  8. package/js/pdfkit.js +500 -0
  9. package/js/pdfkit.js.map +1 -0
  10. package/js/pdfkit.standalone.js +49525 -0
  11. package/js/virtual-fs.js +95 -0
  12. package/jsconfig.json +13 -0
  13. package/package.json +102 -0
  14. package/scripts/gen-afm-data.mjs +41 -0
  15. package/tsconfig.build.json +23 -0
  16. package/types/abstract_reference.d.ts +4 -0
  17. package/types/crypto/aes.d.ts +2 -0
  18. package/types/crypto/md5.d.ts +2 -0
  19. package/types/crypto/random.d.ts +1 -0
  20. package/types/crypto/rc4.d.ts +1 -0
  21. package/types/crypto/sha256.d.ts +1 -0
  22. package/types/data.d.ts +29 -0
  23. package/types/document.d.ts +25 -0
  24. package/types/font/afm.d.ts +21 -0
  25. package/types/font/afm_data.generated.d.ts +1 -0
  26. package/types/font/embedded.d.ts +12 -0
  27. package/types/font/standard.d.ts +12 -0
  28. package/types/font.d.ts +10 -0
  29. package/types/font_factory.d.ts +6 -0
  30. package/types/gradient.d.ts +23 -0
  31. package/types/image/jpeg.d.ts +5 -0
  32. package/types/image/png.d.ts +9 -0
  33. package/types/image.d.ts +6 -0
  34. package/types/jest.custom-matchers.d.ts +28 -0
  35. package/types/line_wrapper.d.ts +10 -0
  36. package/types/metadata.d.ts +9 -0
  37. package/types/mixins/acroform.d.ts +48 -0
  38. package/types/mixins/annotations.d.ts +17 -0
  39. package/types/mixins/attachments.d.ts +17 -0
  40. package/types/mixins/color.d.ts +39 -0
  41. package/types/mixins/fonts.d.ts +19 -0
  42. package/types/mixins/images.d.ts +6 -0
  43. package/types/mixins/markings.d.ts +19 -0
  44. package/types/mixins/metadata.d.ts +7 -0
  45. package/types/mixins/outline.d.ts +5 -0
  46. package/types/mixins/pdfa.d.ts +9 -0
  47. package/types/mixins/pdfua.d.ts +7 -0
  48. package/types/mixins/subsets.d.ts +5 -0
  49. package/types/mixins/table.d.ts +11 -0
  50. package/types/mixins/text.d.ts +31 -0
  51. package/types/mixins/vector.d.ts +43 -0
  52. package/types/name_tree.d.ts +7 -0
  53. package/types/number_tree.d.ts +7 -0
  54. package/types/object.d.ts +5 -0
  55. package/types/outline.d.ts +20 -0
  56. package/types/page.d.ts +27 -0
  57. package/types/path.d.ts +4 -0
  58. package/types/pattern.d.ts +12 -0
  59. package/types/reference.d.ts +9 -0
  60. package/types/saslprep/index.d.ts +9 -0
  61. package/types/security.d.ts +12 -0
  62. package/types/spotcolor.d.ts +4 -0
  63. package/types/structure_annotation.d.ts +4 -0
  64. package/types/structure_content.d.ts +5 -0
  65. package/types/structure_element.d.ts +15 -0
  66. package/types/table/accessibility.d.ts +38 -0
  67. package/types/table/index.d.ts +23 -0
  68. package/types/table/normalize.d.ts +41 -0
  69. package/types/table/render.d.ts +10 -0
  70. package/types/table/size.d.ts +23 -0
  71. package/types/table/style.d.ts +48 -0
  72. package/types/table/utils.d.ts +303 -0
  73. package/types/tree.d.ts +10 -0
  74. package/types/utils.d.ts +64 -0
  75. package/types/virtual-fs.d.ts +8 -0
  76. package/types.d.ts +1128 -0
@@ -0,0 +1,95 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ function _typeof(o) {
8
+ "@babel/helpers - typeof";
9
+
10
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
11
+ return typeof o;
12
+ } : function (o) {
13
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
14
+ }, _typeof(o);
15
+ }
16
+ function _classCallCheck(a, n) {
17
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
18
+ }
19
+ function _defineProperties(e, r) {
20
+ for (var t = 0; t < r.length; t++) {
21
+ var o = r[t];
22
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
23
+ }
24
+ }
25
+ function _createClass(e, r, t) {
26
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
27
+ writable: !1
28
+ }), e;
29
+ }
30
+ function _toPropertyKey(t) {
31
+ var i = _toPrimitive(t, "string");
32
+ return "symbol" == _typeof(i) ? i : i + "";
33
+ }
34
+ function _toPrimitive(t, r) {
35
+ if ("object" != _typeof(t) || !t) return t;
36
+ var e = t[Symbol.toPrimitive];
37
+ if (void 0 !== e) {
38
+ var i = e.call(t, r || "default");
39
+ if ("object" != _typeof(i)) return i;
40
+ throw new TypeError("@@toPrimitive must return a primitive value.");
41
+ }
42
+ return ("string" === r ? String : Number)(t);
43
+ }
44
+ var VirtualFileSystem = /*#__PURE__*/function () {
45
+ function VirtualFileSystem() {
46
+ _classCallCheck(this, VirtualFileSystem);
47
+ this.fileData = {};
48
+ }
49
+ return _createClass(VirtualFileSystem, [{
50
+ key: "readFileSync",
51
+ value: function readFileSync(fileName) {
52
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
53
+ var encoding = typeof options === 'string' ? options : options.encoding;
54
+ var virtualFileName = normalizeFilename(fileName);
55
+ var data = this.fileData[virtualFileName];
56
+ if (data == null) {
57
+ throw new Error("File '".concat(virtualFileName, "' not found in virtual file system"));
58
+ }
59
+ if (encoding) {
60
+ // return a string
61
+ return typeof data === 'string' ? data : data.toString(encoding);
62
+ }
63
+ return Buffer.from(data, typeof data === 'string' ? 'base64' : undefined);
64
+ }
65
+ }, {
66
+ key: "writeFileSync",
67
+ value: function writeFileSync(fileName, content) {
68
+ this.fileData[normalizeFilename(fileName)] = content;
69
+ }
70
+ }, {
71
+ key: "bindFileData",
72
+ value: function bindFileData() {
73
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
74
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
75
+ if (options.reset) {
76
+ this.fileData = data;
77
+ } else {
78
+ Object.assign(this.fileData, data);
79
+ }
80
+ }
81
+ }]);
82
+ }();
83
+ function normalizeFilename(fileName) {
84
+ if (fileName.indexOf('./') === 0) {
85
+ fileName = fileName.substring(2);
86
+ }
87
+ if (fileName.indexOf(__dirname) === 0) {
88
+ fileName = fileName.substring(__dirname.length);
89
+ }
90
+ if (fileName.indexOf('/') === 0) {
91
+ fileName = fileName.substring(1);
92
+ }
93
+ return fileName;
94
+ }
95
+ exports["default"] = new VirtualFileSystem();
package/jsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "allowJs": true,
6
+ // Don't force external @types; our ambient file is included below
7
+ "baseUrl": "."
8
+ },
9
+ "include": [
10
+ "tests/**/*.js",
11
+ "types/**/*.d.ts"
12
+ ]
13
+ }
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "pdfv8",
3
+ "description": "A PDF generation library for Cloudflare Workers",
4
+ "keywords": [
5
+ "pdf",
6
+ "pdf writer",
7
+ "pdf generator",
8
+ "graphics",
9
+ "document",
10
+ "vector",
11
+ "cloudflare",
12
+ "workers"
13
+ ],
14
+ "version": "0.0.1",
15
+ "homepage": "http://pdfv8.com/",
16
+ "author": {
17
+ "name": "Tiago de Souza Santos",
18
+ "email": "tiago@etc.digital",
19
+ "url": "https://etc.digital/"
20
+ },
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/etc-digital/pdfv8.git"
25
+ },
26
+ "bugs": "https://github.com/etc-digital/pdfv8/issues",
27
+ "devDependencies": {
28
+ "@babel/cli": "^7.26.4",
29
+ "@babel/core": "^7.26.0",
30
+ "@babel/plugin-external-helpers": "^7.25.9",
31
+ "@babel/preset-env": "^7.26.0",
32
+ "@babel/preset-typescript": "^7.26.0",
33
+ "@eslint/js": "^9.17.0",
34
+ "@rollup/plugin-babel": "^6.0.4",
35
+ "@types/node": "^22.13.10",
36
+ "babel-jest": "^29.7.0",
37
+ "blob-stream": "^0.1.3",
38
+ "brace": "^0.11.1",
39
+ "brfs": "~2.0.2",
40
+ "browserify": "^17.0.1",
41
+ "canvas": "^3.2.0",
42
+ "codemirror": "~5.65.18",
43
+ "eslint": "^9.17.0",
44
+ "gh-pages": "^6.2.0",
45
+ "globals": "^15.14.0",
46
+ "jest": "^29.7.0",
47
+ "jest-image-snapshot": "^6.4.0",
48
+ "markdown": "~0.5.0",
49
+ "pdfjs-dist": "^2.14.305",
50
+ "prettier": "3.4.2",
51
+ "pug": "^3.0.3",
52
+ "rollup": "^2.79.2",
53
+ "rollup-plugin-copy": "^3.5.0",
54
+ "typescript": "^5.8.2"
55
+ },
56
+ "dependencies": {
57
+ "@noble/ciphers": "^1.0.0",
58
+ "@noble/hashes": "^1.6.0",
59
+ "fontkit": "^2.0.4",
60
+ "js-md5": "^0.8.3",
61
+ "linebreak": "^1.1.0",
62
+ "png-js": "^1.0.0"
63
+ },
64
+ "scripts": {
65
+ "prepublishOnly": "npm run build",
66
+ "build:ts": "node scripts/gen-afm-data.mjs && babel src --extensions \".ts\" --out-dir lib --copy-files --no-babelrc --presets @babel/preset-env,@babel/preset-typescript",
67
+ "pretest": "npm run build:ts",
68
+ "build": "npm run build:ts && rollup -c && npm run build-standalone",
69
+ "build-standalone": "browserify --standalone PDFDocument --ignore crypto lib/document.js > js/pdfkit.standalone.js",
70
+ "browserify-example": "browserify examples/browserify/browser.js > examples/browserify/bundle.js",
71
+ "pdf-guide": "node docs/generate.js",
72
+ "website": "node docs/generate_website.js",
73
+ "publish-website": "node docs/publish_website.js",
74
+ "docs": "npm run pdf-guide && npm run website && npm run browserify-example",
75
+ "lint": "eslint {lib,tests}/**/*.js",
76
+ "prettier": "prettier lib tests docs",
77
+ "test": "node ./node_modules/jest/bin/jest.js",
78
+ "test:visual": "node ./node_modules/jest/bin/jest.js visual/",
79
+ "test:unit": "node ./node_modules/jest/bin/jest.js unit/"
80
+ },
81
+ "main": "js/pdfkit.js",
82
+ "module": "js/pdfkit.es.js",
83
+ "browserify": {
84
+ "transform": [
85
+ "brfs"
86
+ ]
87
+ },
88
+ "engine": [
89
+ "node >= v18.0.0"
90
+ ],
91
+ "jest": {
92
+ "testEnvironment": "node",
93
+ "testPathIgnorePatterns": [
94
+ "/node_modules/",
95
+ "<rootDir>/examples/"
96
+ ],
97
+ "setupFilesAfterEnv": [
98
+ "<rootDir>/tests/unit/setupTests.js"
99
+ ]
100
+ },
101
+ "packageManager": "bun@1.2.14"
102
+ }
@@ -0,0 +1,41 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+
4
+ const repoRoot = path.resolve(new URL('.', import.meta.url).pathname, '..');
5
+ const afmDir = path.join(repoRoot, 'src', 'font', 'data');
6
+ const outFile = path.join(repoRoot, 'src', 'font', 'afm_data.generated.ts');
7
+
8
+ const filenames = [
9
+ 'Courier.afm',
10
+ 'Courier-Bold.afm',
11
+ 'Courier-Oblique.afm',
12
+ 'Courier-BoldOblique.afm',
13
+ 'Helvetica.afm',
14
+ 'Helvetica-Bold.afm',
15
+ 'Helvetica-Oblique.afm',
16
+ 'Helvetica-BoldOblique.afm',
17
+ 'Times-Roman.afm',
18
+ 'Times-Bold.afm',
19
+ 'Times-Italic.afm',
20
+ 'Times-BoldItalic.afm',
21
+ 'Symbol.afm',
22
+ 'ZapfDingbats.afm',
23
+ ];
24
+
25
+ /** Escape for JS template literal. */
26
+ function escapeForTemplateLiteral(s) {
27
+ return s.replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('${', '\\${');
28
+ }
29
+
30
+ const entries = [];
31
+ for (const file of filenames) {
32
+ const p = path.join(afmDir, file);
33
+ const raw = await fs.readFile(p, 'utf8');
34
+ const name = file.replace(/\.afm$/, '');
35
+ entries.push(` ${JSON.stringify(name)}: \`\n${escapeForTemplateLiteral(raw)}\`,`);
36
+ }
37
+
38
+ const content = `// Generated by scripts/gen-afm-data.mjs\n// Loaded only via dynamic import from StandardFont.preload()\nexport const STANDARD_AFM_DATA: Record<string, string> = {\n${entries.join('\n')}\n};\n`;
39
+
40
+ await fs.writeFile(outFile, content, 'utf8');
41
+
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "rootDir": "src",
7
+ "outDir": "lib",
8
+ "declaration": false,
9
+ "emitDeclarationOnly": false,
10
+ "sourceMap": true,
11
+ "strict": false,
12
+ "skipLibCheck": true,
13
+ "esModuleInterop": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true
16
+ ,
17
+ "types": ["node"]
18
+ ,
19
+ "noEmitOnError": false
20
+ },
21
+ "include": ["src/**/*.ts"]
22
+ }
23
+
@@ -0,0 +1,4 @@
1
+ declare class PDFAbstractReference {
2
+ toString(): void;
3
+ }
4
+ export default PDFAbstractReference;
@@ -0,0 +1,2 @@
1
+ export declare function aesCbcEncrypt(data: any, key: any, iv: any, padding?: boolean): Uint8Array<ArrayBufferLike>;
2
+ export declare function aesEcbEncrypt(data: any, key: any): Uint8Array<ArrayBufferLike>;
@@ -0,0 +1,2 @@
1
+ export declare function md5Hash(data: any): Uint8Array<any>;
2
+ export declare function md5Hex(data: any): any;
@@ -0,0 +1 @@
1
+ export default function randomBytes(length: any): Uint8Array<any>;
@@ -0,0 +1 @@
1
+ export default function rc4(data: any, key: any): Uint8Array<any>;
@@ -0,0 +1 @@
1
+ export default function sha256Hash(data: any): Uint8Array<ArrayBufferLike>;
@@ -0,0 +1,29 @@
1
+ declare class Data {
2
+ constructor(data?: any[]);
3
+ readByte(): any;
4
+ writeByte(byte: any): any;
5
+ byteAt(index: any): any;
6
+ readBool(): boolean;
7
+ writeBool(val: any): any;
8
+ readUInt32(): any;
9
+ writeUInt32(val: any): any;
10
+ readInt32(): any;
11
+ writeInt32(val: any): any;
12
+ readUInt16(): number;
13
+ writeUInt16(val: any): any;
14
+ readInt16(): number;
15
+ writeInt16(val: any): any;
16
+ readString(length: any): string;
17
+ writeString(val: any): any[];
18
+ stringAt(pos: any, length: any): string;
19
+ readShort(): number;
20
+ writeShort(val: any): any;
21
+ readLongLong(): any;
22
+ writeLongLong(val: any): any;
23
+ readInt(): any;
24
+ writeInt(val: any): any;
25
+ slice(start: any, end: any): any;
26
+ read(bytes: any): any[];
27
+ write(bytes: any): any;
28
+ }
29
+ export default Data;
@@ -0,0 +1,25 @@
1
+ import stream from 'stream';
2
+ import PDFReference from './reference';
3
+ declare class PDFDocument extends stream.Readable {
4
+ constructor(options?: {});
5
+ addPage(options: any): this;
6
+ continueOnNewPage(options: any): this;
7
+ bufferedPageRange(): {
8
+ start: any;
9
+ count: any;
10
+ };
11
+ switchToPage(n: any): any;
12
+ flushPages(): void;
13
+ addNamedDestination(name: any, ...args: any[]): void;
14
+ addNamedEmbeddedFile(name: any, ref: any): void;
15
+ addNamedJavaScript(name: any, js: any): void;
16
+ ref(data: any): PDFReference;
17
+ _read(): void;
18
+ _write(data: any): void;
19
+ addContent(data: any): this;
20
+ _refEnd(ref: any): void;
21
+ end(): void;
22
+ _finalize(): void;
23
+ toString(): string;
24
+ }
25
+ export default PDFDocument;
@@ -0,0 +1,21 @@
1
+ declare class AFMFont {
2
+ /**
3
+ * @param {string} contents
4
+ */
5
+ constructor(contents: any);
6
+ /**
7
+ * @param {string} contents
8
+ */
9
+ parse(contents: any): void;
10
+ /**
11
+ * @param {string} text
12
+ * @returns
13
+ */
14
+ encodeText(text: any): any[];
15
+ glyphsForString(string: any): any[];
16
+ characterToGlyph(character: any): string;
17
+ widthOfGlyph(glyph: any): any;
18
+ getKernPair(left: any, right: any): any;
19
+ advancesForGlyphs(glyphs: any): any[];
20
+ }
21
+ export default AFMFont;
@@ -0,0 +1 @@
1
+ export declare const STANDARD_AFM_DATA: Record<string, string>;
@@ -0,0 +1,12 @@
1
+ import PDFFont from '../font';
2
+ declare class EmbeddedFont extends PDFFont {
3
+ constructor(document: any, font: any, id: any);
4
+ layoutRun(text: any, features: any): any;
5
+ layoutCached(text: any): any;
6
+ layout(text: any, features: any, onlyWidth: any): any;
7
+ encode(text: any, features: any): any[];
8
+ widthOfString(string: any, size: any, features: any): number;
9
+ embed(): any;
10
+ toUnicodeCmap(): any;
11
+ }
12
+ export default EmbeddedFont;
@@ -0,0 +1,12 @@
1
+ import PDFFont from '../font';
2
+ declare class StandardFont extends PDFFont {
3
+ constructor(document: any, name: any, id: any);
4
+ embed(): any;
5
+ encode(text: any): any[];
6
+ widthOfString(string: any, size: any): number;
7
+ static isStandardFont(name: any): boolean;
8
+ static registerAFM(name: any, afm: any): void;
9
+ static getAFM(name: any): any;
10
+ static preload(names?: string[]): Promise<void>;
11
+ }
12
+ export default StandardFont;
@@ -0,0 +1,10 @@
1
+ declare class PDFFont {
2
+ constructor();
3
+ encode(): void;
4
+ widthOfString(): void;
5
+ ref(): any;
6
+ finalize(): void;
7
+ embed(): void;
8
+ lineHeight(size: any, includeGap?: boolean): number;
9
+ }
10
+ export default PDFFont;
@@ -0,0 +1,6 @@
1
+ import StandardFont from './font/standard';
2
+ import EmbeddedFont from './font/embedded';
3
+ declare class PDFFontFactory {
4
+ static open(document: any, src: any, family: any, id: any): StandardFont | EmbeddedFont;
5
+ }
6
+ export default PDFFontFactory;
@@ -0,0 +1,23 @@
1
+ declare class PDFGradient {
2
+ constructor(doc: any);
3
+ stop(pos: any, color: any, opacity: any): this;
4
+ setTransform(m11: any, m12: any, m21: any, m22: any, dx: any, dy: any): this;
5
+ embed(m: any): any;
6
+ apply(stroke: any): any;
7
+ }
8
+ declare class PDFLinearGradient extends PDFGradient {
9
+ constructor(doc: any, x1: any, y1: any, x2: any, y2: any);
10
+ shader(fn: any): any;
11
+ opacityGradient(): PDFLinearGradient;
12
+ }
13
+ declare class PDFRadialGradient extends PDFGradient {
14
+ constructor(doc: any, x1: any, y1: any, r1: any, x2: any, y2: any, r2: any);
15
+ shader(fn: any): any;
16
+ opacityGradient(): PDFRadialGradient;
17
+ }
18
+ declare const _default: {
19
+ PDFGradient: typeof PDFGradient;
20
+ PDFLinearGradient: typeof PDFLinearGradient;
21
+ PDFRadialGradient: typeof PDFRadialGradient;
22
+ };
23
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare class JPEG {
2
+ constructor(data: any, label: any);
3
+ embed(document: any): any;
4
+ }
5
+ export default JPEG;
@@ -0,0 +1,9 @@
1
+ declare class PNGImage {
2
+ constructor(data: any, label: any);
3
+ embed(document: any): any;
4
+ finalize(): any;
5
+ splitAlphaChannel(): any;
6
+ loadIndexedAlphaChannel(): any;
7
+ decodeData(): void;
8
+ }
9
+ export default PNGImage;
@@ -0,0 +1,6 @@
1
+ import JPEG from './image/jpeg';
2
+ import PNG from './image/png';
3
+ declare class PDFImage {
4
+ static open(src: any, label: any): JPEG | PNG;
5
+ }
6
+ export default PDFImage;
@@ -0,0 +1,28 @@
1
+ // Ambient typings to make custom Jest matchers available to the TS language server in tests.
2
+ // No external @types packages required.
3
+
4
+ type PartialExceptTheseRequired<T, K extends keyof T> = Partial<T> &
5
+ Pick<Required<T>, K>;
6
+
7
+ declare global {
8
+ // Minimal shape of a TextStream used by tests' helpers
9
+ interface TextStream {
10
+ text: string;
11
+ font: string;
12
+ fontSize: number;
13
+ }
14
+
15
+ type TextStreamMatcher = PartialExceptTheseRequired<TextStream, 'text'>;
16
+
17
+ namespace jest {
18
+ interface Matchers<R> {
19
+ // Expect the PDF data array to contain a specific chunk sequence
20
+ toContainChunk(chunk: Array<string | RegExp>): R;
21
+
22
+ // Expect the PDF data array to contain a text stream matching the TextStream
23
+ toContainText(textStream: TextStreamMatcher): R;
24
+ }
25
+ }
26
+ }
27
+
28
+ export {};
@@ -0,0 +1,10 @@
1
+ import { EventEmitter } from 'events';
2
+ declare class LineWrapper extends EventEmitter {
3
+ constructor(document: any, options: any);
4
+ wordWidth(word: any): number;
5
+ canFit(word: any, w: any): boolean;
6
+ eachWord(text: any, fn: any): void;
7
+ wrap(text: any, options: any): void;
8
+ nextSection(options: any): boolean;
9
+ }
10
+ export default LineWrapper;
@@ -0,0 +1,9 @@
1
+ declare class PDFMetadata {
2
+ constructor();
3
+ _closeTags(): void;
4
+ append(xml: any, newline?: boolean): void;
5
+ getXML(): any;
6
+ getLength(): any;
7
+ end(): void;
8
+ }
9
+ export default PDFMetadata;
@@ -0,0 +1,48 @@
1
+ declare const _default: {
2
+ /**
3
+ * Must call if adding AcroForms to a document. Must also call font() before
4
+ * this method to set the default font.
5
+ */
6
+ initForm(): any;
7
+ /**
8
+ * Called automatically by document.js
9
+ */
10
+ endAcroForm(): any;
11
+ _endChild(ref: any): any;
12
+ /**
13
+ * Creates and adds a form field to the document. Form fields are intermediate
14
+ * nodes in a PDF form that are used to specify form name heirarchy and form
15
+ * value defaults.
16
+ * @param {string} name - field name (T attribute in field dictionary)
17
+ * @param {object} options - other attributes to include in field dictionary
18
+ */
19
+ formField(name: any, options?: {}): any;
20
+ /**
21
+ * Creates and adds a Form Annotation to the document. Form annotations are
22
+ * called Widget annotations internally within a PDF file.
23
+ * @param {string} name - form field name (T attribute of widget annotation
24
+ * dictionary)
25
+ * @param {number} x
26
+ * @param {number} y
27
+ * @param {number} w
28
+ * @param {number} h
29
+ * @param {object} options
30
+ */
31
+ formAnnotation(name: any, type: any, x: any, y: any, w: any, h: any, options?: {}): any;
32
+ formText(name: any, x: any, y: any, w: any, h: any, options?: {}): any;
33
+ formPushButton(name: any, x: any, y: any, w: any, h: any, options?: {}): any;
34
+ formCombo(name: any, x: any, y: any, w: any, h: any, options?: {}): any;
35
+ formList(name: any, x: any, y: any, w: any, h: any, options?: {}): any;
36
+ formRadioButton(name: any, x: any, y: any, w: any, h: any, options?: {}): any;
37
+ formCheckbox(name: any, x: any, y: any, w: any, h: any, options?: {}): any;
38
+ _addToParent(fieldRef: any): any;
39
+ _fieldDict(name: any, type: any, options?: {}): {};
40
+ _resolveType(type: any, opts: any): any;
41
+ _resolveFormat(opts: any): any;
42
+ _resolveColors(opts: any): any;
43
+ _resolveFlags(options: any): any;
44
+ _resolveJustify(options: any): any;
45
+ _resolveFont(options: any): any;
46
+ _resolveStrings(options: any): any;
47
+ };
48
+ export default _default;
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ annotate(x: any, y: any, w: any, h: any, options: any): any;
3
+ note(x: any, y: any, w: any, h: any, contents: any, options?: {}): any;
4
+ goTo(x: any, y: any, w: any, h: any, name: any, options?: {}): any;
5
+ link(x: any, y: any, w: any, h: any, url: any, options?: {}): any;
6
+ _markup(x: any, y: any, w: any, h: any, options?: {}): any;
7
+ highlight(x: any, y: any, w: any, h: any, options?: {}): any;
8
+ underline(x: any, y: any, w: any, h: any, options?: {}): any;
9
+ strike(x: any, y: any, w: any, h: any, options?: {}): any;
10
+ lineAnnotation(x1: any, y1: any, x2: any, y2: any, options?: {}): any;
11
+ rectAnnotation(x: any, y: any, w: any, h: any, options?: {}): any;
12
+ ellipseAnnotation(x: any, y: any, w: any, h: any, options?: {}): any;
13
+ textAnnotation(x: any, y: any, w: any, h: any, text: any, options?: {}): any;
14
+ fileAnnotation(x: any, y: any, w: any, h: any, file?: {}, options?: {}): any;
15
+ _convertRect(x1: any, y1: any, w: any, h: any): any[];
16
+ };
17
+ export default _default;
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ /**
3
+ * Embed contents of `src` in PDF
4
+ * @param {Buffer | ArrayBuffer | string} src input Buffer, ArrayBuffer, data: URI, or a key resolvable via the virtual FS
5
+ * @param {object} options
6
+ * * options.name: filename to be shown in PDF, will use `src` if none set
7
+ * * options.type: filetype to be shown in PDF
8
+ * * options.description: description to be shown in PDF
9
+ * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
10
+ * * options.creationDate: override creation date
11
+ * * options.modifiedDate: override modified date
12
+ * * options.relationship: Relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'.
13
+ * @returns filespec reference
14
+ */
15
+ file(src: any, options?: {}): any;
16
+ };
17
+ export default _default;
@@ -0,0 +1,39 @@
1
+ declare const _default: {
2
+ initColor(): void;
3
+ _normalizeColor(color: any): any;
4
+ _setColor(color: any, stroke: any): any;
5
+ _setColorCore(color: any, stroke: any): boolean;
6
+ _setColorSpace(space: any, stroke: any): any;
7
+ _getColorSpace(color: any): any;
8
+ fillColor(color: any, opacity: any): any;
9
+ strokeColor(color: any, opacity: any): any;
10
+ opacity(opacity: any): any;
11
+ fillOpacity(opacity: any): any;
12
+ strokeOpacity(opacity: any): any;
13
+ _doOpacity(fillOpacity: any, strokeOpacity: any): any;
14
+ linearGradient(x1: any, y1: any, x2: any, y2: any): {
15
+ shader(fn: any): any;
16
+ opacityGradient(): /*elided*/ any;
17
+ stop(pos: any, color: any, opacity: any): /*elided*/ any;
18
+ setTransform(m11: any, m12: any, m21: any, m22: any, dx: any, dy: any): /*elided*/ any;
19
+ embed(m: any): any;
20
+ apply(stroke: any): any;
21
+ };
22
+ radialGradient(x1: any, y1: any, r1: any, x2: any, y2: any, r2: any): {
23
+ shader(fn: any): any;
24
+ opacityGradient(): /*elided*/ any;
25
+ stop(pos: any, color: any, opacity: any): /*elided*/ any;
26
+ setTransform(m11: any, m12: any, m21: any, m22: any, dx: any, dy: any): /*elided*/ any;
27
+ embed(m: any): any;
28
+ apply(stroke: any): any;
29
+ };
30
+ pattern(bbox: any, xStep: any, yStep: any, stream: any): {
31
+ createPattern(): any;
32
+ embedPatternColorSpaces(): void;
33
+ getPatternColorSpaceId(underlyingColorspace: any): string;
34
+ embed(): void;
35
+ apply(stroke: any, patternColor: any): any;
36
+ };
37
+ addSpotColor(name: any, C: any, M: any, Y: any, K: any): any;
38
+ };
39
+ export default _default;