|
| 1 | +<template> |
| 2 | + <div id="app"> |
| 3 | + <button v-on:click="findTextBounds">FindTextBounds</button> |
| 4 | + <ejs-pdfviewer |
| 5 | + id="pdfViewer" |
| 6 | + ref="pdfviewer" |
| 7 | + :documentPath="documentPath" |
| 8 | + :resourceUrl="resourceUrl"> |
| 9 | + </ejs-pdfviewer> |
| 10 | + </div> |
| 11 | +</template> |
| 12 | + |
| 13 | +<script> |
| 14 | +import Vue from 'vue'; |
| 15 | +import { PdfViewerPlugin, Toolbar, Magnification, Navigation, |
| 16 | + LinkAnnotation, BookmarkView, Annotation, ThumbnailView, |
| 17 | + Print, TextSelection, TextSearch, FormFields, FormDesigner,PageOrganizer } from '@syncfusion/ej2-vue-pdfviewer'; |
| 18 | +Vue.use(PdfViewerPlugin); |
| 19 | +
|
| 20 | +export default { |
| 21 | + name: 'app', |
| 22 | + data () { |
| 23 | + return { |
| 24 | + resourceUrl:"https://cdn.syncfusion.com/ej2/27.1.48/dist/ej2-pdfviewer-lib", |
| 25 | + documentPath:"https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" |
| 26 | + }; |
| 27 | + }, |
| 28 | + provide: { |
| 29 | + PdfViewer: [ Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, Annotation, |
| 30 | + ThumbnailView, Print, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer ]}, |
| 31 | +
|
| 32 | + methods: { |
| 33 | + findTextBounds: function () { |
| 34 | + var viewer = this.$refs.pdfviewer.ej2Instances; |
| 35 | + // Find and get the bounds of a text |
| 36 | + console.log(viewer.textSearch.findText('adobe', false)); |
| 37 | + // Find and get the bounds of a text on the desired page |
| 38 | + console.log(viewer.textSearch.findText('adobe', false, 7)); |
| 39 | + // Find and get the bounds of the list of text |
| 40 | + console.log(viewer.textSearch.findText(['adobe', 'pdf'], false)); |
| 41 | + // Find and get the bounds of the list of text on desired page |
| 42 | + console.log(viewer.textSearch.findText(['adobe', 'pdf'], false, 7)); |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | +</script> |
| 47 | + |
| 48 | +<style> |
| 49 | + @import "../node_modules/@syncfusion/ej2-base/styles/material.css"; |
| 50 | + @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css"; |
| 51 | + @import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css"; |
| 52 | + @import "../node_modules/@syncfusion/ej2-inputs/styles/material.css"; |
| 53 | + @import "../node_modules/@syncfusion/ej2-navigations/styles/material.css"; |
| 54 | + @import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; |
| 55 | + @import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; |
| 56 | + @import "../node_modules/@syncfusion/ej2-vue-pdfviewer/styles/material.css"; |
| 57 | +</style> |
0 commit comments