|
| 1 | +<template> |
| 2 | + <div id="app"> |
| 3 | + <button v-on:click="findText">findText</button> |
| 4 | + <button v-on:click="findTexts">findTexts</button> |
| 5 | + <ejs-pdfviewer |
| 6 | + id="pdfViewer" |
| 7 | + ref="pdfviewer" |
| 8 | + :documentPath="documentPath" |
| 9 | + :resourceUrl="resourceUrl"> |
| 10 | + </ejs-pdfviewer> |
| 11 | + </div> |
| 12 | +</template> |
| 13 | + |
| 14 | +<script> |
| 15 | +import {PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView, Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner } from '@syncfusion/ej2-vue-pdfviewer'; |
| 16 | +
|
| 17 | +export default { |
| 18 | + name: 'app', |
| 19 | + components: { |
| 20 | + 'ejs-pdfviewer': PdfViewerComponent, |
| 21 | + }, |
| 22 | + data() { |
| 23 | + return { |
| 24 | + documentPath: "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf", |
| 25 | + resourceUrl: "https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2-pdfviewer-lib" |
| 26 | + }; |
| 27 | + }, |
| 28 | + provide: { |
| 29 | + PdfViewer: [ |
| 30 | + Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, |
| 31 | + ThumbnailView, Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner |
| 32 | + ] |
| 33 | + }, |
| 34 | + methods: { |
| 35 | + // Search for a single string 'pdf' with a case-insensitive search across all pages |
| 36 | + findText() { |
| 37 | + const viewer = this.$refs.pdfviewer.ej2Instances; |
| 38 | + viewer.textSearchModule.findTextAsync('pdf', false).then(res => { |
| 39 | + console.log(res); |
| 40 | + }); |
| 41 | + }, |
| 42 | + // Search for multiple strings ['pdf', 'the'] with a case-insensitive search across all pages |
| 43 | + findTexts() { |
| 44 | + const viewer = this.$refs.pdfviewer.ej2Instances; |
| 45 | + viewer.textSearchModule.findTextAsync(['pdf', 'the'], false).then(res => { |
| 46 | + console.log(res); |
| 47 | + }); |
| 48 | + } |
| 49 | + } |
| 50 | +}; |
| 51 | +</script> |
| 52 | + |
| 53 | +<style> |
| 54 | +@import "../node_modules/@syncfusion/ej2-base/styles/material.css"; |
| 55 | +@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css"; |
| 56 | +@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css"; |
| 57 | +@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css"; |
| 58 | +@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css"; |
| 59 | +@import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; |
| 60 | +@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; |
| 61 | +@import "../node_modules/@syncfusion/ej2-vue-pdfviewer/styles/material.css"; |
| 62 | +</style> |
0 commit comments