@f-o-t/pdf 0.1.0 → 0.1.4
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/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/objects.d.ts +42 -0
- package/dist/core/objects.d.ts.map +1 -0
- package/dist/errors.d.ts +58 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index-4jtcmpfh.js +48 -0
- package/dist/index-4jtcmpfh.js.map +10 -0
- package/dist/index-jsfksnj3.js +503 -0
- package/dist/index-jsfksnj3.js.map +14 -0
- package/dist/index-kjz7by1m.js +572 -0
- package/dist/index-kjz7by1m.js.map +13 -0
- package/dist/index.d.ts +7 -808
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +9 -0
- package/dist/plugins/generation/document.d.ts +38 -0
- package/dist/plugins/generation/document.d.ts.map +1 -0
- package/dist/plugins/generation/fonts.d.ts +59 -0
- package/dist/plugins/generation/fonts.d.ts.map +1 -0
- package/dist/plugins/generation/index.d.ts +5 -0
- package/dist/plugins/generation/index.d.ts.map +1 -0
- package/dist/plugins/generation/index.js +26 -0
- package/dist/plugins/generation/index.js.map +9 -0
- package/dist/plugins/generation/page.d.ts +56 -0
- package/dist/plugins/generation/page.d.ts.map +1 -0
- package/dist/plugins/generation/writer.d.ts +14 -0
- package/dist/plugins/generation/writer.d.ts.map +1 -0
- package/dist/plugins/parsing/index.d.ts +4 -0
- package/dist/plugins/parsing/index.d.ts.map +1 -0
- package/dist/plugins/parsing/index.js +16 -0
- package/dist/plugins/parsing/index.js.map +9 -0
- package/dist/plugins/parsing/lexer.d.ts +76 -0
- package/dist/plugins/parsing/lexer.d.ts.map +1 -0
- package/dist/plugins/parsing/parser.d.ts +63 -0
- package/dist/plugins/parsing/parser.d.ts.map +1 -0
- package/dist/plugins/parsing/reader.d.ts +66 -0
- package/dist/plugins/parsing/reader.d.ts.map +1 -0
- package/dist/schemas.d.ts +233 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/types.d.ts +123 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +27 -70
- package/dist/generation/index.d.ts +0 -268
- package/dist/generation/index.js +0 -26
- package/dist/parsing/index.d.ts +0 -234
- package/dist/parsing/index.js +0 -16
- package/dist/shared/chunk-10ftnz45.js +0 -572
- package/dist/shared/chunk-37mjkw9w.js +0 -492
- package/dist/shared/chunk-6dengthp.js +0 -48
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import {
|
|
2
3
|
CMYKColorSchema,
|
|
3
4
|
FONT_FAMILIES,
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
serializeObject,
|
|
27
28
|
serializeStream,
|
|
28
29
|
serializeValue
|
|
29
|
-
} from "./
|
|
30
|
+
} from "./index-jsfksnj3.js";
|
|
30
31
|
import {
|
|
31
32
|
FontNotFoundError,
|
|
32
33
|
InvalidImageError,
|
|
@@ -41,7 +42,7 @@ import {
|
|
|
41
42
|
PDFReader,
|
|
42
43
|
PDFSignatureError,
|
|
43
44
|
TokenType
|
|
44
|
-
} from "./
|
|
45
|
+
} from "./index-kjz7by1m.js";
|
|
45
46
|
import {
|
|
46
47
|
createArray,
|
|
47
48
|
createDictionary,
|
|
@@ -53,7 +54,7 @@ import {
|
|
|
53
54
|
isName,
|
|
54
55
|
isRef,
|
|
55
56
|
isStream
|
|
56
|
-
} from "./
|
|
57
|
+
} from "./index-4jtcmpfh.js";
|
|
57
58
|
export {
|
|
58
59
|
serializeValue,
|
|
59
60
|
serializeStream,
|
|
@@ -107,5 +108,4 @@ export {
|
|
|
107
108
|
CMYKColorSchema
|
|
108
109
|
};
|
|
109
110
|
|
|
110
|
-
//# debugId=
|
|
111
|
-
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFsKICBdLAogICJtYXBwaW5ncyI6ICIiLAogICJkZWJ1Z0lkIjogIkVFQ0ZEMDZGNTZENTk0RTU2NDc1NkUyMTY0NzU2RTIxIiwKICAibmFtZXMiOiBbXQp9
|
|
111
|
+
//# debugId=E6EDEA312D8C028864756E2164756E21
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PDFMetadata, PDFRef, PDFVersion } from "../../types.ts";
|
|
2
|
+
import { PDFPage } from "./page.ts";
|
|
3
|
+
export type PDFDocumentOptions = {
|
|
4
|
+
version?: PDFVersion;
|
|
5
|
+
metadata?: PDFMetadata;
|
|
6
|
+
};
|
|
7
|
+
export type { PDFPageOptions } from "./page.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Main PDF Document class for generation
|
|
10
|
+
*
|
|
11
|
+
* @property version - PDF version (1.4, 1.5, 1.6, or 1.7)
|
|
12
|
+
* @property metadata - Document metadata (title, author, etc.)
|
|
13
|
+
* @property catalog - Reference to the document catalog
|
|
14
|
+
* @property pages - Reference to the pages tree root
|
|
15
|
+
*/
|
|
16
|
+
export declare class PDFDocument {
|
|
17
|
+
version: PDFVersion;
|
|
18
|
+
metadata: PDFMetadata;
|
|
19
|
+
private objects;
|
|
20
|
+
private nextObjectNumber;
|
|
21
|
+
catalog: PDFRef;
|
|
22
|
+
pages: PDFRef;
|
|
23
|
+
private pagesArray;
|
|
24
|
+
constructor(options?: PDFDocumentOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Allocate a new object reference
|
|
27
|
+
*/
|
|
28
|
+
private allocateRef;
|
|
29
|
+
/**
|
|
30
|
+
* Add a page to the document
|
|
31
|
+
*/
|
|
32
|
+
addPage(options?: import("./page.ts").PDFPageOptions): PDFPage;
|
|
33
|
+
/**
|
|
34
|
+
* Save PDF to bytes
|
|
35
|
+
*/
|
|
36
|
+
save(): Uint8Array;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/plugins/generation/document.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAA4B,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,MAAM,kBAAkB,GAAG;IAC9B,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;;;GAOG;AACH,qBAAa,WAAW;IACrB,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,OAAO,CAAqD;IACpE,OAAO,CAAC,gBAAgB,CAAK;IAE7B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,UAAU,CAAiB;gBAEvB,OAAO,GAAE,kBAAuB;IAuC5C;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,WAAW,EAAE,cAAc,GAAG,OAAO;IAwB9D;;OAEG;IACH,IAAI,IAAI,UAAU;CAqEpB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF Standard 14 Fonts
|
|
3
|
+
* These fonts are guaranteed to be available in all PDF readers
|
|
4
|
+
*/
|
|
5
|
+
export declare const STANDARD_FONTS: {
|
|
6
|
+
readonly "Times-Roman": "Times-Roman";
|
|
7
|
+
readonly "Times-Bold": "Times-Bold";
|
|
8
|
+
readonly "Times-Italic": "Times-Italic";
|
|
9
|
+
readonly "Times-BoldItalic": "Times-BoldItalic";
|
|
10
|
+
readonly Helvetica: "Helvetica";
|
|
11
|
+
readonly "Helvetica-Bold": "Helvetica-Bold";
|
|
12
|
+
readonly "Helvetica-Oblique": "Helvetica-Oblique";
|
|
13
|
+
readonly "Helvetica-BoldOblique": "Helvetica-BoldOblique";
|
|
14
|
+
readonly Courier: "Courier";
|
|
15
|
+
readonly "Courier-Bold": "Courier-Bold";
|
|
16
|
+
readonly "Courier-Oblique": "Courier-Oblique";
|
|
17
|
+
readonly "Courier-BoldOblique": "Courier-BoldOblique";
|
|
18
|
+
readonly Symbol: "Symbol";
|
|
19
|
+
readonly ZapfDingbats: "ZapfDingbats";
|
|
20
|
+
};
|
|
21
|
+
export type StandardFont = keyof typeof STANDARD_FONTS;
|
|
22
|
+
/**
|
|
23
|
+
* Font families for convenience
|
|
24
|
+
*/
|
|
25
|
+
export declare const FONT_FAMILIES: {
|
|
26
|
+
times: {
|
|
27
|
+
regular: StandardFont;
|
|
28
|
+
bold: StandardFont;
|
|
29
|
+
italic: StandardFont;
|
|
30
|
+
boldItalic: StandardFont;
|
|
31
|
+
};
|
|
32
|
+
helvetica: {
|
|
33
|
+
regular: StandardFont;
|
|
34
|
+
bold: StandardFont;
|
|
35
|
+
oblique: StandardFont;
|
|
36
|
+
boldOblique: StandardFont;
|
|
37
|
+
};
|
|
38
|
+
courier: {
|
|
39
|
+
regular: StandardFont;
|
|
40
|
+
bold: StandardFont;
|
|
41
|
+
oblique: StandardFont;
|
|
42
|
+
boldOblique: StandardFont;
|
|
43
|
+
};
|
|
44
|
+
symbol: {
|
|
45
|
+
regular: StandardFont;
|
|
46
|
+
};
|
|
47
|
+
zapfDingbats: {
|
|
48
|
+
regular: StandardFont;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Check if a font is a standard PDF font
|
|
53
|
+
*/
|
|
54
|
+
export declare function isStandardFont(font: string): font is StandardFont;
|
|
55
|
+
/**
|
|
56
|
+
* Get font object reference name
|
|
57
|
+
*/
|
|
58
|
+
export declare function getFontRefName(font: StandardFont): string;
|
|
59
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../../src/plugins/generation/fonts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;CAsBjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,aAAa;;iBAEM,YAAY;cAChB,YAAY;gBACR,YAAY;oBACJ,YAAY;;;iBAGtB,YAAY;cACV,YAAY;iBACN,YAAY;qBACJ,YAAY;;;iBAG9B,YAAY;cACV,YAAY;iBACN,YAAY;qBACJ,YAAY;;;iBAG7B,YAAY;;;iBAGN,YAAY;;CAE5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,YAAY,CAEjE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/generation/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
FONT_FAMILIES,
|
|
4
|
+
PDFDocument,
|
|
5
|
+
PDFPage,
|
|
6
|
+
STANDARD_FONTS,
|
|
7
|
+
getFontRefName,
|
|
8
|
+
isStandardFont,
|
|
9
|
+
serializeObject,
|
|
10
|
+
serializeStream,
|
|
11
|
+
serializeValue
|
|
12
|
+
} from "../../index-jsfksnj3.js";
|
|
13
|
+
import"../../index-4jtcmpfh.js";
|
|
14
|
+
export {
|
|
15
|
+
serializeValue,
|
|
16
|
+
serializeStream,
|
|
17
|
+
serializeObject,
|
|
18
|
+
isStandardFont,
|
|
19
|
+
getFontRefName,
|
|
20
|
+
STANDARD_FONTS,
|
|
21
|
+
PDFPage,
|
|
22
|
+
PDFDocument,
|
|
23
|
+
FONT_FAMILIES
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# debugId=DF20C739FFE8F84E64756E2164756E21
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { PDFRef, PDFDictionary, PageSize, TextOptions, RectOptions, LineOptions, PDFStream } from "../../types.ts";
|
|
2
|
+
export type PDFPageOptions = {
|
|
3
|
+
size?: PageSize;
|
|
4
|
+
parent?: PDFRef;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* PDF Page class
|
|
8
|
+
*/
|
|
9
|
+
export declare class PDFPage {
|
|
10
|
+
ref: PDFRef;
|
|
11
|
+
size: PageSize;
|
|
12
|
+
parent?: PDFRef;
|
|
13
|
+
contentStream: string[];
|
|
14
|
+
private resources;
|
|
15
|
+
constructor(ref: PDFRef, options?: PDFPageOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Get page dimensions in points
|
|
18
|
+
*/
|
|
19
|
+
getDimensions(): {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Set fill color
|
|
25
|
+
*/
|
|
26
|
+
private setFillColor;
|
|
27
|
+
/**
|
|
28
|
+
* Set stroke color
|
|
29
|
+
*/
|
|
30
|
+
private setStrokeColor;
|
|
31
|
+
/**
|
|
32
|
+
* Draw text on the page
|
|
33
|
+
*/
|
|
34
|
+
drawText(text: string, options: TextOptions): void;
|
|
35
|
+
/**
|
|
36
|
+
* Draw a rectangle
|
|
37
|
+
*/
|
|
38
|
+
drawRectangle(options: RectOptions): void;
|
|
39
|
+
/**
|
|
40
|
+
* Draw a line
|
|
41
|
+
*/
|
|
42
|
+
drawLine(options: LineOptions): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get content stream reference
|
|
45
|
+
*/
|
|
46
|
+
getContentStreamRef(): PDFRef;
|
|
47
|
+
/**
|
|
48
|
+
* Generate content stream as PDFStream
|
|
49
|
+
*/
|
|
50
|
+
toContentStream(): PDFStream;
|
|
51
|
+
/**
|
|
52
|
+
* Convert page to PDF dictionary
|
|
53
|
+
*/
|
|
54
|
+
toDictionary(): PDFDictionary;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/plugins/generation/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAY,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAWlI,MAAM,MAAM,cAAc,GAAG;IAC1B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAYF;;GAEG;AACH,qBAAa,OAAO;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAM;IAC7B,OAAO,CAAC,SAAS,CAAgB;gBAErB,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IASrD;;OAEG;IACH,aAAa,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAOlD;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAoDlD;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAgCzC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAmBpC;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAK7B;;OAEG;IACH,eAAe,IAAI,SAAS;IAW5B;;OAEG;IACH,YAAY,IAAI,aAAa;CAe/B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PDFValue, PDFStream } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Serialize a PDF value to string
|
|
4
|
+
*/
|
|
5
|
+
export declare function serializeValue(value: PDFValue): string;
|
|
6
|
+
/**
|
|
7
|
+
* Serialize a PDF stream
|
|
8
|
+
*/
|
|
9
|
+
export declare function serializeStream(stream: PDFStream): Uint8Array;
|
|
10
|
+
/**
|
|
11
|
+
* Serialize an indirect object
|
|
12
|
+
*/
|
|
13
|
+
export declare function serializeObject(objectNumber: number, generation: number, value: any): Uint8Array;
|
|
14
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/plugins/generation/writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAyB,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAEpG;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAiCtD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAY7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,UAAU,CAkBhG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/parsing/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
PDFLexer,
|
|
4
|
+
PDFParser,
|
|
5
|
+
PDFReader,
|
|
6
|
+
TokenType
|
|
7
|
+
} from "../../index-kjz7by1m.js";
|
|
8
|
+
import"../../index-4jtcmpfh.js";
|
|
9
|
+
export {
|
|
10
|
+
TokenType,
|
|
11
|
+
PDFReader,
|
|
12
|
+
PDFParser,
|
|
13
|
+
PDFLexer
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# debugId=82E5A7702555144564756E2164756E21
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF token types
|
|
3
|
+
*/
|
|
4
|
+
export declare enum TokenType {
|
|
5
|
+
NUMBER = "NUMBER",
|
|
6
|
+
STRING = "STRING",
|
|
7
|
+
NAME = "NAME",
|
|
8
|
+
BOOLEAN = "BOOLEAN",
|
|
9
|
+
NULL = "NULL",
|
|
10
|
+
ARRAY_START = "ARRAY_START",// [
|
|
11
|
+
ARRAY_END = "ARRAY_END",// ]
|
|
12
|
+
DICT_START = "DICT_START",// <<
|
|
13
|
+
DICT_END = "DICT_END",// >>
|
|
14
|
+
OBJ = "OBJ",// obj
|
|
15
|
+
ENDOBJ = "ENDOBJ",// endobj
|
|
16
|
+
STREAM = "STREAM",// stream
|
|
17
|
+
ENDSTREAM = "ENDSTREAM",// endstream
|
|
18
|
+
XREF = "XREF",// xref
|
|
19
|
+
TRAILER = "TRAILER",// trailer
|
|
20
|
+
STARTXREF = "STARTXREF",// startxref
|
|
21
|
+
R = "R",// R (reference)
|
|
22
|
+
EOF = "EOF"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* PDF token
|
|
26
|
+
*/
|
|
27
|
+
export interface Token {
|
|
28
|
+
type: TokenType;
|
|
29
|
+
value: any;
|
|
30
|
+
position: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* PDF Lexer
|
|
34
|
+
*/
|
|
35
|
+
export declare class PDFLexer {
|
|
36
|
+
private data;
|
|
37
|
+
private position;
|
|
38
|
+
constructor(data: Uint8Array);
|
|
39
|
+
/**
|
|
40
|
+
* Get next token
|
|
41
|
+
*/
|
|
42
|
+
nextToken(): Token;
|
|
43
|
+
/**
|
|
44
|
+
* Peek at next character without consuming
|
|
45
|
+
*/
|
|
46
|
+
private peek;
|
|
47
|
+
/**
|
|
48
|
+
* Skip whitespace and comments
|
|
49
|
+
*/
|
|
50
|
+
private skipWhitespace;
|
|
51
|
+
/**
|
|
52
|
+
* Read a name token
|
|
53
|
+
*/
|
|
54
|
+
private readName;
|
|
55
|
+
/**
|
|
56
|
+
* Read a string token
|
|
57
|
+
*/
|
|
58
|
+
private readString;
|
|
59
|
+
/**
|
|
60
|
+
* Read a number token
|
|
61
|
+
*/
|
|
62
|
+
private readNumber;
|
|
63
|
+
/**
|
|
64
|
+
* Read a keyword token
|
|
65
|
+
*/
|
|
66
|
+
private readKeyword;
|
|
67
|
+
/**
|
|
68
|
+
* Check if character is delimiter
|
|
69
|
+
*/
|
|
70
|
+
private isDelimiter;
|
|
71
|
+
/**
|
|
72
|
+
* Check if byte is whitespace
|
|
73
|
+
*/
|
|
74
|
+
private isWhitespace;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=lexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../../src/plugins/parsing/lexer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,SAAS;IAElB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,IAAI,SAAS;IAGb,WAAW,gBAAgB,CAAM,IAAI;IACrC,SAAS,cAAc,CAAU,IAAI;IACrC,UAAU,eAAe,CAAQ,KAAK;IACtC,QAAQ,aAAa,CAAY,KAAK;IAGtC,GAAG,QAAQ,CAAsB,MAAM;IACvC,MAAM,WAAW,CAAgB,SAAS;IAC1C,MAAM,WAAW,CAAgB,SAAS;IAC1C,SAAS,cAAc,CAAU,YAAY;IAC7C,IAAI,SAAS,CAAoB,OAAO;IACxC,OAAO,YAAY,CAAc,UAAU;IAC3C,SAAS,cAAc,CAAU,YAAY;IAC7C,CAAC,MAAM,CAA0B,gBAAgB;IAGjD,GAAG,QAAQ;CACb;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,QAAQ;IAClB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,QAAQ,CAAa;gBAEjB,IAAI,EAAE,UAAU;IAI5B;;OAEG;IACH,SAAS,IAAI,KAAK;IA8ClB;;OAEG;IACH,OAAO,CAAC,IAAI;IAKZ;;OAEG;IACH,OAAO,CAAC,cAAc;IAsBtB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAiBhB;;OAEG;IACH,OAAO,CAAC,UAAU;IAiClB;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB;;OAEG;IACH,OAAO,CAAC,WAAW;IA+BnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,YAAY;CAGtB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PDFValue, PDFRef } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* PDF Parser
|
|
4
|
+
*/
|
|
5
|
+
export declare class PDFParser {
|
|
6
|
+
private lexer;
|
|
7
|
+
private currentToken;
|
|
8
|
+
private nextToken;
|
|
9
|
+
private data;
|
|
10
|
+
constructor(data: Uint8Array);
|
|
11
|
+
/**
|
|
12
|
+
* Parse a PDF value
|
|
13
|
+
*/
|
|
14
|
+
parseValue(): PDFValue;
|
|
15
|
+
/**
|
|
16
|
+
* Parse number or reference (number number R)
|
|
17
|
+
*/
|
|
18
|
+
private parseNumberOrRef;
|
|
19
|
+
/**
|
|
20
|
+
* Parse string
|
|
21
|
+
*/
|
|
22
|
+
private parseString;
|
|
23
|
+
/**
|
|
24
|
+
* Parse name
|
|
25
|
+
*/
|
|
26
|
+
private parseName;
|
|
27
|
+
/**
|
|
28
|
+
* Parse boolean
|
|
29
|
+
*/
|
|
30
|
+
private parseBoolean;
|
|
31
|
+
/**
|
|
32
|
+
* Parse null
|
|
33
|
+
*/
|
|
34
|
+
private parseNull;
|
|
35
|
+
/**
|
|
36
|
+
* Parse array
|
|
37
|
+
*/
|
|
38
|
+
private parseArray;
|
|
39
|
+
/**
|
|
40
|
+
* Parse dictionary
|
|
41
|
+
*/
|
|
42
|
+
private parseDictionary;
|
|
43
|
+
/**
|
|
44
|
+
* Parse indirect object
|
|
45
|
+
*/
|
|
46
|
+
parseIndirectObject(): {
|
|
47
|
+
ref: PDFRef;
|
|
48
|
+
value: PDFValue;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Parse stream (dictionary already parsed)
|
|
52
|
+
*/
|
|
53
|
+
private parseStream;
|
|
54
|
+
/**
|
|
55
|
+
* Advance to next token
|
|
56
|
+
*/
|
|
57
|
+
private advance;
|
|
58
|
+
/**
|
|
59
|
+
* Check if more tokens available
|
|
60
|
+
*/
|
|
61
|
+
hasMore(): boolean;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/plugins/parsing/parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAA2B,MAAM,EAAa,MAAM,gBAAgB,CAAC;AAG3F;;GAEG;AACH,qBAAa,SAAS;IACnB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,IAAI,CAAa;gBAEb,IAAI,EAAE,UAAU;IAM5B;;OAEG;IACH,UAAU,IAAI,QAAQ;IAqBtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,SAAS;IAMjB;;OAEG;IACH,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,OAAO,CAAC,UAAU;IAelB;;OAEG;IACH,OAAO,CAAC,eAAe;IAyBvB;;OAEG;IACH,mBAAmB,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,QAAQ,CAAA;KAAE;IAuCvD;;OAEG;IACH,OAAO,CAAC,WAAW;IA6CnB;;OAEG;IACH,OAAO,CAAC,OAAO;IASf;;OAEG;IACH,OAAO,IAAI,OAAO;CAGpB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PDFRef } from "../../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Parsed PDF Document
|
|
4
|
+
*/
|
|
5
|
+
export interface ParsedPDF {
|
|
6
|
+
version: string;
|
|
7
|
+
catalog: PDFRef;
|
|
8
|
+
pages: ParsedPDFPage[];
|
|
9
|
+
objects: Map<number, any>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parsed PDF Page
|
|
13
|
+
*/
|
|
14
|
+
export interface ParsedPDFPage {
|
|
15
|
+
ref: PDFRef;
|
|
16
|
+
size: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
content: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* PDF Reader - reads and parses existing PDFs
|
|
24
|
+
*/
|
|
25
|
+
export declare class PDFReader {
|
|
26
|
+
private data;
|
|
27
|
+
private objects;
|
|
28
|
+
constructor(data: Uint8Array);
|
|
29
|
+
/**
|
|
30
|
+
* Parse PDF file
|
|
31
|
+
*/
|
|
32
|
+
parse(): ParsedPDF;
|
|
33
|
+
/**
|
|
34
|
+
* Find startxref offset
|
|
35
|
+
*/
|
|
36
|
+
private findStartXRef;
|
|
37
|
+
/**
|
|
38
|
+
* Parse xref table
|
|
39
|
+
*/
|
|
40
|
+
private parseXRefTable;
|
|
41
|
+
/**
|
|
42
|
+
* Parse trailer dictionary
|
|
43
|
+
*/
|
|
44
|
+
private parseTrailer;
|
|
45
|
+
/**
|
|
46
|
+
* Read all objects from xref table
|
|
47
|
+
*/
|
|
48
|
+
private readObjects;
|
|
49
|
+
/**
|
|
50
|
+
* Parse PDF version from header
|
|
51
|
+
*/
|
|
52
|
+
private parseVersion;
|
|
53
|
+
/**
|
|
54
|
+
* Parse pages from catalog
|
|
55
|
+
*/
|
|
56
|
+
private parsePages;
|
|
57
|
+
/**
|
|
58
|
+
* Parse a single page
|
|
59
|
+
*/
|
|
60
|
+
private parsePage;
|
|
61
|
+
/**
|
|
62
|
+
* Extract text from content stream
|
|
63
|
+
*/
|
|
64
|
+
private extractText;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/plugins/parsing/reader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,MAAM,EAAY,MAAM,gBAAgB,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,SAAS;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,SAAS;IACnB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,OAAO,CAA+B;gBAElC,IAAI,EAAE,UAAU;IAI5B;;OAEG;IACH,KAAK,IAAI,SAAS;IA0BlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAqCtB;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAanB;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,UAAU;IAyBlB;;OAEG;IACH,OAAO,CAAC,SAAS;IAoBjB;;OAEG;IACH,OAAO,CAAC,WAAW;CAiBrB"}
|