Skip to content

Commit 508a0ad

Browse files
993776: Redaction Annotation Samples
1 parent 21ea711 commit 508a0ad

File tree

33 files changed

+858
-0
lines changed

33 files changed

+858
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# textsearch
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
npm run lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "esnext",
5+
"baseUrl": "./",
6+
"moduleResolution": "node",
7+
"paths": {
8+
"@/*": [
9+
"src/*"
10+
]
11+
},
12+
"lib": [
13+
"esnext",
14+
"dom",
15+
"dom.iterable",
16+
"scripthost"
17+
]
18+
}
19+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "textsearch",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"@syncfusion/ej2-vue-pdfviewer": "*",
12+
"@syncfusion/ej2-dropdowns": "*",
13+
"core-js": "^3.8.3",
14+
"vue": "^3.2.13",
15+
"buffer": "^6.0.3",
16+
"crypto-browserify": "^3.12.0",
17+
"stream-browserify": "^3.0.0",
18+
"util": "^0.12.5",
19+
"vm-browserify": "^1.1.2"
20+
},
21+
"devDependencies": {
22+
"@babel/core": "^7.12.16",
23+
"@babel/eslint-parser": "^7.12.16",
24+
"@vue/cli-plugin-babel": "~5.0.0",
25+
"@vue/cli-plugin-eslint": "~5.0.0",
26+
"@vue/cli-service": "~5.0.0",
27+
"eslint": "^7.32.0",
28+
"eslint-plugin-vue": "^8.0.3"
29+
},
30+
"eslintConfig": {
31+
"root": true,
32+
"env": {
33+
"node": true
34+
},
35+
"extends": [
36+
"plugin:vue/essential",
37+
"eslint:recommended"
38+
],
39+
"parserOptions": {
40+
"parser": "@babel/eslint-parser"
41+
},
42+
"rules": {}
43+
},
44+
"browserslist": [
45+
"> 1%",
46+
"last 2 versions",
47+
"not dead",
48+
"not ie 11"
49+
]
50+
}
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title><%= htmlWebpackPlugin.options.title %></title>
9+
10+
</head>
11+
<body>
12+
<noscript>
13+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
14+
</noscript>
15+
<br><br><br>
16+
<div id="app"></div>
17+
<!-- built files will be auto injected -->
18+
</body>
19+
</html>
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<template>
2+
<div class="content-wrapper">
3+
<div style="margin-bottom: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;">
4+
<button id="addRedactAnnot" type="button" @click="addRedaction">Add Redaction</button>
5+
<button id="deleteById" type="button" @click="deleteAnnotationById">Delete Annotation By Id</button>
6+
<button id="editRedactAnnotation" type="button" @click="editRedactAnnotation">Edit Redaction</button>
7+
<button id="addPageRedactions" type="button" @click="addPageRedactions">Add Page Redactions</button>
8+
<button id="applyRedaction" type="button" @click="applyRedaction">Apply Redaction</button>
9+
</div>
10+
11+
<ejs-pdfviewer
12+
ref="pdfviewer"
13+
id="container"
14+
:documentPath="documentPath"
15+
:resourceUrl="resourceUrl"
16+
:toolbarSettings="toolbarSettings"
17+
style="height: 640px; display: block;"
18+
:annotationAdd="onAnnotationAdd"
19+
/>
20+
</div>
21+
</template>
22+
23+
<script>
24+
import {
25+
PdfViewerComponent,
26+
Toolbar,
27+
Magnification,
28+
Navigation,
29+
Annotation,
30+
LinkAnnotation,
31+
BookmarkView,
32+
ThumbnailView,
33+
Print,
34+
TextSelection,
35+
TextSearch,
36+
FormFields,
37+
FormDesigner,
38+
PageOrganizer
39+
} from '@syncfusion/ej2-vue-pdfviewer';
40+
41+
export default {
42+
name: 'App',
43+
components: { 'ejs-pdfviewer': PdfViewerComponent },
44+
data() {
45+
return {
46+
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
47+
resourceUrl: 'https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib',
48+
toolbarSettings: {
49+
toolbarItems: [
50+
'OpenOption',
51+
'UndoRedoTool',
52+
'PageNavigationTool',
53+
'MagnificationTool',
54+
'PanTool',
55+
'SelectionTool',
56+
'CommentTool',
57+
'SubmitForm',
58+
'AnnotationEditTool',
59+
'RedactionEditTool',
60+
'FormDesignerEditTool',
61+
'SearchOption',
62+
'PrintOption',
63+
'DownloadOption'
64+
]
65+
}
66+
};
67+
},
68+
provide: {
69+
PdfViewer: [
70+
Toolbar,
71+
Magnification,
72+
Navigation,
73+
Annotation,
74+
LinkAnnotation,
75+
BookmarkView,
76+
ThumbnailView,
77+
Print,
78+
TextSelection,
79+
TextSearch,
80+
FormFields,
81+
FormDesigner,
82+
PageOrganizer
83+
]
84+
},
85+
mounted() {
86+
// Set default redaction properties
87+
const inst = this.$refs.pdfviewer?.ej2Instances;
88+
if (!inst) return;
89+
inst.redactionSettings = {
90+
overlayText: 'Confidential',
91+
markerFillColor: '#FF0000',
92+
markerBorderColor: '#000000',
93+
isRepeat: false,
94+
fillColor: '#F8F8F8',
95+
fontColor: '#333333',
96+
fontSize: 14,
97+
fontFamily: 'Symbol',
98+
textAlign: 'Right'
99+
};
100+
},
101+
methods: {
102+
onAnnotationAdd(args) {
103+
console.log('Annotation added:', args);
104+
},
105+
addRedaction() {
106+
const inst = this.$refs.pdfviewer?.ej2Instances;
107+
if (!inst) return;
108+
inst.annotation.addAnnotation('Redaction', {
109+
bound: { x: 200, y: 480, width: 150, height: 75 },
110+
pageNumber: 1,
111+
markerFillColor: '#0000FF',
112+
markerBorderColor: 'white',
113+
fillColor: 'red',
114+
overlayText: 'Confidential',
115+
fontColor: 'yellow',
116+
fontFamily: 'Times New Roman',
117+
fontSize: 8,
118+
beforeRedactionsApplied: false
119+
});
120+
},
121+
deleteAnnotationById() {
122+
const inst = this.$refs.pdfviewer?.ej2Instances;
123+
if (!inst) return;
124+
const id = inst.annotationCollection?.[0]?.annotationId;
125+
if (id) inst.annotationModule.deleteAnnotationById(id);
126+
},
127+
editRedactAnnotation() {
128+
const inst = this.$refs.pdfviewer?.ej2Instances;
129+
if (!inst) return;
130+
const collection = inst.annotationCollection || [];
131+
for (let i = 0; i < collection.length; i++) {
132+
if (collection[i].subject === 'Redaction') {
133+
collection[i].overlayText = 'EditedAnnotation';
134+
collection[i].markerFillColor = '#22FF00';
135+
collection[i].markerBorderColor = '#000000';
136+
collection[i].isRepeat = true;
137+
collection[i].fillColor = '#F8F8F8';
138+
collection[i].fontColor = '#333333';
139+
collection[i].fontSize = 14;
140+
collection[i].fontFamily = 'Symbol';
141+
collection[i].textAlign = 'Right';
142+
collection[i].beforeRedactionsApplied = false;
143+
inst.annotation.editAnnotation(collection[i]);
144+
}
145+
}
146+
},
147+
addPageRedactions() {
148+
const inst = this.$refs.pdfviewer?.ej2Instances;
149+
if (!inst) return;
150+
inst.annotation.addPageRedactions([1, 3, 5, 7]);
151+
},
152+
applyRedaction() {
153+
const inst = this.$refs.pdfviewer?.ej2Instances;
154+
if (!inst) return;
155+
inst.annotation.redact();
156+
}
157+
}
158+
};
159+
</script>
160+
161+
<style>
162+
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
163+
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
164+
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
165+
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
166+
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
167+
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
168+
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
169+
@import "../node_modules/@syncfusion/ej2-vue-pdfviewer/styles/material.css";
170+
</style>
6.69 KB
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
4+
createApp(App).mount('#app')

0 commit comments

Comments
 (0)