Skip to content

Commit e282b28

Browse files
authored
Merge pull request #30 from SyncfusionExamples/EJ2-380623-exportImport
380623: Samples on Export and Import Annotation
2 parents 4c964b5 + 5442492 commit e282b28

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html><html lang="en"><head>
2+
<title>EJ2 PDF Viewer</title>
3+
<meta charset="utf-8">
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<meta name="description" content="Typescript PDF Viewer Control">
6+
<meta name="author" content="Syncfusion">
7+
<link href="index.css" rel="stylesheet">
8+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-base/styles/material.css" rel="stylesheet">
9+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-pdfviewer/styles/material.css" rel="stylesheet">
10+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-buttons/styles/material.css" rel="stylesheet">
11+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-popups/styles/material.css" rel="stylesheet">
12+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-navigations/styles/material.css" rel="stylesheet">
13+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-dropdowns/styles/material.css" rel="stylesheet">
14+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-lists/styles/material.css" rel="stylesheet">
15+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-inputs/styles/material.css" rel="stylesheet">
16+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-splitbuttons/styles/material.css" rel="stylesheet">
17+
<link href="https://cdn.syncfusion.com/ej2/27.1.48/ej2-notifications/styles/material.css" rel="stylesheet">
18+
19+
<!-- Essential JS 2 PDF Viewer's script -->
20+
<script src="https://cdn.syncfusion.com/ej2/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
21+
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
22+
23+
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
24+
</head>
25+
<body>
26+
<button id="ExportXfdf">ExportXfdf</button>
27+
<button id="ExportJSON">ExportJSON</button>
28+
<button id="export">ExportasObject</button>
29+
<button id="import">Import</button>
30+
31+
<div id="container">
32+
<div id="PdfViewer" style="height:500px;width:100%;"></div>
33+
</div>
34+
35+
36+
<script>
37+
var ele = document.getElementById('container');
38+
if(ele) {
39+
ele.style.visibility = "visible";
40+
}
41+
</script>
42+
<script src="index.js" type="text/javascript"></script>
43+
</body></html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var pdfviewer = new ej.pdfviewer.PdfViewer({
2+
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
3+
resourceUrl:'https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib'
4+
});
5+
ej.pdfviewer.PdfViewer.Inject(ej.pdfviewer.TextSelection, ej.pdfviewer.TextSearch, ej.pdfviewer.Print, ej.pdfviewer.Navigation, ej.pdfviewer.Toolbar,
6+
ej.pdfviewer.Magnification, ej.pdfviewer.Annotation, ej.pdfviewer.FormDesigner, ej.pdfviewer.FormFields, ej.pdfviewer.PageOrganizer);
7+
pdfviewer.appendTo('#PdfViewer');
8+
9+
document.getElementById('ExportXfdf').addEventListener('click', function () {
10+
// export the annotation in XFDF format.
11+
pdfviewer.exportAnnotation('Xfdf');
12+
});
13+
14+
document.getElementById('ExportJSON').addEventListener('click', function () {
15+
// export the annotation in JSON format.
16+
pdfviewer.exportAnnotation('Json');
17+
});
18+
19+
//Export annotation as object.
20+
document.getElementById('export').addEventListener('click', () => {
21+
pdfviewer.exportAnnotationsAsObject().then(function(value) {
22+
exportObject = value;
23+
});
24+
});
25+
26+
//Import annotation that are exported as object.
27+
document.getElementById('import').addEventListener('click', () => {
28+
pdfviewer.importAnnotation(JSON.parse(exportObject));
29+
});

0 commit comments

Comments
 (0)