|
| 1 | +<template> |
| 2 | + <div id="app"> |
| 3 | + <button v-on:click="ExportAsJson">ExportAsJson</button> |
| 4 | + <button v-on:click="ExportAsXfdf">ExportAsXfdf</button> |
| 5 | + <button v-on:click="ExportAsObject">ExportAsObject</button> |
| 6 | + <button v-on:click="Import">Import</button> |
| 7 | + <ejs-pdfviewer |
| 8 | + id="pdfViewer" |
| 9 | + ref="pdfviewer" |
| 10 | + :documentPath="documentPath" |
| 11 | + :resourceUrl="resourceUrl" |
| 12 | + > |
| 13 | + </ejs-pdfviewer> |
| 14 | + </div> |
| 15 | +</template> |
| 16 | + |
| 17 | +<script> |
| 18 | +import { PdfViewerComponent, Toolbar, Magnification, Navigation, |
| 19 | + LinkAnnotation, BookmarkView, Annotation, ThumbnailView, |
| 20 | + Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } |
| 21 | +from '@syncfusion/ej2-vue-pdfviewer'; |
| 22 | +var exportObject; |
| 23 | +export default { |
| 24 | + name: 'App', |
| 25 | + components: { |
| 26 | + "ejs-pdfviewer": PdfViewerComponent |
| 27 | + }, |
| 28 | +
|
| 29 | + data () { |
| 30 | + return { |
| 31 | + resourceUrl: "https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib", |
| 32 | + documentPath: "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf", |
| 33 | + }; |
| 34 | + }, |
| 35 | + |
| 36 | + provide: { |
| 37 | + PdfViewer: [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, |
| 38 | + ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer ] |
| 39 | + }, |
| 40 | +
|
| 41 | + methods: { |
| 42 | + // export the annotation in JSON format. |
| 43 | + ExportAsJson: function() { |
| 44 | + var viewer = this.$refs.pdfviewer.ej2Instances; |
| 45 | + viewer.exportAnnotation('Json'); |
| 46 | + }, |
| 47 | +
|
| 48 | + // export the annotation in XFDF format. |
| 49 | + ExportAsXfdf: function() { |
| 50 | + var viewer = this.$refs.pdfviewer.ej2Instances; |
| 51 | + viewer.exportAnnotation('Xfdf'); |
| 52 | + }, |
| 53 | +
|
| 54 | + // export the annotation as object. |
| 55 | + ExportAsObject: function() { |
| 56 | + var viewer = this.$refs.pdfviewer.ej2Instances; |
| 57 | + return viewer.exportAnnotationsAsObject().then((value) => { |
| 58 | + exportObject = value; |
| 59 | + }); |
| 60 | + }, |
| 61 | +
|
| 62 | + //Import annotation that are exported as object. |
| 63 | + Import: function() { |
| 64 | + var viewer = this.$refs.pdfviewer.ej2Instances; |
| 65 | + viewer.importAnnotation(JSON.parse(exportObject)); |
| 66 | + } |
| 67 | +
|
| 68 | + } |
| 69 | +} |
| 70 | +</script> |
| 71 | + |
| 72 | +<style> |
| 73 | + @import "../node_modules/@syncfusion/ej2-base/styles/material.css"; |
| 74 | + @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css"; |
| 75 | + @import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css"; |
| 76 | + @import "../node_modules/@syncfusion/ej2-inputs/styles/material.css"; |
| 77 | + @import "../node_modules/@syncfusion/ej2-navigations/styles/material.css"; |
| 78 | + @import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; |
| 79 | + @import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; |
| 80 | + @import "../node_modules/@syncfusion/ej2-vue-pdfviewer/styles/material.css"; |
| 81 | +</style> |
0 commit comments