@qrcommunication/gigapdf-lib 0.1.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 +30 -0
- package/LICENSE +114 -0
- package/README.md +105 -0
- package/dist/index.cjs +541 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +250 -0
- package/dist/index.d.ts +250 -0
- package/dist/index.js +499 -0
- package/dist/index.js.map +1 -0
- package/gigapdf.wasm +0 -0
- package/package.json +75 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@qrcommunication/gigapdf-lib` are documented here.
|
|
4
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/) and the
|
|
5
|
+
project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-06-14
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Initial public release of the TypeScript SDK for **gigapdf-lib**, a
|
|
12
|
+
zero-dependency Rust→WASM PDF engine.
|
|
13
|
+
- `GigaPdfEngine`: `load()`, `loadDefault()` (Node), `open()`, `openEncrypted()`,
|
|
14
|
+
stateless conversions (`txtToPdf`, `htmlToPdf`, `rtfToPdf`, `officeToPdf`), and
|
|
15
|
+
font helpers (`fontCatalog`, `fontRequestUrl`, `parseCssFontUrl`).
|
|
16
|
+
- `GigaPdfDoc`: full document API — text intelligence (`textRuns`,
|
|
17
|
+
`structuredText`, `search`, `ocr`, `ocrText`, `elements`, `elementAt`),
|
|
18
|
+
editing (`replaceText`, `removeElement`, `moveElement`, `duplicateElement`,
|
|
19
|
+
`addRectangle`, `redact`), pages (`rotatePage`, `deletePage`, `movePage`,
|
|
20
|
+
`appendPages`, `extractPages`), rendering (`renderPage`), embedded fonts
|
|
21
|
+
(`embedFont`, `addText`, `neededFonts`), conversions to
|
|
22
|
+
text/HTML/DOCX/PPTX/ODT/XLSX/ODS/RTF/PDF-A, security (`saveEncrypted`, `sign`),
|
|
23
|
+
metadata (`getMetadata`, `setMetadata`), annotations (square, highlight, line,
|
|
24
|
+
free-text, underline, strike-out, ink, stamp, plus `annotations`,
|
|
25
|
+
`removeAnnotation`, `flattenAnnotations`), hyperlinks (`links`, `addUriLink`,
|
|
26
|
+
`addGotoLink`), outline (`outline`, `setOutline`), and AcroForm fields
|
|
27
|
+
(`fields`, `setTextField`, `setCheckbox`, `setRadio`, `setChoice`).
|
|
28
|
+
- The engine `.wasm` is self-contained — no third-party runtime dependencies.
|
|
29
|
+
|
|
30
|
+
[0.1.0]: https://github.com/qrcommunication/gigapdf-lib/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
Copyright 2025 Rony Licha / QR Communication
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree to them as both
|
|
10
|
+
strict obligations and conditions to all your licenses.
|
|
11
|
+
|
|
12
|
+
## Copyright License
|
|
13
|
+
|
|
14
|
+
The licensor grants you a copyright license for the software to do everything
|
|
15
|
+
you might do with the software that would otherwise infringe the licensor's
|
|
16
|
+
copyright in it for any permitted purpose. However, you may only distribute the
|
|
17
|
+
software according to Distribution License and make changes or new works based
|
|
18
|
+
on the software according to Changes and New Works License.
|
|
19
|
+
|
|
20
|
+
## Distribution License
|
|
21
|
+
|
|
22
|
+
The licensor grants you an additional copyright license to distribute copies of
|
|
23
|
+
the software. Your license to distribute covers distributing the software with
|
|
24
|
+
changes and new works permitted by Changes and New Works License.
|
|
25
|
+
|
|
26
|
+
## Notices
|
|
27
|
+
|
|
28
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
29
|
+
also gets a copy of these terms or the URL for them above, as well as copies of
|
|
30
|
+
any plain-text lines beginning with `Required Notice:` that the licensor
|
|
31
|
+
provided with the software.
|
|
32
|
+
|
|
33
|
+
> Required Notice: Copyright 2025 Rony Licha / QR Communication
|
|
34
|
+
|
|
35
|
+
## Changes and New Works License
|
|
36
|
+
|
|
37
|
+
The licensor grants you an additional copyright license to make changes and new
|
|
38
|
+
works based on the software for any permitted purpose.
|
|
39
|
+
|
|
40
|
+
## Patent License
|
|
41
|
+
|
|
42
|
+
The licensor grants you a patent license for the software that covers patent
|
|
43
|
+
claims the licensor can license, or becomes able to license, that you would
|
|
44
|
+
infringe by using the software.
|
|
45
|
+
|
|
46
|
+
## Noncommercial Purposes
|
|
47
|
+
|
|
48
|
+
Any noncommercial purpose is a permitted purpose.
|
|
49
|
+
|
|
50
|
+
## Personal Uses
|
|
51
|
+
|
|
52
|
+
Personal use for research, experiment, and testing for the benefit of public
|
|
53
|
+
knowledge, personal study, private entertainment, hobby projects, amateur
|
|
54
|
+
pursuits, or religious observance, without any anticipated commercial
|
|
55
|
+
application, is use for a permitted purpose.
|
|
56
|
+
|
|
57
|
+
## Noncommercial Organizations
|
|
58
|
+
|
|
59
|
+
Use by any charitable organization, educational institution, public research
|
|
60
|
+
organization, public safety or health organization, environmental protection
|
|
61
|
+
organization, or government institution is use for a permitted purpose
|
|
62
|
+
regardless of the source of funding or obligations resulting from the funding.
|
|
63
|
+
|
|
64
|
+
## Fair Use
|
|
65
|
+
|
|
66
|
+
You may have "fair use" rights for the software under the law. These terms do
|
|
67
|
+
not limit them.
|
|
68
|
+
|
|
69
|
+
## No Other Rights
|
|
70
|
+
|
|
71
|
+
These terms do not allow you to sublicense or transfer any of your licenses to
|
|
72
|
+
anyone else, or prevent the licensor from granting licenses to anyone else.
|
|
73
|
+
These terms do not imply any other licenses.
|
|
74
|
+
|
|
75
|
+
## Patent Defense
|
|
76
|
+
|
|
77
|
+
If you make any written claim that the software infringes or contributes to
|
|
78
|
+
infringement of any patent, your patent license for the software granted under
|
|
79
|
+
these terms ends immediately. If your company makes such a claim, your patent
|
|
80
|
+
license ends immediately for work on behalf of your company.
|
|
81
|
+
|
|
82
|
+
## Violations
|
|
83
|
+
|
|
84
|
+
The first time you are notified in writing that you have violated any of these
|
|
85
|
+
terms, or done anything with the software not covered by your licenses, your
|
|
86
|
+
licenses can nonetheless continue if you come into full compliance with these
|
|
87
|
+
terms, and take practical steps to correct past violations, within 32 days of
|
|
88
|
+
receiving notice. Otherwise, all your licenses end immediately.
|
|
89
|
+
|
|
90
|
+
## No Liability
|
|
91
|
+
|
|
92
|
+
> AS FAR AS THE LAW ALLOWS, THE SOFTWARE COMES AS IS, WITHOUT ANY WARRANTY OR
|
|
93
|
+
> CONDITION, AND THE LICENSOR WILL NOT BE LIABLE TO YOU FOR ANY DAMAGES ARISING
|
|
94
|
+
> OUT OF THESE TERMS OR THE USE OR NATURE OF THE SOFTWARE, UNDER ANY KIND OF
|
|
95
|
+
> LEGAL CLAIM.
|
|
96
|
+
|
|
97
|
+
## Definitions
|
|
98
|
+
|
|
99
|
+
The **licensor** is the individual or entity offering these terms, and the
|
|
100
|
+
**software** is the software the licensor makes available under these terms.
|
|
101
|
+
|
|
102
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
103
|
+
|
|
104
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of
|
|
105
|
+
organization that you work for, plus all organizations that have control over,
|
|
106
|
+
are under the control of, or are under common control with that organization.
|
|
107
|
+
**Control** means ownership of substantially all the assets of an entity, or the
|
|
108
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
109
|
+
Control can be direct or indirect.
|
|
110
|
+
|
|
111
|
+
**Your licenses** are all the licenses granted to you for the software under
|
|
112
|
+
these terms.
|
|
113
|
+
|
|
114
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @qrcommunication/gigapdf-lib
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for **gigapdf-lib** — a zero-dependency Rust→WASM PDF engine.
|
|
4
|
+
Read, edit, render, OCR, search, sign, encrypt, fill forms, annotate, and convert
|
|
5
|
+
PDFs ↔ Office/HTML/RTF. The engine `.wasm` is self-contained: **no third-party
|
|
6
|
+
runtime dependencies**.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @qrcommunication/gigapdf-lib
|
|
12
|
+
# or: npm i @qrcommunication/gigapdf-lib
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { GigaPdfEngine } from "@qrcommunication/gigapdf-lib";
|
|
19
|
+
|
|
20
|
+
// Node: loads the bundled gigapdf.wasm from the package.
|
|
21
|
+
const giga = await GigaPdfEngine.loadDefault();
|
|
22
|
+
|
|
23
|
+
// Browser / explicit control: pass a URL, Response, or bytes.
|
|
24
|
+
// const giga = await GigaPdfEngine.load("/gigapdf.wasm");
|
|
25
|
+
|
|
26
|
+
const doc = giga.open(pdfBytes); // Uint8Array
|
|
27
|
+
|
|
28
|
+
// Read
|
|
29
|
+
const lines = doc.structuredText(1); // [{ text, x, y, w, h }]
|
|
30
|
+
const hits = doc.search("invoice"); // [{ page, text, x, y, w, h }]
|
|
31
|
+
const words = doc.ocr(1, 2); // OCR a scanned page at 2× scale
|
|
32
|
+
|
|
33
|
+
// Edit (operates on the real content stream — no cosmetic overlay)
|
|
34
|
+
doc.replaceText(1, 0, "New value");
|
|
35
|
+
doc.redact(1, 72, 700, 180, 14); // physically remove content in a region
|
|
36
|
+
doc.addHighlight(1, 72, 690, 252, 704, 0xffff00);
|
|
37
|
+
|
|
38
|
+
// Convert
|
|
39
|
+
const docx = doc.toDocx(); // also: toPptx/toOdt/toXlsx/toOds/toHtml/toText/toRtf/toPdfA
|
|
40
|
+
const png = doc.renderPage(1, 2); // rasterize a page
|
|
41
|
+
|
|
42
|
+
// Save
|
|
43
|
+
const out = doc.save(); // or doc.saveCompressed()
|
|
44
|
+
doc.close();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Office / HTML / RTF → PDF
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const fromDocx = giga.officeToPdf(officeBytes); // docx/xlsx/pptx/odt/ods/odp auto-detected
|
|
51
|
+
const fromHtml = giga.htmlToPdf("<h1>Hello</h1>");
|
|
52
|
+
const fromRtf = giga.rtfToPdf(rtfString);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Fonts (host performs the network fetch)
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const url = giga.fontRequestUrl("Roboto", 400); // Google Fonts CSS2 URL
|
|
59
|
+
const css = await (await fetch(url, { headers: { "User-Agent": "Mozilla/4.0" } })).text();
|
|
60
|
+
const ttfUrl = giga.parseCssFontUrl(css); // trusted gstatic URL
|
|
61
|
+
const ttf = new Uint8Array(await (await fetch(ttfUrl)).arrayBuffer());
|
|
62
|
+
const fontObj = doc.embedFont("Roboto", ttf);
|
|
63
|
+
doc.addText(1, 72, 720, 18, "Selectable text", fontObj, 0x111111);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Next.js (`output: "standalone"`)
|
|
67
|
+
|
|
68
|
+
`loadDefault()` reads `gigapdf.wasm` from the package directory. In standalone
|
|
69
|
+
output, add it to the route's `outputFileTracingIncludes` so it is copied into
|
|
70
|
+
the bundle:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
// next.config.ts
|
|
74
|
+
outputFileTracingIncludes: {
|
|
75
|
+
"/api/pdf/*": ["./node_modules/@qrcommunication/gigapdf-lib/gigapdf.wasm"],
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or call `GigaPdfEngine.load(bytes)` with bytes you read yourself.
|
|
80
|
+
|
|
81
|
+
## API surface
|
|
82
|
+
|
|
83
|
+
- **`GigaPdfEngine`** — `load`/`loadDefault`, `open`/`openEncrypted`,
|
|
84
|
+
`txtToPdf`/`htmlToPdf`/`rtfToPdf`/`officeToPdf`, `fontCatalog`/`fontRequestUrl`/`parseCssFontUrl`.
|
|
85
|
+
- **`GigaPdfDoc`** — text intelligence (`textRuns`, `structuredText`, `search`,
|
|
86
|
+
`ocr`, `ocrText`, `elements`, `elementAt`), editing (`replaceText`,
|
|
87
|
+
`removeElement`, `moveElement`, `duplicateElement`, `addRectangle`, `redact`),
|
|
88
|
+
pages (`rotatePage`, `deletePage`, `movePage`, `appendPages`, `extractPages`),
|
|
89
|
+
`renderPage`, fonts (`embedFont`, `addText`, `neededFonts`), conversions
|
|
90
|
+
(`toText/Html/Docx/Pptx/Odt/Xlsx/Ods/Rtf/PdfA`), security (`saveEncrypted`,
|
|
91
|
+
`sign`), metadata (`getMetadata`, `setMetadata`), annotations (`addSquare`,
|
|
92
|
+
`addHighlight`, `addLineAnnotation`, `addFreeText`, `addUnderline`,
|
|
93
|
+
`addStrikeOut`, `addInk`, `addStamp`, `annotations`, `removeAnnotation`,
|
|
94
|
+
`flattenAnnotations`), links (`links`, `addUriLink`, `addGotoLink`), outline
|
|
95
|
+
(`outline`, `setOutline`), and forms (`fields`, `setTextField`, `setCheckbox`,
|
|
96
|
+
`setRadio`, `setChoice`).
|
|
97
|
+
|
|
98
|
+
Every method is fully typed. Always `close()` a document when done to free the
|
|
99
|
+
WASM handle.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
**PolyForm Noncommercial License 1.0.0** © Rony Licha / QR Communication.
|
|
104
|
+
Free for noncommercial use; a commercial license is required otherwise. See
|
|
105
|
+
[`LICENSE`](LICENSE).
|