@qrcommunication/gigapdf-lib 0.67.0 → 0.69.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 +74 -0
- package/dist/index.cjs +89 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,80 @@ 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.69.0] - 2026-06-23
|
|
8
|
+
|
|
9
|
+
Image-watermark release: stamp a raster image across any range of pages, with
|
|
10
|
+
the same ergonomics as the existing text watermark. The text watermark is
|
|
11
|
+
unchanged.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Image watermark.** Stamp a raster image over pages —
|
|
16
|
+
`addImageWatermark` (SDK) / `add_image_watermark` (core) /
|
|
17
|
+
`gp_add_image_watermark` (FFI). Accepts **PNG / JPEG / WebP / GIF / AVIF**
|
|
18
|
+
source images and supports per-watermark **opacity**, **anchoring**
|
|
19
|
+
(center + four corners) with offsets, **rotation** (about the image center),
|
|
20
|
+
**scaling** to a target size (aspect-follow), and an optional **tiling** grid.
|
|
21
|
+
The image XObject is embedded **once** and referenced on each target page,
|
|
22
|
+
reusing the existing image-embed/raster-transcode pipeline. The text
|
|
23
|
+
watermark and `add_image` behavior are unchanged.
|
|
24
|
+
|
|
25
|
+
## [0.68.0] - 2026-06-23
|
|
26
|
+
|
|
27
|
+
Format-reach + import/render fidelity release: the unified model now exports
|
|
28
|
+
**Markdown / CSV / EPUB** end to end, Office/ODF import preserves far more
|
|
29
|
+
structure, the HTML→PDF renderer gains the remaining common CSS, and several
|
|
30
|
+
image-codec and rendering bugs are fixed.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **Markdown / CSV / EPUB model export.** The unified editable model can now be
|
|
35
|
+
raised to **Markdown** (`modelToMd`), **CSV** (RFC 4180, `modelToCsv`) and
|
|
36
|
+
**EPUB 3** (`modelToEpub`), alongside the existing
|
|
37
|
+
`modelTo{Docx,Xlsx,Pptx,Odt,Ods,Odp,Pdf,Html,Rtf}` targets (ABI
|
|
38
|
+
`gp_model_to_{md,csv,epub}`).
|
|
39
|
+
- **Complete Markdown modelling.** `CodeBlock`, `Blockquote` and
|
|
40
|
+
`HorizontalRule` are first-class in the model — full Markdown round-trip
|
|
41
|
+
(headings, runs, links, images, nested lists, GFM tables, code blocks,
|
|
42
|
+
block-quotes, horizontal rules, footnotes, front-matter) rendered and exported
|
|
43
|
+
consistently across formats.
|
|
44
|
+
- **Office / ODF import fidelity.** DOCX/XLSX/PPTX and **ODF (`.odt`/`.ods`/
|
|
45
|
+
`.odp`)** import now preserves **images, hyperlinks, strikethrough,
|
|
46
|
+
highlighting, spreadsheet formulas, grouped shapes, charts, SmartArt text and
|
|
47
|
+
master/layout (theme) inheritance**.
|
|
48
|
+
- **HTML / CSS → PDF — remaining common CSS.** **Radial** and **conic**
|
|
49
|
+
gradients, **`font-weight` 100–900**, **`box-shadow`** (blur), **elliptical
|
|
50
|
+
`border-radius`**, dashed/dotted borders, **`linear-gradient`** and
|
|
51
|
+
**`position: sticky`**.
|
|
52
|
+
- **OpenType text shaping.** GPOS mark positioning, GSUB contextual, script
|
|
53
|
+
selection and Arabic joining (complex scripts only; Latin unchanged).
|
|
54
|
+
- **Image codecs.** SVG `<text>` rendering and GIF multi-frame decoding.
|
|
55
|
+
- **Run highlight.** Character-level `background` is painted and emitted across
|
|
56
|
+
HTML, PDF and Office output.
|
|
57
|
+
- **`setTextRunStyle`.** Run-level style bake exposed in the SDK.
|
|
58
|
+
- **Mermaid flowchart renderer** in the HTML engine (`graph TD/LR`, node shapes,
|
|
59
|
+
typed edges + arrowheads, Sugiyama layout → PDF vectors).
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- **AVIF multi-tile decode — corrupt images > 9.4 MP.** Multi-tile AVIFs were
|
|
64
|
+
decoded as a single tile, garbling pixels. The AV1 spec forces multi-tile
|
|
65
|
+
above ~9.4 MP, so essentially every modern phone/camera AVIF was silently
|
|
66
|
+
corrupted. Each tile is now decoded independently; single-tile and existing
|
|
67
|
+
fixtures are byte-for-byte unchanged (validated bit-exact vs `dav1d`).
|
|
68
|
+
- **WebP lossless (VP8L)** — lossless transforms + meta-Huffman now decode real
|
|
69
|
+
`cwebp`/libwebp lossless images correctly.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
|
|
73
|
+
- **Non-Device colorspaces** — Pattern fills and `Separation`/`ICCBased` colours
|
|
74
|
+
in content streams are unified through the raster colour resolver (consistent
|
|
75
|
+
with the rasterizer) instead of a device-default fallback.
|
|
76
|
+
- **Docs honesty** — README corrected to **near-zero-dependency** (hand-written
|
|
77
|
+
PDF/render/conversion core; **RustCrypto** for crypto/signatures; **Boa** for
|
|
78
|
+
JS — the earlier from-scratch JS engine is gone), **1198 tests** (was 284), and
|
|
79
|
+
`.wasm` **~5.6 MB** (was ~540 KB, before Boa was bundled).
|
|
80
|
+
|
|
7
81
|
## [0.67.0] - 2026-06-23
|
|
8
82
|
|
|
9
83
|
### Added
|
package/dist/index.cjs
CHANGED
|
@@ -831,6 +831,27 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
831
831
|
(p, l) => this._str((o) => this.ex.gp_model_to_rtf(p, l, o))
|
|
832
832
|
);
|
|
833
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
|
+
}
|
|
834
855
|
};
|
|
835
856
|
function packHtmlResources(resources) {
|
|
836
857
|
let size = 4;
|
|
@@ -1062,6 +1083,31 @@ var GigaPdfDoc = class {
|
|
|
1062
1083
|
(p, l) => this.ex().gp_set_path_style_json(this.h, page, index, p, l)
|
|
1063
1084
|
) === 0;
|
|
1064
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
|
+
}
|
|
1065
1111
|
/**
|
|
1066
1112
|
* Set a constant opacity on element `index` on `page` — text, image **or**
|
|
1067
1113
|
* shape — by registering an `/ExtGState` (`/ca` = `/CA` = `fillAlpha`, clamped
|
|
@@ -1193,6 +1239,49 @@ var GigaPdfDoc = class {
|
|
|
1193
1239
|
(p, l) => this.ex().gp_add_image(this.h, page, p, l, x, y, w, h, opacity)
|
|
1194
1240
|
) === 0;
|
|
1195
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Stamp an **image watermark** across pages from raw image bytes. Accepts the
|
|
1244
|
+
* same five formats the engine decodes — **PNG, JPEG, WebP, GIF, AVIF**. The
|
|
1245
|
+
* image is embedded **once** and referenced on every target page.
|
|
1246
|
+
*
|
|
1247
|
+
* `opts.pages` is a list of 1-based page numbers; omit it (or pass `[]`) to
|
|
1248
|
+
* stamp every page. `opts.anchor` positions the image (`'center'` default, or a
|
|
1249
|
+
* corner) and `opts.offsetX`/`offsetY` nudge it (in points; in `tile` mode they
|
|
1250
|
+
* become the gaps between tiles). `opts.width`/`height` set the target size in
|
|
1251
|
+
* points (height keeps the source aspect ratio when omitted). `opts.rotationDeg`
|
|
1252
|
+
* rotates about the image centre and `opts.opacity` (0–1) sets the alpha.
|
|
1253
|
+
* Returns `false` if the image can't be decoded.
|
|
1254
|
+
*/
|
|
1255
|
+
addImageWatermark(data, opts = {}) {
|
|
1256
|
+
const anchorTag = {
|
|
1257
|
+
center: 0,
|
|
1258
|
+
"top-left": 1,
|
|
1259
|
+
"top-right": 2,
|
|
1260
|
+
"bottom-left": 3,
|
|
1261
|
+
"bottom-right": 4
|
|
1262
|
+
}[opts.anchor ?? "center"];
|
|
1263
|
+
const pages = opts.pages ?? [];
|
|
1264
|
+
const call = (pp, pc) => this.g._withBytes(
|
|
1265
|
+
data,
|
|
1266
|
+
(p, l) => this.ex().gp_add_image_watermark(
|
|
1267
|
+
this.h,
|
|
1268
|
+
p,
|
|
1269
|
+
l,
|
|
1270
|
+
pp,
|
|
1271
|
+
pc,
|
|
1272
|
+
anchorTag,
|
|
1273
|
+
opts.offsetX ?? 0,
|
|
1274
|
+
opts.offsetY ?? 0,
|
|
1275
|
+
opts.width ?? 0,
|
|
1276
|
+
opts.height ?? 0,
|
|
1277
|
+
opts.rotationDeg ?? 0,
|
|
1278
|
+
opts.opacity ?? 0.25,
|
|
1279
|
+
opts.tile ? 1 : 0
|
|
1280
|
+
)
|
|
1281
|
+
);
|
|
1282
|
+
const rc = pages.length === 0 ? call(0, 0) : this.g._withU32(pages, (pp, pc) => call(pp, pc));
|
|
1283
|
+
return rc === 0;
|
|
1284
|
+
}
|
|
1196
1285
|
/**
|
|
1197
1286
|
* Draw SVG markup on a page as **native vector paths** (crisp at any zoom, not
|
|
1198
1287
|
* rasterized), fitting its `viewBox` into the box `(x, y, w, h)` in PDF points
|