@qrcommunication/gigapdf-lib 0.55.1 → 0.57.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 +42 -0
- package/README.md +6 -2
- package/dist/index.cjs +51 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +51 -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,48 @@ 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.57.0] - 2026-06-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`transformElement(page, index, m)` — full affine transform of an element in
|
|
12
|
+
place.** Generalises `moveElement` (a translate-only `[1,0,0,1,dx,dy]` matrix)
|
|
13
|
+
to a complete PDF affine matrix `m = [a, b, c, d, e, f]` — scale, rotate, shear
|
|
14
|
+
and translate — so an element can be moved **and** resized **and** rotated in a
|
|
15
|
+
single call. Non-destructive: the element is wrapped in `q a b c d e f cm …
|
|
16
|
+
Q`, so its internal coordinates are never rewritten and it behaves identically
|
|
17
|
+
for text, images and shapes. New ABI `gp_transform_element(handle, page, index,
|
|
18
|
+
a, b, c, d, e, f)` and core `Document::transform_element` /
|
|
19
|
+
`content::transform_element`, alongside the existing `moveElement` /
|
|
20
|
+
`gp_move_element` (kept). Returns `false` for a missing page/element.
|
|
21
|
+
- **`setPathStyle(page, index, style)` — in-place vector restyle.** Re-styles a
|
|
22
|
+
**path** element (returns `false` for a non-path index) without touching its
|
|
23
|
+
geometry: the path's op range is wrapped in `q … Q` and, for each provided
|
|
24
|
+
field, an override operator is injected before the paint op — `fill`→`r g b rg`,
|
|
25
|
+
`stroke`→`r g b RG`, `strokeWidth`→`w`, `dash`→`[…] 0 d`; omitted fields keep
|
|
26
|
+
the inherited graphics state. `style = { fill?, stroke?, strokeWidth?,
|
|
27
|
+
fillAlpha?, strokeAlpha?, dash? }`; colours are RGB `[r,g,b]` in `0..=1` and
|
|
28
|
+
`dash` is the PDF dash array (`[]` = solid). New ABI
|
|
29
|
+
`gp_set_path_style_json(handle, page, index, json_ptr, json_len)` and core
|
|
30
|
+
`content::set_path_style` + `PathStyle` / `Document::set_path_style`. **Note:**
|
|
31
|
+
`fillAlpha` / `strokeAlpha` are accepted for API symmetry but are **not**
|
|
32
|
+
applied — PDF opacity requires a named `/ExtGState` resource, which a pure
|
|
33
|
+
content-stream edit cannot create; use the resource-level shape APIs (whose
|
|
34
|
+
`opacity` argument allocates the `/ExtGState`) when real transparency is needed.
|
|
35
|
+
|
|
36
|
+
## [0.56.0] - 2026-06-21
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **`renderPageNoText(page, scale?)` — text-free page raster.** Rasterise a page to
|
|
41
|
+
PNG **without** its page-content text (glyphs from `Tj`/`'`/`"`/`TJ` are suppressed)
|
|
42
|
+
while every non-text element — vectors, gradients/shadings, images and patterns —
|
|
43
|
+
plus annotation/widget appearances are rendered in full. Built for editors that
|
|
44
|
+
overlay real, editable text on top of a text-free background. Native rasteriser, no
|
|
45
|
+
third-party image library. New ABI `gp_render_page_no_text(handle, page, scale,
|
|
46
|
+
out_len)` and core `Document::render_page_no_text`, alongside the existing
|
|
47
|
+
`renderPage` / `gp_render_page`.
|
|
48
|
+
|
|
7
49
|
## [0.55.1] - 2026-06-21
|
|
8
50
|
|
|
9
51
|
### Fixed
|
package/README.md
CHANGED
|
@@ -271,12 +271,16 @@ Or call `GigaPdfEngine.load(bytes)` with bytes you read yourself.
|
|
|
271
271
|
`mergePdfs` (concatenate many PDFs), `fontCatalog`/`fontRequestUrl`/`parseCssFontUrl`.
|
|
272
272
|
- **`GigaPdfDoc`** — text intelligence (`textRuns`, `structuredText`, `search`,
|
|
273
273
|
`ocr`, `ocrText`, `elements`, `elementAt`), editing (`replaceText`,
|
|
274
|
-
`removeElement`, `moveElement`, `
|
|
274
|
+
`removeElement`, `moveElement`, `transformElement` (full affine — move + resize
|
|
275
|
+
+ rotate in place), `setPathStyle` (in-place vector restyle: fill/stroke/width/dash),
|
|
276
|
+
`duplicateElement`, `redact`), vector drawing
|
|
275
277
|
(`addRectangle`, `drawLine`, `addEllipse`, `addPolygon`, `addPath` (SVG path),
|
|
276
278
|
`addImage` (PNG/JPEG, alpha + opacity)), pages (`rotatePage`, `deletePage`,
|
|
277
279
|
`movePage`, `appendPages`, `extractPages`, `resizePage`, `addPage`, `copyPage`,
|
|
278
280
|
`pageInfo`),
|
|
279
|
-
`renderPage
|
|
281
|
+
`renderPage` (and `renderPageNoText` — a text-free background for editors that
|
|
282
|
+
overlay real editable text; vectors/gradients/images/annotations still rendered),
|
|
283
|
+
fonts (base-14 `addStandardText`, embed **any** TrueType/OpenType
|
|
280
284
|
via `embedFont`/`addText`, font-aware editing `replaceText`,
|
|
281
285
|
the document's own faces `embeddedFonts`/`extractFont`, `neededFonts`),
|
|
282
286
|
conversions (`toText/Html/Docx/Pptx/Odp/Odt/Xlsx/Ods/Rtf/PdfA`, plus
|
package/dist/index.cjs
CHANGED
|
@@ -913,6 +913,10 @@ var GigaPdfDoc = class {
|
|
|
913
913
|
* `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
|
|
914
914
|
* through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
|
|
915
915
|
* The native replacement for a reader's image extraction (bytes + placement).
|
|
916
|
+
*
|
|
917
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
918
|
+
* {@link removeElement} / {@link transformElement} / {@link duplicateElement} /
|
|
919
|
+
* {@link moveElement} — so you can extract an image and edit *that exact* image.
|
|
916
920
|
*/
|
|
917
921
|
imageElements(page) {
|
|
918
922
|
const raw = this.g._json(
|
|
@@ -929,6 +933,10 @@ var GigaPdfDoc = class {
|
|
|
929
933
|
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
930
934
|
* The native replacement for walking a reader's operator list to rebuild the
|
|
931
935
|
* shape layer.
|
|
936
|
+
*
|
|
937
|
+
* Each result's `index` is the **unified element index** usable directly with
|
|
938
|
+
* {@link setPathStyle} / {@link removeElement} / {@link transformElement} — so
|
|
939
|
+
* you can extract a path and restyle/remove *that exact* path.
|
|
932
940
|
*/
|
|
933
941
|
vectorPaths(page) {
|
|
934
942
|
return this.g._json((o) => this.ex().gp_vector_paths_json(this.h, page, o));
|
|
@@ -965,6 +973,39 @@ var GigaPdfDoc = class {
|
|
|
965
973
|
moveElement(page, index, dx, dy) {
|
|
966
974
|
return this.ex().gp_move_element(this.h, page, index, dx, dy) === 0;
|
|
967
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Apply a full affine transform to element `index` on `page`, wrapping it in
|
|
978
|
+
* `q … cm … Q` with the matrix `m = [a, b, c, d, e, f]`. This **generalises**
|
|
979
|
+
* {@link moveElement} (whose matrix is the pure translate `[1,0,0,1,dx,dy]`)
|
|
980
|
+
* to scale, rotation, shear and translation in one call. Because it is purely
|
|
981
|
+
* matrix-based it works identically for text, images and shapes — their
|
|
982
|
+
* internal coordinates are never touched. Returns `false` if the element/page
|
|
983
|
+
* doesn't exist.
|
|
984
|
+
*/
|
|
985
|
+
transformElement(page, index, m) {
|
|
986
|
+
return this.ex().gp_transform_element(this.h, page, index, m[0], m[1], m[2], m[3], m[4], m[5]) === 0;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Re-style the **path** element `index` on `page` in place: any provided field
|
|
990
|
+
* overrides that part of the graphics state for the path's paint; omitted
|
|
991
|
+
* fields keep the inherited state. Implemented by wrapping the path's op range
|
|
992
|
+
* in `q … Q` and injecting the requested state operators (`rg`/`RG`/`w`/`d`)
|
|
993
|
+
* before its construction + paint ops, so the original paint op now draws with
|
|
994
|
+
* the override and following content is unaffected. RGB colours are `[r,g,b]`
|
|
995
|
+
* in `0..=1`; `dash` is the PDF dash array (`[]` = solid). Returns `false` if
|
|
996
|
+
* the element is not a path (or the page/index doesn't exist).
|
|
997
|
+
*
|
|
998
|
+
* Opacity note: `fillAlpha`/`strokeAlpha` are accepted for API symmetry but
|
|
999
|
+
* are **not** emitted — PDF opacity needs a named `/ExtGState`, which a pure
|
|
1000
|
+
* content-stream edit cannot create. Use the resource-level shape APIs when
|
|
1001
|
+
* opacity is required.
|
|
1002
|
+
*/
|
|
1003
|
+
setPathStyle(page, index, style) {
|
|
1004
|
+
return this.g._withStr(
|
|
1005
|
+
JSON.stringify(style),
|
|
1006
|
+
(p, l) => this.ex().gp_set_path_style_json(this.h, page, index, p, l)
|
|
1007
|
+
) === 0;
|
|
1008
|
+
}
|
|
968
1009
|
duplicateElement(page, index) {
|
|
969
1010
|
return this.ex().gp_duplicate_element(this.h, page, index) === 0;
|
|
970
1011
|
}
|
|
@@ -1238,6 +1279,16 @@ var GigaPdfDoc = class {
|
|
|
1238
1279
|
renderPage(page, scale = 1) {
|
|
1239
1280
|
return this.g._buffer((o) => this.ex().gp_render_page(this.h, page, scale, o));
|
|
1240
1281
|
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Rasterize a page to a PNG **without the page content stream's text** — glyphs
|
|
1284
|
+
* are suppressed while gradients, shadings, images, vectors and patterns are
|
|
1285
|
+
* preserved. Annotation/widget appearances are still painted in full. Use this
|
|
1286
|
+
* to paint a text-free raster background the editor can overlay real, editable
|
|
1287
|
+
* text on top of.
|
|
1288
|
+
*/
|
|
1289
|
+
renderPageNoText(page, scale = 1) {
|
|
1290
|
+
return this.g._buffer((o) => this.ex().gp_render_page_no_text(this.h, page, scale, o));
|
|
1291
|
+
}
|
|
1241
1292
|
// fonts — embed a downloaded font, then add real selectable text
|
|
1242
1293
|
/**
|
|
1243
1294
|
* Embed an outline font program as a Type0 font and return its object number
|