@qrcommunication/gigapdf-lib 0.66.0 → 0.68.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/CHANGELOG.md +75 -0
- package/dist/index.cjs +94 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +208 -1
- package/dist/index.d.ts +208 -1
- package/dist/index.js +94 -1
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,81 @@ All notable changes to `@qrcommunication/gigapdf-lib` are documented here.
|
|
|
4
4
|
The format follows [Keep a Changelog](https://keepachangelog.com/) and the
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.68.0] - 2026-06-23
|
|
8
|
+
|
|
9
|
+
Format-reach + import/render fidelity release: the unified model now exports
|
|
10
|
+
**Markdown / CSV / EPUB** end to end, Office/ODF import preserves far more
|
|
11
|
+
structure, the HTML→PDF renderer gains the remaining common CSS, and several
|
|
12
|
+
image-codec and rendering bugs are fixed.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Markdown / CSV / EPUB model export.** The unified editable model can now be
|
|
17
|
+
raised to **Markdown** (`modelToMd`), **CSV** (RFC 4180, `modelToCsv`) and
|
|
18
|
+
**EPUB 3** (`modelToEpub`), alongside the existing
|
|
19
|
+
`modelTo{Docx,Xlsx,Pptx,Odt,Ods,Odp,Pdf,Html,Rtf}` targets (ABI
|
|
20
|
+
`gp_model_to_{md,csv,epub}`).
|
|
21
|
+
- **Complete Markdown modelling.** `CodeBlock`, `Blockquote` and
|
|
22
|
+
`HorizontalRule` are first-class in the model — full Markdown round-trip
|
|
23
|
+
(headings, runs, links, images, nested lists, GFM tables, code blocks,
|
|
24
|
+
block-quotes, horizontal rules, footnotes, front-matter) rendered and exported
|
|
25
|
+
consistently across formats.
|
|
26
|
+
- **Office / ODF import fidelity.** DOCX/XLSX/PPTX and **ODF (`.odt`/`.ods`/
|
|
27
|
+
`.odp`)** import now preserves **images, hyperlinks, strikethrough,
|
|
28
|
+
highlighting, spreadsheet formulas, grouped shapes, charts, SmartArt text and
|
|
29
|
+
master/layout (theme) inheritance**.
|
|
30
|
+
- **HTML / CSS → PDF — remaining common CSS.** **Radial** and **conic**
|
|
31
|
+
gradients, **`font-weight` 100–900**, **`box-shadow`** (blur), **elliptical
|
|
32
|
+
`border-radius`**, dashed/dotted borders, **`linear-gradient`** and
|
|
33
|
+
**`position: sticky`**.
|
|
34
|
+
- **OpenType text shaping.** GPOS mark positioning, GSUB contextual, script
|
|
35
|
+
selection and Arabic joining (complex scripts only; Latin unchanged).
|
|
36
|
+
- **Image codecs.** SVG `<text>` rendering and GIF multi-frame decoding.
|
|
37
|
+
- **Run highlight.** Character-level `background` is painted and emitted across
|
|
38
|
+
HTML, PDF and Office output.
|
|
39
|
+
- **`setTextRunStyle`.** Run-level style bake exposed in the SDK.
|
|
40
|
+
- **Mermaid flowchart renderer** in the HTML engine (`graph TD/LR`, node shapes,
|
|
41
|
+
typed edges + arrowheads, Sugiyama layout → PDF vectors).
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- **AVIF multi-tile decode — corrupt images > 9.4 MP.** Multi-tile AVIFs were
|
|
46
|
+
decoded as a single tile, garbling pixels. The AV1 spec forces multi-tile
|
|
47
|
+
above ~9.4 MP, so essentially every modern phone/camera AVIF was silently
|
|
48
|
+
corrupted. Each tile is now decoded independently; single-tile and existing
|
|
49
|
+
fixtures are byte-for-byte unchanged (validated bit-exact vs `dav1d`).
|
|
50
|
+
- **WebP lossless (VP8L)** — lossless transforms + meta-Huffman now decode real
|
|
51
|
+
`cwebp`/libwebp lossless images correctly.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
|
|
55
|
+
- **Non-Device colorspaces** — Pattern fills and `Separation`/`ICCBased` colours
|
|
56
|
+
in content streams are unified through the raster colour resolver (consistent
|
|
57
|
+
with the rasterizer) instead of a device-default fallback.
|
|
58
|
+
- **Docs honesty** — README corrected to **near-zero-dependency** (hand-written
|
|
59
|
+
PDF/render/conversion core; **RustCrypto** for crypto/signatures; **Boa** for
|
|
60
|
+
JS — the earlier from-scratch JS engine is gone), **1198 tests** (was 284), and
|
|
61
|
+
`.wasm` **~5.6 MB** (was ~540 KB, before Boa was bundled).
|
|
62
|
+
|
|
63
|
+
## [0.67.0] - 2026-06-23
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
|
|
67
|
+
- **Structured-editing ModelOps + permissions API exposed in the SDK.** New
|
|
68
|
+
`applyModelOps` variants: paragraph formatting (`setParagraphStyle` — align/indent/
|
|
69
|
+
spacing/line-height), lists (`setListLevel`/`setListMarker`/`setListOrdered`),
|
|
70
|
+
absolute block placement (`setBlockFrame`/`setBlockRotation`), and table styling
|
|
71
|
+
(`setCellShading`/`setRowHeight`/`setColWidth`/`setTableBorder`). Table structural
|
|
72
|
+
edits (`insertTableRow`/`deleteTableRow`/`insertTableColumn`/`deleteTableColumn`/
|
|
73
|
+
`setCellSpan` + sheet row/column ops) and `GigaPdfDoc` permission helpers
|
|
74
|
+
(`permissionsToP`/`decodePermissions`/`getPermissions` + `saveEncrypted({ flags })`)
|
|
75
|
+
are now callable from JS.
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
|
|
79
|
+
- 8 PDF permission flags are functional: `/P` is computed from named flags per
|
|
80
|
+
ISO 32000-1 Table 22 (previously a cosmetic integer).
|
|
81
|
+
|
|
7
82
|
## [0.66.0] - 2026-06-23
|
|
8
83
|
|
|
9
84
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,16 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
var import_node_fs = require("./node-fs.js");
|
|
28
28
|
var enc = new TextEncoder();
|
|
29
29
|
var dec = new TextDecoder();
|
|
30
|
+
var ALL_PERMISSIONS = {
|
|
31
|
+
print: true,
|
|
32
|
+
modify: true,
|
|
33
|
+
copy: true,
|
|
34
|
+
annotate: true,
|
|
35
|
+
fillForms: true,
|
|
36
|
+
accessibility: true,
|
|
37
|
+
assemble: true,
|
|
38
|
+
printHighRes: true
|
|
39
|
+
};
|
|
30
40
|
var GigaPdfEngine = class _GigaPdfEngine {
|
|
31
41
|
constructor(ex) {
|
|
32
42
|
this.ex = ex;
|
|
@@ -243,6 +253,43 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
243
253
|
);
|
|
244
254
|
return JSON.parse(dec.decode(json));
|
|
245
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Decode the eight access-permission flags from a `/P` permission bitmask
|
|
258
|
+
* (ISO 32000-1 Table 22) into named booleans (`true` = the action is
|
|
259
|
+
* granted). Reserved bits are ignored.
|
|
260
|
+
*/
|
|
261
|
+
decodePermissions(p) {
|
|
262
|
+
const json = dec.decode(this._buffer((o) => this.ex.gp_permissions_from_p(p, o)));
|
|
263
|
+
return JSON.parse(json);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Read a PDF's access permissions **without decrypting it** (no password
|
|
267
|
+
* needed). Returns the eight named flags decoded from the `/Encrypt`
|
|
268
|
+
* dictionary's `/P`; an unencrypted document grants everything.
|
|
269
|
+
*/
|
|
270
|
+
getPermissions(pdf) {
|
|
271
|
+
const { encrypted, permissions } = this.encryptionInfo(pdf);
|
|
272
|
+
return encrypted ? this.decodePermissions(permissions) : { ...ALL_PERMISSIONS };
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Pack eight access-permission flags into a signed 32-bit `/P` value
|
|
276
|
+
* (ISO 32000-1 Table 22). Omitted flags default to **granted**, so an empty
|
|
277
|
+
* object means "all allowed". Feed the result to {@link GigaPdfDoc.saveEncrypted}
|
|
278
|
+
* via `opts.permissions`, or pass `opts.flags` directly.
|
|
279
|
+
*/
|
|
280
|
+
permissionsToP(flags = {}) {
|
|
281
|
+
const f = { ...ALL_PERMISSIONS, ...flags };
|
|
282
|
+
return this.ex.gp_permissions_to_p(
|
|
283
|
+
f.print ? 1 : 0,
|
|
284
|
+
f.modify ? 1 : 0,
|
|
285
|
+
f.copy ? 1 : 0,
|
|
286
|
+
f.annotate ? 1 : 0,
|
|
287
|
+
f.fillForms ? 1 : 0,
|
|
288
|
+
f.accessibility ? 1 : 0,
|
|
289
|
+
f.assemble ? 1 : 0,
|
|
290
|
+
f.printHighRes ? 1 : 0
|
|
291
|
+
);
|
|
292
|
+
}
|
|
246
293
|
/**
|
|
247
294
|
* Width of `text` set in standard Helvetica at `size` points (AFM metrics) —
|
|
248
295
|
* place watermark/header text without embedding a font.
|
|
@@ -784,6 +831,27 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
784
831
|
(p, l) => this._str((o) => this.ex.gp_model_to_rtf(p, l, o))
|
|
785
832
|
);
|
|
786
833
|
}
|
|
834
|
+
/** Raise a model to Markdown (decoded UTF-8 string). */
|
|
835
|
+
modelToMarkdown(model) {
|
|
836
|
+
return this._withStr(
|
|
837
|
+
JSON.stringify(model),
|
|
838
|
+
(p, l) => this._str((o) => this.ex.gp_model_to_md(p, l, o))
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
/** Raise a model to CSV (decoded UTF-8 string). */
|
|
842
|
+
modelToCsv(model) {
|
|
843
|
+
return this._withStr(
|
|
844
|
+
JSON.stringify(model),
|
|
845
|
+
(p, l) => this._str((o) => this.ex.gp_model_to_csv(p, l, o))
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
/** Raise a model to an EPUB e-book (`.epub`). */
|
|
849
|
+
modelToEpub(model) {
|
|
850
|
+
return this._withStr(
|
|
851
|
+
JSON.stringify(model),
|
|
852
|
+
(p, l) => this._buffer((o) => this.ex.gp_model_to_epub(p, l, o))
|
|
853
|
+
);
|
|
854
|
+
}
|
|
787
855
|
};
|
|
788
856
|
function packHtmlResources(resources) {
|
|
789
857
|
let size = 4;
|
|
@@ -1015,6 +1083,31 @@ var GigaPdfDoc = class {
|
|
|
1015
1083
|
(p, l) => this.ex().gp_set_path_style_json(this.h, page, index, p, l)
|
|
1016
1084
|
) === 0;
|
|
1017
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Re-style **sub-ranges** of text run `index` on `page` in place — the
|
|
1088
|
+
* by-character-run companion of {@link setPathStyle}. Each span sets the style
|
|
1089
|
+
* of the `[start, end)` UTF-16 slice of the run's *decoded* text (bold / italic
|
|
1090
|
+
* / underline / strike / colour / size); the run is split so the rest keeps its
|
|
1091
|
+
* original style and **positioning is preserved** (the original glyph codes,
|
|
1092
|
+
* including `TJ` kerning, are sliced and re-emitted — never re-encoded — and
|
|
1093
|
+
* each styled slice is wrapped in `q … Q`). Spans may be given in any order and
|
|
1094
|
+
* are clamped to the run's length.
|
|
1095
|
+
*
|
|
1096
|
+
* Notes on each field: `color` is `[r,g,b]` in `0..=1` (text fill); `sizePt`
|
|
1097
|
+
* rescales the slice's font in the run's own text scale; `bold` is faux-bold
|
|
1098
|
+
* (fill+stroke render mode) when no bold variant font is wired; `italic` is a
|
|
1099
|
+
* no-op without an italic/oblique variant (a stream edit can't shear glyphs
|
|
1100
|
+
* without disturbing advances); `underline`/`strike` draw a thin rule in page
|
|
1101
|
+
* space. Returns `false` when `index` does not resolve to a top-level text run
|
|
1102
|
+
* (e.g. it addresses form-XObject text), like {@link setPathStyle} for a
|
|
1103
|
+
* non-matching element.
|
|
1104
|
+
*/
|
|
1105
|
+
setTextRunStyle(page, index, spans) {
|
|
1106
|
+
return this.g._withStr(
|
|
1107
|
+
JSON.stringify(spans),
|
|
1108
|
+
(p, l) => this.ex().gp_set_text_run_style_json(this.h, page, index, p, l)
|
|
1109
|
+
) === 0;
|
|
1110
|
+
}
|
|
1018
1111
|
/**
|
|
1019
1112
|
* Set a constant opacity on element `index` on `page` — text, image **or**
|
|
1020
1113
|
* shape — by registering an `/ExtGState` (`/ca` = `/CA` = `fillAlpha`, clamped
|
|
@@ -1525,7 +1618,7 @@ var GigaPdfDoc = class {
|
|
|
1525
1618
|
saveEncrypted(password, fileId, opts = {}) {
|
|
1526
1619
|
const algo = opts.algorithm ?? "aes256";
|
|
1527
1620
|
const algoCode = algo === "rc4" ? 0 : algo === "aes128" ? 1 : 2;
|
|
1528
|
-
const permissions = opts.permissions ??
|
|
1621
|
+
const permissions = opts.flags !== void 0 ? this.g.permissionsToP(opts.flags) : opts.permissions ?? this.g.permissionsToP();
|
|
1529
1622
|
let key = opts.keySeed ?? new Uint8Array(0);
|
|
1530
1623
|
if (algoCode === 2 && key.length < 32) {
|
|
1531
1624
|
const c = globalThis.crypto;
|