|
| 1 | +<template> |
| 2 | + <div id="app"> |
| 3 | + <button @click="retrievePageInfo" style="margin-bottom: 20px;"> |
| 4 | + GetPageInfo |
| 5 | + </button> |
| 6 | + <ejs-pdfviewer |
| 7 | + id="pdfViewer" |
| 8 | + ref="pdfviewer" |
| 9 | + :documentPath="documentPath" |
| 10 | + :resourceUrl="resourceUrl" |
| 11 | + style="height: 640px;" |
| 12 | + > |
| 13 | + </ejs-pdfviewer> |
| 14 | + </div> |
| 15 | +</template> |
| 16 | + |
| 17 | +<script> |
| 18 | +import { |
| 19 | + PdfViewerComponent, |
| 20 | + Toolbar, |
| 21 | + Magnification, |
| 22 | + Navigation, |
| 23 | + Annotation, |
| 24 | + TextSelection, |
| 25 | + TextSearch, |
| 26 | + FormFields, |
| 27 | + FormDesigner, |
| 28 | + PageOrganizer, |
| 29 | +} from '@syncfusion/ej2-vue-pdfviewer'; |
| 30 | +
|
| 31 | +export default { |
| 32 | + name: 'App', |
| 33 | + components: { |
| 34 | + 'ejs-pdfviewer': PdfViewerComponent, |
| 35 | + }, |
| 36 | + data() { |
| 37 | + return { |
| 38 | + documentPath: "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf", |
| 39 | + resourceUrl: "https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2-pdfviewer-lib", |
| 40 | + }; |
| 41 | + }, |
| 42 | + provide: { |
| 43 | + PdfViewer: [ |
| 44 | + Toolbar, |
| 45 | + Magnification, |
| 46 | + Navigation, |
| 47 | + Annotation, |
| 48 | + TextSelection, |
| 49 | + TextSearch, |
| 50 | + FormFields, |
| 51 | + FormDesigner, |
| 52 | + PageOrganizer, |
| 53 | + ], |
| 54 | + }, |
| 55 | + methods: { |
| 56 | + retrievePageInfo() { |
| 57 | + if (this.$refs.pdfviewer) { |
| 58 | + const pdfviewer = this.$refs.pdfviewer.ej2Instances; |
| 59 | + // Set the page index for which info is required |
| 60 | + const pageIndex = 0; |
| 61 | + // To Retrieve and log the page information |
| 62 | + console.log(pdfviewer.getPageInfo(pageIndex)); |
| 63 | +
|
| 64 | + // To Log the specific page information details to the console |
| 65 | + const pageInfo = pdfviewer.getPageInfo(pageIndex); |
| 66 | + if (pageInfo) { |
| 67 | + console.log(`Page Info for Page Index ${pageIndex}:`); |
| 68 | + console.log(`Height: ${pageInfo.height}`); |
| 69 | + console.log(`Width: ${pageInfo.width}`); |
| 70 | + console.log(`Rotation: ${pageInfo.rotation}`); |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + }, |
| 75 | +}; |
| 76 | +</script> |
| 77 | + |
| 78 | +<style> |
| 79 | +@import "../node_modules/@syncfusion/ej2-base/styles/material.css"; |
| 80 | +@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css"; |
| 81 | +@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css"; |
| 82 | +@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css"; |
| 83 | +@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css"; |
| 84 | +@import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; |
| 85 | +@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; |
| 86 | +@import "../node_modules/@syncfusion/ej2-vue-pdfviewer/styles/material.css"; |
| 87 | +</style> |
0 commit comments