You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(v6.1.0): core infrastructure stability and documentation overhaul
Core Infrastructure & Performance:
- Implement `OcrSchedulerManager` with intelligent Tesseract.js worker pooling.
- Support parallel OCR requests with LRU language-affinity worker reuse.
- Migrate from `yauzl` to `fflate` for robust browser/Node zip extraction.
- Add `terminateOcr()` and `autoTerminateTimeout` for manual lifecycle control.
- Fix#59: Implement lazy-loading for OCR to prevent top-level requirement leaks.
- Enable full native ESM support and modern `Node16` resolution.
Documentation & UI/UX:
- Standardize download metrics to "260k+" with Shields.io badges.
- Add `npm-stat.com` verification hyperlinks to the Landing Page and Hero sections.
- Rewrite `index.html` as a premium SPA with persistent documentation fragments.
- Expand "Troubleshooting & Debugging" guides in README and documentation.
- Implement high-fidelity SVG icon system for all 8 supported document formats.
Metadata & Parsing Refinements:
- Add extraction of custom document properties for OOXML, ODF, and PDF.
- Upgrade `pdfjs-dist` to v5.6.205 with verified worker registry logic.
- Refine hierarchical coordinate alignment for PDF text and link layers.
- Improve ODT/RTF list parsing stability and indentation accuracy.
Project Ecosystem:
- Integrate GitHub `FUNDING.yml` and local `funding.json` manifests.
- Standardize IIFE/ESM browser bundles with automated sync-to-docs logic.
- Hardened CLI and Test suite (270+ test cases validated).
Copy file name to clipboardExpand all lines: README.md
+90-11Lines changed: 90 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@
3
3
A robust, strictly-typed Node.js and Browser library for parsing office files ([`docx`](https://en.wikipedia.org/wiki/Office_Open_XML), [`pptx`](https://en.wikipedia.org/wiki/Office_Open_XML), [`xlsx`](https://en.wikipedia.org/wiki/Office_Open_XML), [`odt`](https://en.wikipedia.org/wiki/OpenDocument), [`odp`](https://en.wikipedia.org/wiki/OpenDocument), [`ods`](https://en.wikipedia.org/wiki/OpenDocument), [`pdf`](https://en.wikipedia.org/wiki/PDF), [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)). It produces a clean, hierarchical Abstract Syntax Tree (AST) with rich metadata, text formatting, and full attachment support.
@@ -22,6 +24,13 @@ A robust, strictly-typed Node.js and Browser library for parsing office files ([
22
24
23
25
24
26
#### Update
27
+
* 2026-04-14 - **v6.1.0 Release**: Major Infrastructure & Resource Stability. (Incremental since v6.0.0)
28
+
-**OCR Scheduler**: Intelligent worker pool that optimizes Tesseract lifecycle across parallel requests. **Note**: By default, Node.js processes stay active for 10s after OCR to keep workers warm (configurable via `ocrConfig.autoTerminateTimeout`); use `terminateOcr()` for immediate CLI/script exit.
29
+
-**Core Engine**: Replaced legacy zip extraction with `fflate` for significant performance gains and robust browser/edge compatibility.
30
+
-**Module System**: Full native ESM support with `Node16` resolution and verified browser bundles (Vite/Angular compatible).
31
+
-**Format Refinements**: Hierarchical PDF coordinate alignment and ODT/RTF list parsing stability.
32
+
-**Custom Properties**: Added support for extracting custom document metadata across OOXML, ODF, and PDF formats.
33
+
-**Sponsorship**: Integrated `funding.json` manifest and GitHub Sponsors support.
25
34
* 2025/12/29 - **v6.0.0 Release**: Major overhaul of the library. Transitioned from simple text extraction to a rich **Abstract Syntax Tree (AST)** output.
26
35
- Simplified API: Use `parseOffice` for all parsing needs (returns a Promise).
@@ -303,6 +313,16 @@ Formatting can be found at two levels:
303
313
The `ast.metadata` object provides document-wide context:
304
314
-**`styleMap`**: A dictionary of style names to their `TextFormatting` definitions found in the document.
305
315
-**`formatting`**: Document-wide default settings (e.g., default font or font size).
316
+
-**`customProperties`**: A dictionary of user-defined metadata embedded in the document (OOXML `custom.xml`, ODF `meta:user-defined`, or PDF Info dictionary).
317
+
318
+
### 7. Custom Properties
319
+
You can access custom user-defined metadata that might be embedded in the document:
| `ocrLanguage` | string | `eng` | Language for OCR (e.g., 'eng', 'fra'). Supports multiple languages with '+'. See [Language Codes](https://tesseract-ocr.github.io/tessdoc/Data-Files#data-files-for-version-400-november-29-2016). |
408
426
| `includeRawContent` | boolean | `false` | Include raw XML/RTF markup in the nodes. |
427
+
| `serializeRawContent` | boolean | `true` | When `includeRawContent` is true, re-serializes raw XML to clean strings. If false, extracts original raw substring. |
428
+
| `preserveXmlWhitespace` | boolean | `false` | When `serializeRawContent` is true, preserves original XML whitespace and line endings. |
| `ocrConfig.langPath` | string | `undefined` | Path for Tesseract language files (for offline use). |
438
+
439
+
### OCR Scheduler & Resource Management
440
+
If your application uses OCR, `officeParser` utilizes an intelligent **Smart Worker Pool** to maintain a background worker pool and optimize repeated parse requests.
441
+
442
+
- **Dynamic Affinity**: Workers in the pool persist with their last used language affinity.
443
+
- **Smart Re-initialization**: If a new language is requested and the pool is full, the manager identifies the **Least Recently Used (LRU)** idle worker and re-initializes it for the new language using the Tesseract.js v5 API. This avoids the overhead of destroying and recreating workers.
444
+
- **Auto-Termination**: Workers are automatically cleaned up after 10 seconds of inactivity (configurable via `ocrConfig.autoTerminateTimeout`).
445
+
446
+
#### `OfficeParser.terminateOcr()`
447
+
If you have used OCR (`{ ocr: true }`) in a short-lived script (like CLI tools or one-off automation), we recommend explicitly calling `terminateOcr()` after your processing is finished. This bypasses the 10-second idle timer and allows the process to return to the terminal prompt immediately.
448
+
449
+
> [!NOTE]
450
+
> If OCR was not used, this function is a no-op and does not need to be called.
// Manually kill OCR workers for an immediate exit
460
+
await officeParser.terminateOcr();
461
+
}
462
+
```
463
+
464
+
> [!TIP]
465
+
> This is handled automatically in our own CLI (`npx officeparser ...`). You only need to call this manually if you are using the library in your own custom script and want a snappy exit.
When using `officeparser` in a browser environment to parse PDF files, you may provide the `pdfWorkerSrc` configuration option. If not provided, it defaults to a CDN link for `pdfjs-dist@5.6.205`.
> **Note:** The version of `pdfjs-dist` in the worker source should match the version used by `officeparser` (currently `5.4.530`).
557
+
> **Note:** The version of `pdfjs-dist` in the worker source should match the version used by `officeparser` (currently `5.6.205`).
558
+
559
+
## Troubleshooting & Common Issues
560
+
561
+
- **Node.js process stays alive after finishing**: If using OCR, the worker pool stays warm for 10s by default. Use `awaitterminateOcr()` at the end of your script for a snappy exit.
562
+
- **"Worker not found" in Browser**: Ensure `pdfWorkerSrc` is correctly pointed to the `pdf.worker.min.mjs` file matching version `5.6.205`.
563
+
- **OCR accuracy is low**: Verify your `ocrConfig.language` matches the document content. Note that OCR quality depends on image resolution.
564
+
- **Out of memory on large files**: For massive spreadsheets, consider using `ast.toText()` early and allowing the full AST object to be garbage-collected.
565
+
566
+
For a comprehensive guide, visit our [Debugging & Troubleshooting Documentation](https://harshankur.github.io/officeParser/#spec/debugging).
567
+
489
568
490
569
## Known Limitations
491
570
1. **ODT/ODS Charts**: Extraction may occasionally show inaccurate data when referencing external cell ranges or complex layout-based data.
-**serializeRawContent: true** (Default): Re-serializes the XML from the DOM. This ensures valid XML but may change whitespace or attribute order.
76
76
-**serializeRawContent: false**: Extracts the exact substring from the original file based on DOM locators. This is faster and preserves the byte-for-byte original content.
77
+
78
+
## OCR Scheduler & Resource Management
79
+
80
+
If you enable OCR in the browser (`{ ocr: true }`), `officeParser` will initialize a pool of Tesseract.js workers managed by an intelligent **Smart Worker Pool**.
81
+
82
+
-**Efficient Switching**: These workers persist with their language affinity. If you switch between parsing of English and French documents, the pool will automatically re-allocate workers using an **LRU (Least Recently Used)** strategy—re-initializing the oldest idle worker to the new language only when necessary.
83
+
-**Resource Cleanup**: Workers are automatically cleaned up after an inactivity timeout of 10 seconds.
84
+
85
+
### Manual OCR Cleanup
86
+
If you have performed a parse with OCR enabled and want to free up memory and terminate workers immediately:
0 commit comments