officeparser 3.3.0 → 4.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.
- package/README.md +95 -214
- package/officeParser.js +445 -539
- package/package.json +8 -4
- package/typings/officeParser.d.ts +29 -67
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "officeparser",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A Node.js library to parse text out of any office file. Currently supports docx, pptx, xlsx, odt, odp
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "A Node.js library to parse text out of any office file. Currently supports docx, pptx, xlsx, odt, odp, ods, pdf files.",
|
|
5
5
|
"main": "officeParser.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"officeParser.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"odt",
|
|
25
25
|
"odp",
|
|
26
26
|
"ods",
|
|
27
|
+
"pdf",
|
|
27
28
|
"parser",
|
|
28
29
|
"text",
|
|
29
30
|
"extract text",
|
|
@@ -41,13 +42,16 @@
|
|
|
41
42
|
},
|
|
42
43
|
"homepage": "https://github.com/harshankur/officeParser#readme",
|
|
43
44
|
"dependencies": {
|
|
45
|
+
"@xmldom/xmldom": "^0.8.10",
|
|
44
46
|
"decompress": "^4.2.0",
|
|
45
47
|
"file-type": "^16.5.4",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
+
"pdf-parse": "^1.1.1",
|
|
49
|
+
"rimraf": "^2.6.3"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
52
|
+
"@types/decompress": "^4.2.6",
|
|
50
53
|
"@types/node": "^18.16.1",
|
|
54
|
+
"@types/xmldom": "^0.1.33",
|
|
51
55
|
"typescript": "^5.0.3"
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -1,82 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @param {string} filename File path
|
|
25
|
-
* @param {function} callback Callback function that returns value or error
|
|
26
|
-
* @param {boolean} [deleteOfficeDist=true] Optional: Delete the officeDist directory created while unarchiving the doc file to get its content underneath. By default, we delete those files after we are done reading them.
|
|
27
|
-
* @returns {void}
|
|
28
|
-
*/
|
|
29
|
-
export function parseOpenOffice(filename: string, callback: Function, deleteOfficeDist?: boolean): void;
|
|
2
|
+
export type OfficeParserConfig = {
|
|
3
|
+
/**
|
|
4
|
+
* Flag to not delete the internal content files and the duplicate temp files that it uses after unzipping office files. Default is false. It deletes all of those files.
|
|
5
|
+
*/
|
|
6
|
+
preserveTempFiles: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Flag to show all the logs to console in case of an error irrespective of your own handling.
|
|
9
|
+
*/
|
|
10
|
+
outputErrorToConsole: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The delimiter used for every new line in places that allow multiline text like word. Default is \n.
|
|
13
|
+
*/
|
|
14
|
+
newlineDelimiter: string;
|
|
15
|
+
/**
|
|
16
|
+
* Flag to ignore notes from parsing in files like powerpoint. Default is false. It includes notes in the parsed text by default.
|
|
17
|
+
*/
|
|
18
|
+
ignoreNotes: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Flag, if set to true, will collectively put all the parsed text from notes at last in files like powerpoint. Default is false. It puts each notes right after its main slide content. If ignoreNotes is set to true, this flag is also ignored.
|
|
21
|
+
*/
|
|
22
|
+
putNotesAtLast: boolean;
|
|
23
|
+
};
|
|
30
24
|
/** Main async function with callback to execute parseOffice for supported files
|
|
31
|
-
* @param {string | Buffer}
|
|
32
|
-
* @param {function}
|
|
33
|
-
* @param {
|
|
25
|
+
* @param {string | Buffer} file File path or file buffers
|
|
26
|
+
* @param {function} callback Callback function that returns value or error
|
|
27
|
+
* @param {OfficeParserConfig} config [OPTIONAL]: Config Object for officeParser
|
|
34
28
|
* @returns {void}
|
|
35
29
|
*/
|
|
36
|
-
export function parseOffice(file: string | Buffer, callback: Function,
|
|
37
|
-
/** Async function that can be used with await to execute parseWord. Or it can be used with promises.
|
|
38
|
-
* @param {string} filename File path
|
|
39
|
-
* @param {boolean} [deleteOfficeDist=true] Optional: Delete the officeDist directory created while unarchiving the doc file to get its content underneath. By default, we delete those files after we are done reading them.
|
|
40
|
-
* @returns {Promise<string>}
|
|
41
|
-
*/
|
|
42
|
-
export function parseWordAsync(filename: string, deleteOfficeDist?: boolean): Promise<string>;
|
|
43
|
-
/** Async function that can be used with await to execute parsePowerPoint. Or it can be used with promises.
|
|
44
|
-
* @param {string} filename File path
|
|
45
|
-
* @param {boolean} [deleteOfficeDist=true] Optional: Delete the officeDist directory created while unarchiving the doc file to get its content underneath. By default, we delete those files after we are done reading them.
|
|
46
|
-
* @returns {Promise<string>}
|
|
47
|
-
*/
|
|
48
|
-
export function parsePowerPointAsync(filename: string, deleteOfficeDist?: boolean): Promise<string>;
|
|
49
|
-
/** Async function that can be used with await to execute parseExcel. Or it can be used with promises.
|
|
50
|
-
* @param {string} filename File path
|
|
51
|
-
* @param {boolean} [deleteOfficeDist=true] Optional: Delete the officeDist directory created while unarchiving the doc file to get its content underneath. By default, we delete those files after we are done reading them.
|
|
52
|
-
* @returns {Promise<string>}
|
|
53
|
-
*/
|
|
54
|
-
export function parseExcelAsync(filename: string, deleteOfficeDist?: boolean): Promise<string>;
|
|
55
|
-
/** Async function that can be used with await to execute parseOpenOffice. Or it can be used with promises.
|
|
56
|
-
* @param {string} filename File path
|
|
57
|
-
* @param {boolean} [deleteOfficeDist=true] Optional: Delete the officeDist directory created while unarchiving the doc file to get its content underneath. By default, we delete those files after we are done reading them.
|
|
58
|
-
* @returns {Promise<string>}
|
|
59
|
-
*/
|
|
60
|
-
export function parseOpenOfficeAsync(filename: string, deleteOfficeDist?: boolean): Promise<string>;
|
|
30
|
+
export function parseOffice(file: string | Buffer, callback: Function, config?: OfficeParserConfig): void;
|
|
61
31
|
/**
|
|
62
32
|
* Main async function that can be used with await to execute parseOffice. Or it can be used with promises.
|
|
63
|
-
* @param {string | Buffer}
|
|
64
|
-
* @param {
|
|
33
|
+
* @param {string | Buffer} file File path or file buffers
|
|
34
|
+
* @param {OfficeParserConfig} config [OPTIONAL]: Config Object for officeParser
|
|
65
35
|
* @returns {Promise<string>}
|
|
66
36
|
*/
|
|
67
|
-
export function parseOfficeAsync(file: string | Buffer,
|
|
37
|
+
export function parseOfficeAsync(file: string | Buffer, config: OfficeParserConfig): Promise<string>;
|
|
68
38
|
/**
|
|
69
39
|
* Set decompression directory. The final decompressed data will be put inside officeDist folder within your directory
|
|
70
40
|
* @param {string} newLocation Relative path to the directory that will contain officeDist folder with decompressed data
|
|
71
41
|
* @returns {void}
|
|
72
42
|
*/
|
|
73
43
|
export function setDecompressionLocation(newLocation: string): void;
|
|
74
|
-
/** Enable console output
|
|
75
|
-
* @returns {void}
|
|
76
|
-
*/
|
|
77
|
-
export function enableConsoleOutput(): void;
|
|
78
|
-
/** Disabled console output
|
|
79
|
-
* @returns {void}
|
|
80
|
-
*/
|
|
81
|
-
export function disableConsoleOutput(): void;
|
|
82
44
|
//# sourceMappingURL=officeParser.d.ts.map
|