Skip to content

Commit 99daaa4

Browse files
845073: Updated sample to client side
1 parent 0336154 commit 99daaa4

Some content is hidden

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

56 files changed

+21
-40527
lines changed

How to/Show and Hide Annotations/Show and Hide Annotations/src/App.vue

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<template>
22
<div id="app">
3-
<button v-on:click="toggleAnnotations">
4-
{{ annotationsVisible ? 'Hide Annotation' : 'Show Annotation' }}
5-
</button>
3+
<button id="hideBtn" v-on:click="hideAnnotations">Hide Annotations</button>
4+
<button id="unhideBtn" v-on:click="unhideAnnotations">Show Annotations</button>
65
<ejs-pdfviewer
76
id="pdfViewer"
87
ref="pdfviewer"
98
:documentPath="documentPath"
10-
:serviceUrl="serviceUrl">
9+
:resourceUrl="resourceUrl">
1110
</ejs-pdfviewer>
1211
</div>
1312
</template>
@@ -23,8 +22,8 @@ export default {
2322
},
2423
data() {
2524
return {
26-
documentPath: "Annotations.pdf",
27-
serviceUrl: "https://localhost:44309/pdfviewer",
25+
documentPath: "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf",
26+
resourceUrl: "https://cdn.syncfusion.com/ej2/30.1.37/dist/ej2-pdfviewer-lib",
2827
exportObject: "",
2928
annotationsVisible: true
3029
};
@@ -36,33 +35,24 @@ export default {
3635
]
3736
},
3837
methods: {
39-
async toggleAnnotations() {
38+
async hideAnnotations() {
4039
const viewer = this.$refs.pdfviewer.ej2Instances;
4140
42-
if (this.annotationsVisible) {
43-
// Hide annotations by exporting and deleting them
44-
try {
45-
const value = await viewer.exportAnnotationsAsObject();
46-
this.exportObject = JSON.stringify(value); // Convert object to string for later use
47-
48-
const count = viewer.annotationCollection.length;
49-
for (let i = 0; i < count; i++) {
50-
// Always delete the first item as the collection shrinks
51-
viewer.annotationModule.deleteAnnotationById(viewer.annotationCollection[0].annotationId);
52-
}
53-
54-
this.annotationsVisible = false;
55-
} catch (error) {
56-
console.error('Error hiding annotations:', error);
57-
}
58-
} else {
59-
// Restore annotations
60-
if (this.exportObject) {
61-
const parsedObject = JSON.parse(this.exportObject);
62-
viewer.importAnnotation(JSON.parse(parsedObject));
63-
}
64-
65-
this.annotationsVisible = true;
41+
try {
42+
const value = await viewer.exportAnnotationsAsObject();
43+
this.exportObject = JSON.stringify(value); // Convert object to string for later use
44+
viewer.deleteAnnotations();
45+
} catch (error) {
46+
console.error('Error hiding annotations:', error);
47+
}
48+
},
49+
50+
unhideAnnotations() {
51+
const viewer = this.$refs.pdfviewer.ej2Instances;
52+
53+
if (this.exportObject) {
54+
const parsedObject = JSON.parse(this.exportObject);
55+
viewer.importAnnotation(JSON.parse(parsedObject));
6656
}
6757
}
6858
}

How to/Show and Hide Annotations/Web Service/ControllerPractice.sln

Lines changed: 0 additions & 28 deletions
This file was deleted.

How to/Show and Hide Annotations/Web Service/ControllerPractice/ControllerPractice.csproj

Lines changed: 0 additions & 13 deletions
This file was deleted.

How to/Show and Hide Annotations/Web Service/ControllerPractice/ControllerPractice.csproj.user

Lines changed: 0 additions & 7 deletions
This file was deleted.

How to/Show and Hide Annotations/Web Service/ControllerPractice/Controllers/HomeController.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)