officeparser 4.1.0 → 4.1.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 CHANGED
@@ -13,6 +13,7 @@ A Node.js library to parse text out of any office file.
13
13
 
14
14
 
15
15
  #### Update
16
+ * 2024/05/06 - Replaced pdf parsing support from pdf-parse library to natively building it using pdf.js library from Mozilla by analyzing its output. Added pdfjs-dist build as a local library.
16
17
  * 2023/11/25 - Fixed error catching when an error occurs within the parsing of a file, especially after decompressing it. Also fixed the problem with parallel parsing of files as we were using only timestamp in file names.
17
18
  * 2023/10/24 - Revamped content parsing code. Fixed order of content in files, especially in word files where table information would always land up at the end of the text. Added config object as argument for parseOffice which can be used to set new line delimiter and multiple other configurations. Added support for parsing pdf files using the popular npm library pdf-parse. Removed support for individual file parsing functions.
18
19
  * 2023/04/26 - Added support for file buffers as argument for filepath for parseOffice and parseOfficeAsync
package/officeParser.js CHANGED
@@ -454,6 +454,7 @@ function parsePdf(filepath, callback, config) {
454
454
  const responseText = textContentArray
455
455
  .map(textContent => textContent.items) // Get all the items
456
456
  .flat() // Flatten all the items object
457
+ .filter(item => item.str != '') // Ignore the empty string items.
457
458
  .reduce((a, v) => (
458
459
  {
459
460
  text: a.text + (v.transform[5] != a.transform5 ? (config.newlineDelimiter ?? "\n") : '') + v.str,
@@ -555,7 +556,7 @@ function parseOffice(file, callback, config = {}) {
555
556
  break;
556
557
 
557
558
  default:
558
- throw ERRORMSG.extensionUnsupported(extension);
559
+ internalCallback(undefined, ERRORMSG.extensionUnsupported(extension)); // Call the internalCallback function which removes the temp files if required.
559
560
  }
560
561
 
561
562
  /** Internal callback function that calls the user's callback function passed in argument and removes the temp files if required */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "officeparser",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
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": [