|
| 1 | +<template> |
| 2 | + <div id="app"> |
| 3 | + <ejs-pdfviewer |
| 4 | + id="pdfViewer" |
| 5 | + ref="pdfviewer" |
| 6 | + :documentPath="documentPath" |
| 7 | + :documentLoad="documentLoad" |
| 8 | + :resourceUrl="resourceUrl" |
| 9 | + :toolbarClick="toolbarClick" |
| 10 | + :toolbarSettings="toolbarSettings"> |
| 11 | + </ejs-pdfviewer> |
| 12 | + </div> |
| 13 | +</template> |
| 14 | +<script> |
| 15 | +import Vue from 'vue'; |
| 16 | +import { PdfViewerPlugin, Toolbar, Magnification, Navigation, LinkAnnotation, |
| 17 | + BookmarkView, ThumbnailView, Print, TextSelection, TextSearch, |
| 18 | + Annotation, FormDesigner, FormFields, PageOrganizer } from '@syncfusion/ej2-vue-pdfviewer'; |
| 19 | +Vue.use(PdfViewerPlugin); |
| 20 | +var viewer; |
| 21 | +export default { |
| 22 | + name: 'app', |
| 23 | + data () { |
| 24 | + // Move the toolItem declaration inside the data function |
| 25 | + var toolItem1 = { |
| 26 | + prefixIcon: 'e-icons e-save', |
| 27 | + id: 'download', |
| 28 | + text: 'Save', |
| 29 | + tooltipText: 'Save Button', |
| 30 | + align: 'left' |
| 31 | + }; |
| 32 | + return { |
| 33 | + documentPath: "https://cdn.syncfusion.com/content/pdf/form-designer.pdf", |
| 34 | + resourceUrl: "https://cdn.syncfusion.com/ej2/24.1.41/dist/ej2-pdfviewer-lib", |
| 35 | + toolbarSettings: { |
| 36 | + toolbarItems: ['OpenOption', toolItem1, 'PageNavigationTool', 'MagnificationTool', 'PanTool', 'SelectionTool', 'SearchOption', 'PrintOption', 'UndoRedoTool', 'AnnotationEditTool', 'FormDesignerEditTool', 'CommentTool', 'SubmitForm'] |
| 37 | + } |
| 38 | + }; |
| 39 | + }, |
| 40 | +
|
| 41 | + provide: { |
| 42 | + PdfViewer: [Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, |
| 43 | + Print, TextSelection, TextSearch, Annotation, FormDesigner, FormFields, PageOrganizer ] |
| 44 | + }, |
| 45 | +
|
| 46 | + methods: { |
| 47 | + documentLoad: function () { |
| 48 | + viewer = this.$refs.pdfviewer.ej2Instances; |
| 49 | + }, |
| 50 | + toolbarClick: function (args) { |
| 51 | + if (args.item && args.item.id === 'download') { |
| 52 | + viewer.download(); |
| 53 | + } |
| 54 | + }, |
| 55 | + } |
| 56 | +} |
| 57 | +</script> |
| 58 | +<style> |
| 59 | + @import "../node_modules/@syncfusion/ej2-base/styles/material.css"; |
| 60 | + @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css"; |
| 61 | + @import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css"; |
| 62 | + @import "../node_modules/@syncfusion/ej2-inputs/styles/material.css"; |
| 63 | + @import "../node_modules/@syncfusion/ej2-navigations/styles/material.css"; |
| 64 | + @import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; |
| 65 | + @import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; |
| 66 | + @import "../node_modules/@syncfusion/ej2-pdfviewer/styles/material.css"; |
| 67 | +</style> |
0 commit comments