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,19 @@
1
+ declare const _default: {
2
+ initFonts(defaultFont?: string, defaultFontFamily?: any, defaultFontSize?: number): void;
3
+ font(src: any, family: any, size: any): any;
4
+ fontSize(_fontSize: any): any;
5
+ currentLineHeight(includeGap: any): any;
6
+ registerFont(name: any, src: any, family: any): any;
7
+ /**
8
+ * Convert a {@link Size} into a point measurement
9
+ *
10
+ * @param {Size | boolean | undefined} size - The size to convert
11
+ * @param {Size | boolean | undefined} defaultValue - The default value when undefined
12
+ * @param {PDFPage} page - The page used for computing font sizes
13
+ * @param {number} [percentageWidth] - The value to use for computing size based on `%`
14
+ *
15
+ * @returns number
16
+ */
17
+ sizeToPoint(size: any, defaultValue?: number, page?: any, percentageWidth?: any): number;
18
+ };
19
+ export default _default;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ initImages(): void;
3
+ image(src: any, x: any, y: any, options?: {}): any;
4
+ openImage(src: any): any;
5
+ };
6
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import PDFStructureElement from '../structure_element';
2
+ import PDFStructureContent from '../structure_content';
3
+ declare const _default: {
4
+ initMarkings(options: any): void;
5
+ markContent(tag: any, options?: any): any;
6
+ markStructureContent(tag: any, options?: {}): PDFStructureContent;
7
+ endMarkedContent(): any;
8
+ struct(type: any, options?: {}, children?: any): PDFStructureElement;
9
+ addStructure(structElem: any): any;
10
+ initPageMarkings(pageMarkings: any): void;
11
+ endPageMarkings(page: any): any;
12
+ getMarkInfoDictionary(): any;
13
+ hasMarkInfoDictionary(): boolean;
14
+ getStructTreeRoot(): any;
15
+ getStructParentTree(): any;
16
+ createStructParentTreeNextKey(): number;
17
+ endMarkings(): void;
18
+ };
19
+ export default _default;
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ initMetadata(): void;
3
+ appendXML(xml: any, newline?: boolean): void;
4
+ _addInfo(): void;
5
+ endMetadata(): void;
6
+ };
7
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ initOutline(): void;
3
+ endOutline(): any;
4
+ };
5
+ export default _default;
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ initPDFA(pSubset: any): void;
3
+ endSubset(): void;
4
+ _addColorOutputIntent(): void;
5
+ _getPdfaid(): string;
6
+ _addPdfaMetadata(): void;
7
+ setPDFAIccProfile(iccProfile: any): any;
8
+ };
9
+ export default _default;
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ initPDFUA(): void;
3
+ endSubset(): void;
4
+ _addPdfuaMetadata(): void;
5
+ _getPdfuaid(): string;
6
+ };
7
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ _importSubset(subset: any): void;
3
+ initSubset(options: any): void;
4
+ };
5
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import PDFTable from '../table/index';
2
+ declare const _default: {
3
+ initTables(): void;
4
+ /**
5
+ * @param {Table} [opts]
6
+ * @returns {PDFTable} returns the table object unless `data` is set,
7
+ * then it returns the underlying document
8
+ */
9
+ table(opts: any): PDFTable;
10
+ };
11
+ export default _default;
@@ -0,0 +1,31 @@
1
+ declare const _default: {
2
+ initText(): void;
3
+ lineGap(_lineGap: any): any;
4
+ moveDown(lines: any): any;
5
+ moveUp(lines: any): any;
6
+ _text(text: any, x: any, y: any, options: any, lineCallback: any): any;
7
+ text(text: any, x: any, y: any, options: any): any;
8
+ widthOfString(string: any, options?: {}): number;
9
+ /**
10
+ * Compute the bounding box of a string
11
+ * based on what will actually be rendered by `doc.text()`
12
+ *
13
+ * @param string - The string
14
+ * @param x - X position of text (defaults to this.x)
15
+ * @param y - Y position of text (defaults to this.y)
16
+ * @param options - Any text options (The same you would apply to `doc.text()`)
17
+ * @returns {{x: number, y: number, width: number, height: number}}
18
+ */
19
+ boundsOfString(string: any, x: any, y: any, options: any): {
20
+ x: any;
21
+ y: any;
22
+ width: number;
23
+ height: number;
24
+ };
25
+ heightOfString(text: any, options: any): number;
26
+ list(list: any, x: any, y: any, options: any): any;
27
+ _initOptions(x: {}, y: any, options?: {}): {};
28
+ _line(text: any, options: {}, wrapper: any): void;
29
+ _fragment(text: any, x: any, y: any, options: any): void;
30
+ };
31
+ export default _default;
@@ -0,0 +1,43 @@
1
+ declare const _default: {
2
+ initVector(): void;
3
+ save(): any;
4
+ restore(): any;
5
+ closePath(): any;
6
+ lineWidth(w: any): any;
7
+ _CAP_STYLES: {
8
+ BUTT: number;
9
+ ROUND: number;
10
+ SQUARE: number;
11
+ };
12
+ lineCap(c: any): any;
13
+ _JOIN_STYLES: {
14
+ MITER: number;
15
+ ROUND: number;
16
+ BEVEL: number;
17
+ };
18
+ lineJoin(j: any): any;
19
+ miterLimit(m: any): any;
20
+ dash(length: any, options?: {}): any;
21
+ undash(): any;
22
+ moveTo(x: any, y: any): any;
23
+ lineTo(x: any, y: any): any;
24
+ bezierCurveTo(cp1x: any, cp1y: any, cp2x: any, cp2y: any, x: any, y: any): any;
25
+ quadraticCurveTo(cpx: any, cpy: any, x: any, y: any): any;
26
+ rect(x: any, y: any, w: any, h: any): any;
27
+ roundedRect(x: any, y: any, w: any, h: any, r: any): any;
28
+ ellipse(x: any, y: any, r1: any, r2: any): any;
29
+ circle(x: any, y: any, radius: any): any;
30
+ arc(x: any, y: any, radius: any, startAngle: any, endAngle: any, anticlockwise: any): any;
31
+ polygon(...points: any[]): any;
32
+ path(path: any): any;
33
+ _windingRule(rule: any): "" | "*";
34
+ fill(color: any, rule: any): any;
35
+ stroke(color: any): any;
36
+ fillAndStroke(fillColor: any, strokeColor: any, rule: any): any;
37
+ clip(rule: any): any;
38
+ transform(m11: any, m12: any, m21: any, m22: any, dx: any, dy: any): any;
39
+ translate(x: any, y: any): any;
40
+ rotate(angle: any, options?: {}): any;
41
+ scale(xFactor: any, yFactor: any, options?: {}): any;
42
+ };
43
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import PDFTree from './tree';
2
+ declare class PDFNameTree extends PDFTree {
3
+ _compareKeys(a: any, b: any): any;
4
+ _keysName(): string;
5
+ _dataForKey(k: any): String;
6
+ }
7
+ export default PDFNameTree;
@@ -0,0 +1,7 @@
1
+ import PDFTree from './tree';
2
+ declare class PDFNumberTree extends PDFTree {
3
+ _compareKeys(a: any, b: any): number;
4
+ _keysName(): string;
5
+ _dataForKey(k: any): number;
6
+ }
7
+ export default PDFNumberTree;
@@ -0,0 +1,5 @@
1
+ declare class PDFObject {
2
+ static convert(object: any, encryptFn?: any): any;
3
+ static number(n: any): number;
4
+ }
5
+ export default PDFObject;
@@ -0,0 +1,20 @@
1
+ declare class PDFOutline {
2
+ constructor(document: any, parent: any, title: any, dest: any, options?: {
3
+ top: number;
4
+ left: number;
5
+ zoom: number;
6
+ fit: boolean;
7
+ pageNumber: any;
8
+ expanded: boolean;
9
+ });
10
+ addItem(title: any, options?: {
11
+ top: number;
12
+ left: number;
13
+ zoom: number;
14
+ fit: boolean;
15
+ pageNumber: any;
16
+ expanded: boolean;
17
+ }): PDFOutline;
18
+ endOutline(): any;
19
+ }
20
+ export default PDFOutline;
@@ -0,0 +1,27 @@
1
+ declare class PDFPage {
2
+ constructor(document: any, options?: {});
3
+ get fonts(): any;
4
+ get xobjects(): any;
5
+ get ext_gstates(): any;
6
+ get patterns(): any;
7
+ get colorSpaces(): any;
8
+ get annotations(): any;
9
+ get structParentTreeKey(): any;
10
+ /**
11
+ * The width of the safe contents of a page
12
+ *
13
+ * @returns {number}
14
+ */
15
+ get contentWidth(): number;
16
+ /**
17
+ * The height of the safe contents of a page
18
+ *
19
+ * @returns {number}
20
+ */
21
+ get contentHeight(): number;
22
+ maxY(): number;
23
+ write(chunk: any): any;
24
+ _setTabOrder(): void;
25
+ end(): any;
26
+ }
27
+ export default PDFPage;
@@ -0,0 +1,4 @@
1
+ declare class SVGPath {
2
+ static apply(doc: any, path: any): void;
3
+ }
4
+ export default SVGPath;
@@ -0,0 +1,12 @@
1
+ declare class PDFTilingPattern {
2
+ constructor(doc: any, bBox: any, xStep: any, yStep: any, stream: any);
3
+ createPattern(): any;
4
+ embedPatternColorSpaces(): void;
5
+ getPatternColorSpaceId(underlyingColorspace: any): string;
6
+ embed(): void;
7
+ apply(stroke: any, patternColor: any): any;
8
+ }
9
+ declare const _default: {
10
+ PDFTilingPattern: typeof PDFTilingPattern;
11
+ };
12
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import PDFAbstractReference from './abstract_reference';
2
+ declare class PDFReference extends PDFAbstractReference {
3
+ constructor(document: any, id: any, data?: {});
4
+ write(chunk: any): void;
5
+ end(chunk: any): void;
6
+ finalize(): void;
7
+ toString(): string;
8
+ }
9
+ export default PDFReference;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SASLprep.
3
+ * @param {string} input
4
+ * @param {Object} opts
5
+ * @param {boolean} opts.allowUnassigned
6
+ * @returns {string}
7
+ */
8
+ declare function saslprep(input: any, opts?: {}): any;
9
+ export default saslprep;
@@ -0,0 +1,12 @@
1
+ declare class PDFSecurity {
2
+ static generateFileID(info?: {}): Buffer<ArrayBuffer>;
3
+ static generateRandomWordArray(bytes: any): Uint8Array<any>;
4
+ static create(document: any, options?: {}): PDFSecurity;
5
+ constructor(document: any, options?: {});
6
+ _setupEncryption(options: any): void;
7
+ _setupEncryptionV1V2V4(v: any, encDict: any, options: any): void;
8
+ _setupEncryptionV5(encDict: any, options: any): void;
9
+ getEncryptFn(obj: any, gen: any): (buffer: any) => Buffer<ArrayBuffer>;
10
+ end(): void;
11
+ }
12
+ export default PDFSecurity;
@@ -0,0 +1,4 @@
1
+ export default class SpotColor {
2
+ constructor(doc: any, name: any, C: any, M: any, Y: any, K: any);
3
+ toString(): string;
4
+ }
@@ -0,0 +1,4 @@
1
+ declare class PDFAnnotationReference {
2
+ constructor(annotationRef: any);
3
+ }
4
+ export default PDFAnnotationReference;
@@ -0,0 +1,5 @@
1
+ declare class PDFStructureContent {
2
+ constructor(pageRef: any, mcid: any);
3
+ push(structContent: any): void;
4
+ }
5
+ export default PDFStructureContent;
@@ -0,0 +1,15 @@
1
+ declare class PDFStructureElement {
2
+ constructor(document: any, type: any, options?: {}, children?: any);
3
+ add(child: any): this;
4
+ _addContentToParentTree(content: any): void;
5
+ _addAnnotationToParentTree(annotRef: any): void;
6
+ setParent(parentRef: any): void;
7
+ setAttached(): void;
8
+ end(): void;
9
+ _isValidChild(child: any): boolean;
10
+ _contentForClosure(closure: any): any;
11
+ _isFlushable(): any;
12
+ _flush(): void;
13
+ _flushChild(child: any): void;
14
+ }
15
+ export default PDFStructureElement;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Add accessibility to a table
3
+ *
4
+ * @this PDFTable
5
+ * @memberOf PDFTable
6
+ * @private
7
+ */
8
+ export declare function accommodateTable(): void;
9
+ /**
10
+ * Cleanup accessibility on a table
11
+ *
12
+ * @this PDFTable
13
+ * @memberOf PDFTable
14
+ * @private
15
+ */
16
+ export declare function accommodateCleanup(): void;
17
+ /**
18
+ * Render a row with all its accessibility features
19
+ *
20
+ * @this PDFTable
21
+ * @memberOf PDFTable
22
+ * @param {SizedNormalizedTableCellStyle[]} row
23
+ * @param {number} rowIndex
24
+ * @param {Function} renderCell
25
+ * @private
26
+ */
27
+ export declare function accessibleRow(row: any, rowIndex: any, renderCell: any): void;
28
+ /**
29
+ * Render a cell with all its accessibility features
30
+ *
31
+ * @this PDFTable
32
+ * @memberOf PDFTable
33
+ * @param {SizedNormalizedTableCellStyle} cell
34
+ * @param {PDFStructureElement} rowStruct
35
+ * @param {Function} callback
36
+ * @private
37
+ */
38
+ export declare function accessibleCell(cell: any, rowStruct: any, callback: any): void;
@@ -0,0 +1,23 @@
1
+ declare class PDFTable {
2
+ /**
3
+ * @param {PDFDocument} document
4
+ * @param {Table} [opts]
5
+ */
6
+ constructor(document: any, opts?: {});
7
+ /**
8
+ * Render a new row in the table
9
+ *
10
+ * @param {Iterable<TableCell>} row - The cells to render
11
+ * @param {boolean} lastRow - Whether this row is the last row
12
+ * @returns {this} returns the table, unless lastRow is `true` then returns the `PDFDocument`
13
+ */
14
+ row(row: any, lastRow?: boolean): any;
15
+ /**
16
+ * Indicates to the table that it is finished,
17
+ * allowing the table to flush its cell buffer (which should be empty unless there is rowSpans)
18
+ *
19
+ * @returns {PDFDocument} the document
20
+ */
21
+ end(): any;
22
+ }
23
+ export default PDFTable;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Normalize a table
3
+ *
4
+ * @this PDFTable
5
+ * @memberOf PDFTable
6
+ * @private
7
+ */
8
+ export declare function normalizeTable(): void;
9
+ /**
10
+ * Convert text into a string
11
+ * - null and undefined are preserved (as they will be ignored)
12
+ * - everything else is run through `String()`
13
+ *
14
+ * @param {*} text
15
+ * @returns {string}
16
+ * @private
17
+ */
18
+ export declare function normalizeText(text: any): any;
19
+ /**
20
+ * Normalize a cell config
21
+ *
22
+ * @this PDFTable
23
+ * @memberOf PDFTable
24
+ * @param {TableCellStyle} cell - The cell to mutate
25
+ * @param {number} rowIndex - The cells row
26
+ * @param {number} colIndex - The cells column
27
+ * @returns {NormalizedTableCellStyle}
28
+ * @private
29
+ */
30
+ export declare function normalizeCell(cell: any, rowIndex: any, colIndex: any): any;
31
+ /**
32
+ * Normalize a row
33
+ *
34
+ * @this PDFTable
35
+ * @memberOf PDFTable
36
+ * @param {TableCell[]} row
37
+ * @param {number} rowIndex
38
+ * @returns {NormalizedTableCellStyle[]}
39
+ * @private
40
+ */
41
+ export declare function normalizeRow(row: any, rowIndex: any): any;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Render a cell
3
+ *
4
+ * @this PDFTable
5
+ * @memberOf PDFTable
6
+ * @param {SizedNormalizedTableCellStyle[]} row
7
+ * @param {number} rowIndex
8
+ * @private
9
+ */
10
+ export declare function renderRow(row: any, rowIndex: any): any;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Compute the widths of the columns, ensuring to distribute the star widths
3
+ *
4
+ * @this PDFTable
5
+ * @memberOf PDFTable
6
+ * @param {NormalizedTableCellStyle[]} row
7
+ * @private
8
+ */
9
+ export declare function ensure(row: any): void;
10
+ /**
11
+ * Compute the dimensions of the cells
12
+ *
13
+ * @this PDFTable
14
+ * @memberOf PDFTable
15
+ * @param {NormalizedTableCellStyle[]} row
16
+ * @param {number} rowIndex
17
+ * @returns {{newPage: boolean, toRender: SizedNormalizedTableCellStyle[]}}
18
+ * @private
19
+ */
20
+ export declare function measure(row: any, rowIndex: any): {
21
+ newPage: boolean;
22
+ toRender: any[];
23
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Normalize the row config
3
+ * @note The context here is the cell not the document
4
+ *
5
+ * @param {DefaultTableCell} [defaultStyleInternal]
6
+ * @returns {{
7
+ * defaultStyle: TableCellStyle,
8
+ * defaultRowStyle: RowStyle,
9
+ * defaultColStyle: ColumnStyle
10
+ * }}
11
+ * @private
12
+ */
13
+ export declare function normalizedDefaultStyle(defaultStyleInternal: any): {
14
+ defaultStyle: any;
15
+ defaultRowStyle: {
16
+ [k: string]: unknown;
17
+ };
18
+ defaultColStyle: {
19
+ [k: string]: unknown;
20
+ };
21
+ };
22
+ /**
23
+ * Normalize the row config
24
+ *
25
+ * @note The context here is the cell not the document
26
+ *
27
+ * @this PDFTable
28
+ * @memberOf PDFTable
29
+ * @param {RowStyle} defaultRowStyle
30
+ * @param {Dynamic<Row>} rowStyleInternal
31
+ * @param {number} i The target row
32
+ * @returns {NormalizedRowStyle}
33
+ * @private
34
+ */
35
+ export declare function normalizedRowStyle(defaultRowStyle: any, rowStyleInternal: any, i: any): any;
36
+ /**
37
+ * Normalize the column config
38
+ *
39
+ * @note The context here is the document not the cell
40
+ *
41
+ * @param {ColumnStyle} defaultColStyle
42
+ * @param {Dynamic<Column>} colStyleInternal
43
+ * @param {number} i - The target column
44
+ * @returns {NormalizedColumnStyle}
45
+ * @private
46
+ */
47
+ export declare function normalizedColumnStyle(defaultColStyle: any, colStyleInternal: any, i: any): any;
48
+ export declare function normalizeAlignment(align: any): any;