Repository navigation
pdf2json v4.1.1
A patch release that fixes parseBuffer and makes field tab indexes deterministic. There are no API
changes. Runtime dependencies are still zero, and the minimum Node.js is still 22.23.2.
Bug fixes
- parseBuffer works with buffers at a non-zero offset (#437). Parsing failed with Invalid XRef stream
header when the input was a view into a larger ArrayBuffer, such as a pooled Buffer.from(...) or a
subarray(). Since Node 24.18 raised Buffer.poolSize to 64 KiB, this hits any buffer under 32 KiB. Typed
arrays other than Uint8Array now read the same bytes instead of being truncated. This supersedes #424.
Thanks @dxg. - parseBuffer accepts any non-empty ArrayBufferView, including DataView (#438). Inputs that aren't views,
and empty views, still throw. - Verbosity 0 (errors only) is now honored (#438). loadPDF and parseBuffer used to treat 0 as unset and
fall back to warnings. - Empty sub-streams are now empty (#438). A PDF.js sub-stream at offset 0 with length 0 used to cover the
whole buffer.
Behavior change
- Form field tab indexes (TI) are numbered per document (#438). They start at 0 and go in page order. The
counter used to be shared by the whole process, so TI depended on how many PDFs had been parsed before,
including concurrent parses. If you parse several PDFs in one process (for example, the CLI on a
directory), TI now restarts at 0 for each file. Across the 1,064 output files of the forms test corpus,
TI values are the only difference.
Types
- parseBuffer(pdfBuffer: ArrayBufferView) in both pdfparser.d.ts and pdfparser.d.cts, matching what the
implementation accepts.
Packaging
- exports now includes "./package.json", so require("pdf2json/package.json") and import ... from
"pdf2json/package.json" work. - Cleaned up package.json metadata: repository (git+https), bugs and author URLs. Removed the deprecated
maintainers, contributors and readme fields, and files now lists only dist/. npm still packs
package.json, the readme and the license automatically.
Developer tooling (no runtime behavior change, #439)
- ESLint uses a rewritten flat config with typescript-eslint strictTypeChecked and stylisticTypeChecked.
Tests and bin/ are now linted, and private-member conventions are enforced. - Prettier 3.9.10 formats all JS/TS sources: tabs, double quotes, 120 columns.
- TypeScript is upgraded from 5.9.3 to 6.0.3, with nodenext, ES2024, verbatimModuleSyntax and
erasableSyntaxOnly. - Scripts: new check, lint:fix, format, format:check and typecheck scripts. npm run build now runs lint,
format check and typecheck. - CI: runs on push to master, with updated action versions, Deno 2.9.8, Node 22.23.2 and a non-blocking
TypeScript 7 typecheck. .gitattributes now forces LF line endings on every OS. - Docs: the readme's API reference documents parseBuffer inputs, verbosity levels and how TI is numbered,
and its test instructions are corrected.
Full changelog: v4.1.0...v4.1.1