Skip to content

Commit d1282c7

Browse files
committed
Merge branch 'master' into div/ui-customization-doc-editor
2 parents 9f0b4f8 + 02455b3 commit d1282c7

File tree

78 files changed

+4896
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4896
-430
lines changed

.github/workflows/typecheck.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Type Check Playground Examples
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'playground/**'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
typecheck:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 2
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v5
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v6
22+
with:
23+
node-version: 'lts/*'
24+
cache: 'npm'
25+
cache-dependency-path: playground/package-lock.json
26+
27+
- name: Install dependencies
28+
working-directory: playground
29+
run: npm ci
30+
31+
- name: Run type check
32+
working-directory: playground
33+
run: npm run typecheck

README.md

Lines changed: 138 additions & 392 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"devDependencies": {
3-
"@biomejs/biome": "^2.2.4",
3+
"@biomejs/biome": "^2.3.1",
44
"@eslint/js": "^9.18.0",
55
"husky": "^9.1.7",
66
"lint-staged": "^15.4.1"

playground/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# 🎮 Interactive Playground Snippets
2+
3+
> **Try these examples instantly in your browser** - No setup, no installation required!
4+
5+
These are ready-to-run code snippets for the [Nutrient Web SDK](https://www.nutrient.io/web-sdk/) that you can open directly in the [Nutrient Playground](https://www.nutrient.io/playground). Each example demonstrates a specific feature with working code you can experiment with immediately.
6+
7+
## 🚀 How to Use
8+
9+
1. Click any example link below
10+
2. The Nutrient Playground opens with the code pre-loaded
11+
3. Modify the code and see changes instantly
12+
4. Copy the code into your own project
13+
14+
---
15+
16+
## 📋 Example Categories
17+
18+
### 🎨 Annotations
19+
[**View Annotations Examples**](./web-annotations.md) — Add, customize, and manage PDF annotations including watermarks, highlighting, and bulk operations.
20+
21+
**Popular examples:**
22+
- Watermark from text annotation
23+
- Flatten annotation on creation
24+
- Bulk delete all annotations
25+
- Straighten freeform highlights
26+
27+
---
28+
29+
### 🔒 Redaction
30+
[**View Redaction Examples**](./web-redaction.md) — Permanently remove sensitive content from PDFs.
31+
32+
---
33+
34+
### ✍️ Signing
35+
[**View Signing Examples**](./web-signing.md) — Electronic and digital signatures for PDF documents.
36+
37+
---
38+
39+
### 📝 Forms
40+
[**View Forms Examples**](./web-forms.md) — PDF form filling and management.
41+
42+
---
43+
44+
### 🎨 Form Creator
45+
[**View Form Creator Examples**](./web-form-creator.md) — Create and customize interactive PDF forms.
46+
47+
---
48+
49+
### 👁️ Viewer
50+
[**View Viewer Examples**](./web-viewer.md) — PDF viewing, navigation, and display customization.
51+
52+
---
53+
54+
### 📄 Document Editor
55+
[**View Document Editor Examples**](./web-document-editor.md) — Page manipulation, extraction, and editing.
56+
57+
---
58+
59+
### 💬 Comments
60+
[**View Comments Examples**](./web-comments.md) — Collaborative commenting workflows.
61+
62+
---
63+
64+
### ✏️ Content Editor
65+
[**View Content Editor Examples**](./web-content-editor.md) — Direct PDF content editing capabilities.
66+
67+
---
68+
69+
### 🎛️ Toolbars & Menus
70+
[**View Toolbars & Menus Examples**](./web-toolbars-menus.md) — UI customization and toolbar configuration.
71+
72+
---
73+
74+
### 🔍 Text Comparison
75+
[**View Text Comparison Examples**](./web-text-comparison.md) — Compare document versions and track changes.
76+
77+
---
78+
79+
## 💻 Want More?
80+
81+
- **Full Projects**: For complete, runnable applications, see [/web](../../web) directory
82+
- **Framework Integration**: [React](https://github.com/PSPDFKit/nutrient-web-examples/tree/main/examples/react), [Angular](https://github.com/PSPDFKit/nutrient-web-examples/tree/main/examples/angular), [Next.js](https://github.com/PSPDFKit/nutrient-web-examples/tree/main/examples/nextjs)
83+
- **Documentation**: [Nutrient Guides](https://www.nutrient.io/guides/)
84+
- **API Reference**: [Web SDK API](https://www.nutrient.io/api/web/)
85+
86+
---
87+
88+
## 🤝 Need Help?
89+
90+
- [Discord Community](https://discord.gg/Z754Pfb8bD)
91+
- [Support Portal](https://support.nutrient.io/hc/en-us/requests/new)
92+
- [Report Issues](https://github.com/PSPDFKit/awesome-nutrient/issues)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { baseOptions } from "../../shared/base-options";
2+
3+
// Bulk delete ALL annotations
4+
window.NutrientViewer.load({
5+
...baseOptions,
6+
theme: window.NutrientViewer.Theme.DARK,
7+
}).then((instance) => {
8+
const items = instance.toolbarItems;
9+
10+
const deleteButton = {
11+
type: "custom",
12+
id: "delete-annotations",
13+
title: "Delete", // or "Remove"
14+
onPress: async () => {
15+
try {
16+
const pagesAnnotations = await Promise.all(
17+
Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
18+
instance.getAnnotations(pageIndex),
19+
),
20+
);
21+
22+
const annotationIds = pagesAnnotations.flatMap((pageAnnotations) =>
23+
pageAnnotations.map((annotation) => annotation.id).toArray(),
24+
);
25+
26+
if (annotationIds.length === 0) {
27+
console.info("No annotations to delete.");
28+
return;
29+
}
30+
31+
await instance.delete(annotationIds);
32+
console.info(`Deleted ${annotationIds.length} annotations.`);
33+
} catch (e) {
34+
console.error("Failed to delete annotations:", e);
35+
}
36+
},
37+
};
38+
39+
instance.setToolbarItems([...items, deleteButton]);
40+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: annotations
3+
title: Bulk Delete Annotations
4+
description: Example to bulk delete annotations from the entire document. After the viewer loads, it gathers annotations from every page, flattens their IDs, and deletes them in a single operation..
5+
keywords: [annoatations, delete]
6+
---
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { Annotation } from "@nutrient-sdk/viewer";
2+
import { baseOptions } from "../../shared/base-options";
3+
4+
const username = "Omar";
5+
6+
window.NutrientViewer.load({
7+
...baseOptions,
8+
theme: window.NutrientViewer.Theme.DARK,
9+
toolbarItems: [{ type: "comment" }],
10+
}).then((instance) => {
11+
const annotation =
12+
new window.NutrientViewer.Annotations.CommentMarkerAnnotation({
13+
id: "test",
14+
pageIndex: 0,
15+
boundingBox: new window.NutrientViewer.Geometry.Rect({
16+
top: 100,
17+
left: 100,
18+
width: 10,
19+
height: 10,
20+
}),
21+
customData: { circleId: "my-circle" },
22+
});
23+
24+
const comment = new window.NutrientViewer.Comment({
25+
id: "commentId",
26+
rootId: "test",
27+
pageIndex: 0,
28+
text: { format: "plain", value: "Hello" },
29+
});
30+
31+
instance.setAnnotationCreatorName(username);
32+
instance.create([annotation, comment]);
33+
34+
instance.addEventListener("annotations.create", (annotations) => {
35+
const firstAnnotation = annotations.first() as Annotation | undefined;
36+
if (firstAnnotation) {
37+
console.log(firstAnnotation.toJS());
38+
}
39+
});
40+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: annotations
3+
title: Create Comment Thread Programmatically
4+
description: Demonstrates how to programmatically create a comment marker annotation with an associated comment thread, setting the creator name and listening for annotation creation events.
5+
keywords: [comment, annotation, programmatic, CommentMarkerAnnotation, thread]
6+
---

0 commit comments

Comments
 (0)