@peculiar/pdf-core 1.17.0 → 2.0.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 CHANGED
@@ -1,13 +1,34 @@
1
- # `@peculiar/pdf-core`
1
+ <h1 align="center">
2
+ @peculiar/pdf-core
3
+ </h1>
4
+
5
+ <div align="center">
6
+
7
+ ![GitHub License](https://img.shields.io/github/license/PeculiarVentures/pdf)
8
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/PeculiarVentures/pdf/release.yml?branch=main&label=release)
9
+ [![npm version](https://img.shields.io/npm/v/@peculiar/pdf-core.svg)](https://www.npmjs.com/package/@peculiar/pdf-core)
10
+ [![npm downloads](https://img.shields.io/npm/dm/@peculiar/pdf-core.svg)](https://www.npmjs.com/package/@peculiar/pdf-core)
11
+
12
+ </div>
2
13
 
3
14
  A powerful and flexible TypeScript library for PDF document manipulation, supporting both creation and modification of PDF files. The library provides comprehensive functionality for working with PDF objects, incremental updates, cross-reference tables, and encryption.
4
15
 
5
16
  ## Installation
6
17
 
7
18
  ```bash
8
- npm install @peculiar/pdf-core
19
+ npm install @peculiar/pdf-core reflect-metadata
9
20
  ```
10
21
 
22
+ ## Breaking Changes In v2
23
+
24
+ v2 is ESM-only and requires Node.js `^20.19.0 || >=22.12.0` (1.x declared no `engines`). CommonJS code can still `require("@peculiar/pdf-core")` on these versions; Node.js 22.0–22.11 can't. See the [full notes](https://github.com/PeculiarVentures/pdf#breaking-changes-in-v2) for the x509 3 / pkijs 4 changes, the Reflect polyfill and the `@peculiar/utils` differences.
25
+
26
+ - **TypeScript compiling to CommonJS:** use `"module": "node20"` or `"nodenext"` (`node16` fails with TS1479). ESM and bundler setups need no changes.
27
+ - **Jest in CommonJS mode:** switch to ESM mode or Vitest, or configure an ESM-to-CommonJS transformer and make sure `transformIgnorePatterns` doesn't exclude the `@peculiar/*` packages.
28
+ - **Deep imports** (`@peculiar/pdf-core/build/...`) are blocked by `exports`; import from `@peculiar/pdf-core`.
29
+ - **Peer dependencies:** `@peculiar/x509` (`^3.1.0`) and `pkijs` (`^4.0.0`) are peers, so certificates, pkijs objects and the pkijs engine are your app's copies. npm installs peers automatically.
30
+ - **Reflect polyfill:** `@peculiar/x509` 3 no longer loads one. Import `reflect-metadata` (or another Reflect polyfill) once, before any other import.
31
+
11
32
  ## Usage
12
33
 
13
34
  ### Creating a New PDF Document
@@ -50,10 +71,7 @@ const stringObj = doc.createString("Hello, PDF!");
50
71
  const arrayObj = doc.createArray(doc.createNumber(1), doc.createString("item"));
51
72
 
52
73
  // Create a dictionary
53
- const dictObj = doc.createDictionary(
54
- ["Key1", doc.createNumber(1)],
55
- ["Key2", doc.createString("value")]
56
- );
74
+ const dictObj = doc.createDictionary(["Key1", doc.createNumber(1)], ["Key2", doc.createString("value")]);
57
75
 
58
76
  // Create stream
59
77
  const streamObj = doc.createStream(new Uint8Array([1, 2, 3, 4]));