officeparser 6.0.7 → 6.1.0
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/README.md +92 -13
- package/dist/OfficeParser.d.ts +10 -1
- package/dist/OfficeParser.js +43 -56
- package/dist/cli.d.ts +20 -0
- package/dist/cli.js +116 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -59
- package/dist/index.mjs +18 -0
- package/dist/officeparser.browser.d.ts +79 -1
- package/dist/officeparser.browser.iife.js +112 -0
- package/dist/officeparser.browser.mjs +111 -0
- package/dist/parsers/ExcelParser.d.ts +1 -1
- package/dist/parsers/ExcelParser.js +71 -63
- package/dist/parsers/OpenOfficeParser.d.ts +1 -1
- package/dist/parsers/OpenOfficeParser.js +131 -114
- package/dist/parsers/PdfParser.d.ts +1 -1
- package/dist/parsers/PdfParser.js +98 -94
- package/dist/parsers/PowerPointParser.d.ts +1 -1
- package/dist/parsers/PowerPointParser.js +85 -88
- package/dist/parsers/RtfParser.d.ts +1 -1
- package/dist/parsers/RtfParser.js +10 -6
- package/dist/parsers/WordParser.d.ts +1 -1
- package/dist/parsers/WordParser.js +109 -101
- package/dist/sbom.cdx.json +1807 -0
- package/dist/types.d.ts +69 -1
- package/dist/utils/chartUtils.js +2 -0
- package/dist/utils/dateUtils.d.ts +17 -0
- package/dist/utils/dateUtils.js +69 -0
- package/dist/utils/envUtils.d.ts +24 -0
- package/dist/utils/envUtils.js +69 -0
- package/dist/utils/moduleLoader.d.ts +2 -1
- package/dist/utils/moduleLoader.js +9 -39
- package/dist/utils/ocrUtils.d.ts +16 -12
- package/dist/utils/ocrUtils.js +186 -25
- package/dist/utils/xmlUtils.d.ts +80 -9
- package/dist/utils/xmlUtils.js +236 -18
- package/dist/utils/zipUtils.js +6 -47
- package/package.json +31 -16
- package/dist/officeParserBundle@6.0.7.js +0 -154
- package/dist/officeparser.browser.js +0 -154
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for OCR.
|
|
5
|
+
*/
|
|
6
|
+
export interface OcrConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Language for OCR.
|
|
9
|
+
* Default is 'eng'.
|
|
10
|
+
*
|
|
11
|
+
* You can provide multiple languages separated by a `+` sign (e.g., 'eng+fra' for English and French).
|
|
12
|
+
* The OCR engine will then attempt to recognize text in any of the specified languages.
|
|
13
|
+
*
|
|
14
|
+
* See the list of supported languages and their codes here:
|
|
15
|
+
* https://tesseract-ocr.github.io/tessdoc/Data-Files#data-files-for-version-400-november-29-2016
|
|
16
|
+
*/
|
|
17
|
+
language?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Path to the Tesseract worker script.
|
|
20
|
+
* Primarily used for offline/air-gapped environments.
|
|
21
|
+
*/
|
|
22
|
+
workerPath?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Path to the Tesseract core script.
|
|
25
|
+
* Primarily used for offline/air-gapped environments.
|
|
26
|
+
*/
|
|
27
|
+
corePath?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Path for Tesseract language files (traineddata).
|
|
30
|
+
* Primarily used for offline/air-gapped environments.
|
|
31
|
+
*/
|
|
32
|
+
langPath?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Timeout in milliseconds of inactivity before the OCR worker pool is automatically terminated.
|
|
35
|
+
* Set to 0 to disable auto-termination.
|
|
36
|
+
* Default is 10,000 (10 seconds).
|
|
37
|
+
*/
|
|
38
|
+
autoTerminateTimeout?: number;
|
|
39
|
+
}
|
|
3
40
|
/**
|
|
4
41
|
* Configuration options for the OfficeParser.
|
|
5
42
|
*/
|
|
@@ -42,6 +79,7 @@ export interface OfficeParserConfig {
|
|
|
42
79
|
*/
|
|
43
80
|
ocr?: boolean;
|
|
44
81
|
/**
|
|
82
|
+
* @deprecated Use `ocrConfig.language` instead.
|
|
45
83
|
* Language for OCR.
|
|
46
84
|
* Default is 'eng'.
|
|
47
85
|
*
|
|
@@ -52,11 +90,31 @@ export interface OfficeParserConfig {
|
|
|
52
90
|
* https://tesseract-ocr.github.io/tessdoc/Data-Files#data-files-for-version-400-november-29-2016
|
|
53
91
|
*/
|
|
54
92
|
ocrLanguage?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Shared OCR configuration for worker pooling and offline support.
|
|
95
|
+
* If provided, `ocrLanguage` will be ignored in favor of `ocrConfig.language`.
|
|
96
|
+
*/
|
|
97
|
+
ocrConfig?: OcrConfig;
|
|
98
|
+
/**
|
|
99
|
+
* Flag to serialize raw content (XML) as clean, formatted strings.
|
|
100
|
+
* Only relevant when `includeRawContent` is true.
|
|
101
|
+
* Default is true.
|
|
102
|
+
*
|
|
103
|
+
* If false, the parser will attempt to extract the original raw substring from the
|
|
104
|
+
* source document instead of re-serializing the DOM node.
|
|
105
|
+
*/
|
|
106
|
+
serializeRawContent?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Flag to preserve original XML whitespace and line endings when serializing.
|
|
109
|
+
* Only relevant when `includeRawContent` is true and `serializeRawContent` is true.
|
|
110
|
+
* Default is false.
|
|
111
|
+
*/
|
|
112
|
+
preserveXmlWhitespace?: boolean;
|
|
55
113
|
/**
|
|
56
114
|
* The URL/path to the PDF.js worker script.
|
|
57
115
|
*
|
|
58
116
|
* **Mandatory** when using PDF parsing in browser environments to avoid worker configuration errors.
|
|
59
|
-
* If not provided, it defaults to `https://unpkg.com/pdfjs-dist@5.
|
|
117
|
+
* If not provided, it defaults to `https://unpkg.com/pdfjs-dist@5.6.205/build/pdf.worker.min.mjs`.
|
|
60
118
|
* You can override this with your own local path or a different CDN link.
|
|
61
119
|
*/
|
|
62
120
|
pdfWorkerSrc?: string;
|
|
@@ -542,6 +600,16 @@ export interface OfficeMetadata {
|
|
|
542
600
|
formatting?: Partial<TextFormatting>;
|
|
543
601
|
/** Style map for styles in the document. */
|
|
544
602
|
styleMap?: Record<string, Partial<TextFormatting>>;
|
|
603
|
+
/**
|
|
604
|
+
* User-defined custom properties embedded in the document.
|
|
605
|
+
* Sources by format:
|
|
606
|
+
* - DOCX/XLSX/PPTX: `docProps/custom.xml` (Office custom document properties)
|
|
607
|
+
* - ODT/ODP/ODS: `meta:user-defined` elements in `meta.xml`
|
|
608
|
+
* - PDF: non-standard entries in the PDF Info dictionary
|
|
609
|
+
* RTF does not support custom properties; the `\info` group is not extracted.
|
|
610
|
+
* Values are typed as string, number, boolean, or Date where the source format provides type information.
|
|
611
|
+
*/
|
|
612
|
+
customProperties?: Record<string, string | number | boolean | Date>;
|
|
545
613
|
}
|
|
546
614
|
/**
|
|
547
615
|
* The Abstract Syntax Tree (AST) returned by the parser.
|
|
@@ -668,8 +736,18 @@ export declare class OfficeParser {
|
|
|
668
736
|
* ```
|
|
669
737
|
*/
|
|
670
738
|
static parseOffice(file: string | Buffer | ArrayBuffer, configOrCallback?: OfficeParserConfig | ((ast: OfficeParserAST, err?: any) => void), config?: OfficeParserConfig): Promise<OfficeParserAST>;
|
|
739
|
+
/**
|
|
740
|
+
* Terminates all active OCR workers and cleans up resources.
|
|
741
|
+
*
|
|
742
|
+
* This should be called when the application is shutting down or when OCR
|
|
743
|
+
* is no longer needed to prevent memory leaks and orphaned worker processes.
|
|
744
|
+
*
|
|
745
|
+
* @returns A promise that resolves when all workers have been terminated
|
|
746
|
+
*/
|
|
747
|
+
static terminateOcr(): Promise<void>;
|
|
671
748
|
}
|
|
672
749
|
export declare const parseOffice: typeof OfficeParser.parseOffice;
|
|
750
|
+
export declare const terminateOcr: typeof OfficeParser.terminateOcr;
|
|
673
751
|
|
|
674
752
|
export {
|
|
675
753
|
OfficeParser as default,
|