@qrcommunication/gigapdf-lib 0.57.0 → 0.58.1
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 +66 -0
- package/README.md +6 -2
- package/dist/index.cjs +47 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,72 @@ 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.58.1] - 2026-06-21
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **`reorderElement` now preserves the element's effective graphics state
|
|
12
|
+
(fill/stroke colour, line width, dash, font) so reordered shapes/text keep
|
|
13
|
+
their appearance.** Previously the moved op range was re-wrapped in a *bare*
|
|
14
|
+
`q … Q`, dropping the graphics state set *before* the element (fill colour via
|
|
15
|
+
`rg`/`g`/`k` or `cs`+`scn`, stroke colour via `RG`/`G`/`K` or `CS`+`SCN`, line
|
|
16
|
+
width `w`, dash `d`, caps/joins `J`/`j`/`M`, the active `/ExtGState` `gs`, and —
|
|
17
|
+
for text — the font `Tf`). A red shape brought to the front would render black,
|
|
18
|
+
etc. `reorderElement` now runs a last-write-wins scan over the operators
|
|
19
|
+
preceding the element (honouring the `q`/`Q` save/restore stack) and re-emits
|
|
20
|
+
the actually-set state operators inside the new `q … Q`, before the moved run,
|
|
21
|
+
so the element renders identically at its new position; the trailing `Q` still
|
|
22
|
+
restores, so neighbours are unaffected. Images (no colour state) are unchanged.
|
|
23
|
+
|
|
24
|
+
## [0.58.0] - 2026-06-21
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **`setElementOpacity(page, index, fillAlpha)` — constant opacity on *any*
|
|
29
|
+
element.** Sets a single transparency value on a text, image **or** shape
|
|
30
|
+
element in place by registering a page `/ExtGState` (`/ca` = `/CA` =
|
|
31
|
+
`fillAlpha`, clamped to `0..=1`, auto-named `GpGs<n>`) and wrapping the
|
|
32
|
+
element's op range in `q /<gs> gs … Q`, so the alpha applies to that run only
|
|
33
|
+
and following content is unaffected. This is the way to set an **image**'s
|
|
34
|
+
opacity in place; shapes may use either this or `setPathStyle`'s `fillAlpha` /
|
|
35
|
+
`strokeAlpha` (same underlying `/ExtGState` mechanism — the difference is that
|
|
36
|
+
`setElementOpacity` uses one value for both `/ca` and `/CA`, while `setPathStyle`
|
|
37
|
+
can set fill and stroke alpha independently). New ABI
|
|
38
|
+
`gp_set_element_opacity(handle, page, index, fill_alpha)` and core
|
|
39
|
+
`Document::set_element_opacity` / `content::set_element_opacity`. Returns
|
|
40
|
+
`false` for a missing page/index.
|
|
41
|
+
- **`reorderElement(page, index, toFront)` — native PDF stacking order.** Changes
|
|
42
|
+
an element's paint (z) order by splicing its op range to the **end** of the
|
|
43
|
+
content stream (`toFront = true` → painted last, on top) or to the **start**
|
|
44
|
+
(`toFront = false` → painted first, behind everything). The moved range is
|
|
45
|
+
re-wrapped in `q … Q` so it neither inherits nor leaks graphics state; works for
|
|
46
|
+
text, image and shape elements. **The element's unified index changes after the
|
|
47
|
+
splice — re-read `pageElements`.** New ABI `gp_reorder_element(handle, page,
|
|
48
|
+
index, to_front)` and core `Document::reorder_element` /
|
|
49
|
+
`content::reorder_element`. Returns `false` for a missing page/index.
|
|
50
|
+
- **`renderPageExcluding(page, indices, scale?)` — rasterise a page minus given
|
|
51
|
+
elements.** Rasterises a page to PNG while **omitting** the listed top-level
|
|
52
|
+
unified element `indices` (from `pageElements`) — each excluded element paints
|
|
53
|
+
nothing (fills, strokes, shadings, images and text alike) while all
|
|
54
|
+
non-excluded content renders normally. Generalises `renderPageNoText` (which
|
|
55
|
+
suppresses *all* text); an empty `indices` renders the full page and unknown
|
|
56
|
+
indices are ignored. Built for live-overlay editing — paint a background
|
|
57
|
+
without the element currently being edited, then overlay an editable version on
|
|
58
|
+
top. Native rasteriser, no third-party image library. New ABI
|
|
59
|
+
`gp_render_page_excluding(handle, page, indices_ptr, indices_len, scale,
|
|
60
|
+
out_len)` and core `Document::render_page_excluding`, alongside the unchanged
|
|
61
|
+
`renderPage` / `renderPageNoText`.
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- **`setPathStyle` opacity is now real.** `fillAlpha` / `strokeAlpha` (`0..=1`)
|
|
66
|
+
are now **fully applied** (previously accepted for API symmetry but a no-op):
|
|
67
|
+
the engine registers an `/ExtGState` carrying `/ca` / `/CA` on the page and
|
|
68
|
+
injects a `/<gs> gs` into the path's `q … Q` wrap, so the alpha applies to that
|
|
69
|
+
path run only. The earlier "opacity not applied — needs an `/ExtGState`"
|
|
70
|
+
limitation no longer holds. For non-path elements (e.g. images) use
|
|
71
|
+
`setElementOpacity`.
|
|
72
|
+
|
|
7
73
|
## [0.57.0] - 2026-06-21
|
|
8
74
|
|
|
9
75
|
### Added
|
package/README.md
CHANGED
|
@@ -272,14 +272,18 @@ Or call `GigaPdfEngine.load(bytes)` with bytes you read yourself.
|
|
|
272
272
|
- **`GigaPdfDoc`** — text intelligence (`textRuns`, `structuredText`, `search`,
|
|
273
273
|
`ocr`, `ocrText`, `elements`, `elementAt`), editing (`replaceText`,
|
|
274
274
|
`removeElement`, `moveElement`, `transformElement` (full affine — move + resize
|
|
275
|
-
+ rotate in place), `
|
|
275
|
+
+ rotate in place), `reorderElement` (native z-order — bring to front / send to
|
|
276
|
+
back), `setPathStyle` (in-place vector restyle: fill/stroke/width/dash + **real
|
|
277
|
+
opacity**), `setElementOpacity` (constant opacity on any element — text/image/shape),
|
|
276
278
|
`duplicateElement`, `redact`), vector drawing
|
|
277
279
|
(`addRectangle`, `drawLine`, `addEllipse`, `addPolygon`, `addPath` (SVG path),
|
|
278
280
|
`addImage` (PNG/JPEG, alpha + opacity)), pages (`rotatePage`, `deletePage`,
|
|
279
281
|
`movePage`, `appendPages`, `extractPages`, `resizePage`, `addPage`, `copyPage`,
|
|
280
282
|
`pageInfo`),
|
|
281
283
|
`renderPage` (and `renderPageNoText` — a text-free background for editors that
|
|
282
|
-
overlay real editable text; vectors/gradients/images/annotations still rendered
|
|
284
|
+
overlay real editable text; vectors/gradients/images/annotations still rendered —
|
|
285
|
+
plus `renderPageExcluding` — a background omitting specific elements for
|
|
286
|
+
live-overlay editing),
|
|
283
287
|
fonts (base-14 `addStandardText`, embed **any** TrueType/OpenType
|
|
284
288
|
via `embedFont`/`addText`, font-aware editing `replaceText`,
|
|
285
289
|
the document's own faces `embeddedFonts`/`extractFont`, `neededFonts`),
|
package/dist/index.cjs
CHANGED
|
@@ -995,10 +995,11 @@ var GigaPdfDoc = class {
|
|
|
995
995
|
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
996
996
|
* the element is not a path (or the page/index doesn't exist).
|
|
997
997
|
*
|
|
998
|
-
* Opacity
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
998
|
+
* Opacity: `fillAlpha`/`strokeAlpha` (`0..=1`) are fully supported — an
|
|
999
|
+
* `/ExtGState` carrying `/ca`/`/CA` is registered on the page and a `/<gs> gs`
|
|
1000
|
+
* is injected into the path's `q … Q` wrap, so the alpha applies to that path
|
|
1001
|
+
* run only. (For non-path elements such as images, use
|
|
1002
|
+
* {@link setElementOpacity}.)
|
|
1002
1003
|
*/
|
|
1003
1004
|
setPathStyle(page, index, style) {
|
|
1004
1005
|
return this.g._withStr(
|
|
@@ -1006,6 +1007,30 @@ var GigaPdfDoc = class {
|
|
|
1006
1007
|
(p, l) => this.ex().gp_set_path_style_json(this.h, page, index, p, l)
|
|
1007
1008
|
) === 0;
|
|
1008
1009
|
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Set a constant opacity on element `index` on `page` — text, image **or**
|
|
1012
|
+
* shape — by registering an `/ExtGState` (`/ca` = `/CA` = `fillAlpha`, clamped
|
|
1013
|
+
* to `0..=1`) on the page and wrapping the element's op range in
|
|
1014
|
+
* `q /<gs> gs … Q`. This is the way to set an **image**'s alpha in place;
|
|
1015
|
+
* shapes may also use {@link setPathStyle}'s `fillAlpha`/`strokeAlpha` (same
|
|
1016
|
+
* underlying `/ExtGState` mechanism). Returns `false` if the page/index doesn't
|
|
1017
|
+
* exist.
|
|
1018
|
+
*/
|
|
1019
|
+
setElementOpacity(page, index, fillAlpha) {
|
|
1020
|
+
return this.ex().gp_set_element_opacity(this.h, page, index, fillAlpha) === 0;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Change the paint order (z-order) of element `index` on `page`. `toFront`
|
|
1024
|
+
* brings it visually on top (its op range is moved to the end of the content
|
|
1025
|
+
* stream, painted last); otherwise it is sent behind everything (moved to the
|
|
1026
|
+
* start, painted first). The moved range is re-wrapped in `q … Q` so it neither
|
|
1027
|
+
* inherits nor leaks graphics state. Works for text, image and shape elements.
|
|
1028
|
+
* The element's index changes after the move — re-read {@link pageElements}.
|
|
1029
|
+
* Returns `false` if the page/index doesn't exist.
|
|
1030
|
+
*/
|
|
1031
|
+
reorderElement(page, index, toFront) {
|
|
1032
|
+
return this.ex().gp_reorder_element(this.h, page, index, toFront ? 1 : 0) === 0;
|
|
1033
|
+
}
|
|
1009
1034
|
duplicateElement(page, index) {
|
|
1010
1035
|
return this.ex().gp_duplicate_element(this.h, page, index) === 0;
|
|
1011
1036
|
}
|
|
@@ -1289,6 +1314,24 @@ var GigaPdfDoc = class {
|
|
|
1289
1314
|
renderPageNoText(page, scale = 1) {
|
|
1290
1315
|
return this.g._buffer((o) => this.ex().gp_render_page_no_text(this.h, page, scale, o));
|
|
1291
1316
|
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Rasterize a page to a PNG while **omitting** the given top-level element
|
|
1319
|
+
* `indices` (from {@link pageElements}). Each excluded element paints nothing
|
|
1320
|
+
* — fills, strokes, shadings, images and text alike — while everything else
|
|
1321
|
+
* (including the non-text content of non-excluded elements) renders normally.
|
|
1322
|
+
* Use it to paint a background without specific elements and overlay live,
|
|
1323
|
+
* editable versions on top. Generalises {@link renderPageNoText} (which
|
|
1324
|
+
* suppresses *all* text). An empty `indices` renders the full page; unknown
|
|
1325
|
+
* indices are ignored.
|
|
1326
|
+
*/
|
|
1327
|
+
renderPageExcluding(page, indices, scale = 1) {
|
|
1328
|
+
return this.g._buffer(
|
|
1329
|
+
(o) => this.g._withU32(
|
|
1330
|
+
indices,
|
|
1331
|
+
(p, c) => this.ex().gp_render_page_excluding(this.h, page, p, c, scale, o)
|
|
1332
|
+
)
|
|
1333
|
+
);
|
|
1334
|
+
}
|
|
1292
1335
|
// fonts — embed a downloaded font, then add real selectable text
|
|
1293
1336
|
/**
|
|
1294
1337
|
* Embed an outline font program as a Type0 font and return its object number
|