Slots Vue PDF Viewer provides slots for customizing all tools in the toolbar, allowing you to override the default UI elements. Each tool has a slot with a prefix icon, making it easy to change any icons in the toolbar.
Slots - Icons Name Description iconCommentPanelTo change the comment panel icon iconDocPropertiesTo change the document properties icon iconDownloadTo change the download icon iconFirstPageTo change the first page icon iconFullScreenTo change the full screen icon iconHandModeTo change the hand mode icon iconLastPageTo change the last page icon iconMoreOptionsTo change the more option menu icon iconNextPageTo change the next page icon iconOpenFileTo change the open local file icon iconPageViewDualTo change the dual page view icon iconPageViewDualWithCoverTo change the dual page view with cover icon iconPageViewSingleTo change the single page view icon iconPrevPageTo change the previous page icon iconPrintTo change the print icon iconRotateClockwiseTo change the rotate clockwise icon iconRotateCounterClockwiseTo change the rotate counterclockwise icon iconScrollingHorizontalTo change the horizontal scrolling icon iconScrollingPageTo change the page scrolling icon iconScrollingVerticalTo change the vertical scrolling icon iconScrollingWrappedTo change the wrapped scrolling icon iconSearchTo change the search icon iconTextSelectionTo change the text selection mode icon iconThemeDarkTo change the dark mode icon when the current state is light iconThemeLightTo change the light mode icon when the current state is dark iconThumbnailTo change the thumbnail icon iconZoomInTo change the zoom-in icon iconZoomOutTo change the zoom-out icon
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # iconPrint > < span >P</ span > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # iconPrint > < span >P</ span > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # iconPrint > < span >P</ span > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # iconPrint > < span >P</ span > </ template > </ VPdfViewer > </ div > </ template > Slots - Pages pageOverlay>=3.4.0 ThepageOverlay slot allows you to render custom content on top of each PDF page. This is useful for adding overlays, watermarks, or interactive elements that need to be positioned on specific pages.
INFO
This slot is only available for Organization license users.
Prop Description Type pageElementThe HTML element container of the PDF page HTMLElementpageIndexZero-based index of the current page numberscaleCurrent scale/zoom level of the page from viewport number
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; import { computed } from "vue" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; // Helper function to calculate responsive styles based on scale const getOverlayStyle = ( scale : number ) => { return { fontSize: `${ 14 * scale }px` , padding: `${ 8 * scale }px ${ 12 * scale }px` , top: `${ 10 * scale }px` , right: `${ 10 * scale }px` , }; }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageOverlay = " { pageIndex, scale } " > < div class = "custom-overlay" : style = " getOverlayStyle (scale) " > Page {{ pageIndex + 1 }} </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .custom-overlay { position : absolute ; background : rgba ( 0 , 0 , 0 , 0.7 ); color : white ; border-radius : 4 px ; pointer-events : auto ; transition : all 0.2 s ease ; } </ style > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; // Helper function to calculate responsive styles based on scale const getOverlayStyle = ( scale ) => { return { fontSize: `${ 14 * scale }px` , padding: `${ 8 * scale }px ${ 12 * scale }px` , top: `${ 10 * scale }px` , right: `${ 10 * scale }px` , }; }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageOverlay = " { pageIndex, scale } " > < div class = "custom-overlay" : style = " getOverlayStyle (scale) " > Page {{ pageIndex + 1 }} </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .custom-overlay { position : absolute ; background : rgba ( 0 , 0 , 0 , 0.7 ); color : white ; border-radius : 4 px ; pointer-events : auto ; transition : all 0.2 s ease ; } </ style > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, methods: { // Helper method to calculate responsive styles based on scale getOverlayStyle ( scale : number ) { return { fontSize: `${ 14 * scale }px` , padding: `${ 8 * scale }px ${ 12 * scale }px` , top: `${ 10 * scale }px` , right: `${ 10 * scale }px` , }; }, }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageOverlay = " { pageIndex, scale } " > < div class = "custom-overlay" : style = " getOverlayStyle (scale) " > Page {{ pageIndex + 1 }} </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .custom-overlay { position : absolute ; background : rgba ( 0 , 0 , 0 , 0.7 ); color : white ; border-radius : 4 px ; pointer-events : auto ; transition : all 0.2 s ease ; } </ style > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, methods: { // Helper method to calculate responsive styles based on scale getOverlayStyle ( scale ) { return { fontSize: `${ 14 * scale }px` , padding: `${ 8 * scale }px ${ 12 * scale }px` , top: `${ 10 * scale }px` , right: `${ 10 * scale }px` , }; }, }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageOverlay = " { pageIndex, scale } " > < div class = "custom-overlay" : style = " getOverlayStyle (scale) " > Page {{ pageIndex + 1 }} </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .custom-overlay { position : absolute ; background : rgba ( 0 , 0 , 0 , 0.7 ); color : white ; border-radius : 4 px ; pointer-events : auto ; transition : all 0.2 s ease ; } </ style > TIP
Scaling Strategies:
JavaScript-based scaling (shown in examples above): Multiply your base values by thescale prop for precise control over font-size, padding, and positioning.
CSS variable approach : Use the--scale-factor CSS variable for automatic scaling calculations:
css .custom-element { font-size : calc ( 14 px * var ( --scale-factor )); width : calc ( 100 px * var ( --scale-factor )); } Pointer Events: The overlay container haspointer-events: none by default, allowing clicks to pass through to the PDF. Addpointer-events: auto to your custom elements if you need them to be interactive.
Practical Tutorials For real-world implementations of thepageOverlay slot, check out these tutorials:
Slots - Tools Name Description commentPanelToolTo override the icon orcomment panel flow dropFileZoneTo change the style of the drop file zone downloadToolTo override the icon ordownload flow fullScreenToolTo override the icon orfull screen flow loaderTo replace the default loader loaderImageTo replace the default loader image loaderProgressTo show or adjust the progress percentage which is below the loader image openFileToolTo override the icon oropen file flow pageNavigationToolTo customize the display of the navigation UI printToolTo override the icon orprint flow thumbnailToolTo override the icon orthumbnail flow themeToolTo change thelight anddark icons zoomToolTo customize the display of the zoom UI
commentPanelTool Prop Description Type onClickComment panel tool function handler () => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # commentPanelTool = " { onClick } " > < button @ click = " onClick " >Comment Panel Tool</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # commentPanelTool = " { onClick } " > < button @ click = " onClick " >Comment Panel Tool</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # commentPanelTool = " { onClick } " > < button @ click = " onClick " >Comment Panel Tool</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # commentPanelTool = " { onClick } " > < button @ click = " onClick " >Comment Panel Tool</ button > </ template > </ VPdfViewer > </ div > </ template > dropFileZone Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # dropFileZone > Drop file here </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # dropFileZone > Drop file here </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # dropFileZone > Drop file here </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # dropFileZone > Drop file here </ template > </ VPdfViewer > </ div > </ template > downloadTool Prop Description Type onClickDownload file function handler () => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # downloadTool = " { onClick } " > < button @ click = " onClick " >download</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # downloadTool = " { onClick } " > < button @ click = " onClick " >download</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # downloadTool = " { onClick } " > < button @ click = " onClick " >download</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # downloadTool = " { onClick } " > < button @ click = " onClick " >download</ button > </ template > </ VPdfViewer > </ div > </ template > fullScreenTool Prop Description Type isSupported Indicate whether the browser's full screen mode is supported booleanonClick Full screen function handler () => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # fullScreenTool = " { onClick, isSupported } " > < button @ click = " onClick " : disabled = " ! isSupported " >full screen</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # fullScreenTool = " { onClick, isSupported } " > < button @ click = " onClick " : disabled = " ! isSupported " >full screen</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # fullScreenTool = " { onClick, isSupported } " > < button @ click = " onClick " : disabled = " ! isSupported " >full screen</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # fullScreenTool = " { onClick, isSupported } " > < button @ click = " onClick " : disabled = " ! isSupported " >full screen</ button > </ template > </ VPdfViewer > </ div > </ template > loader Prop Description Type progressState of loading progress in percentage numberloadedReturntrue when the PDF has finished loading boolean
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loader = " { progress, loaded } " > < div v-if = " ! loaded " class = "loader-wrapper" > < img src = "/your-loader.gif" /> </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .loader-wrapper { position : absolute ; z-index : 12 ; inset : 0 ; display : flex ; align-items : center ; justify-content : center ; background-color : rgb ( 251 191 36 / 0.75 ); } </ style > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loader = " { progress, loaded } " > < div v-if = " ! loaded " class = "loader-wrapper" > < img src = "/your-loader.gif" /> </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .loader-wrapper { position : absolute ; z-index : 12 ; inset : 0 ; display : flex ; align-items : center ; justify-content : center ; background-color : rgb ( 251 191 36 / 0.75 ); } </ style > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loader = " { progress, loaded } " > < div v-if = " ! loaded " class = "loader-wrapper" > < img src = "/your-loader.gif" /> </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .loader-wrapper { position : absolute ; z-index : 12 ; inset : 0 ; display : flex ; align-items : center ; justify-content : center ; background-color : rgb ( 251 191 36 / 0.75 ); } </ style > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loader = " { progress, loaded } " > < div v-if = " ! loaded " class = "loader-wrapper" > < img src = "/your-loader.gif" /> </ div > </ template > </ VPdfViewer > </ div > </ template > < style scoped > .loader-wrapper { position : absolute ; z-index : 12 ; inset : 0 ; display : flex ; align-items : center ; justify-content : center ; background-color : rgb ( 251 191 36 / 0.75 ); } </ style > loaderImage Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderImage > < img src = "/your-spin-image.png" width = "80" height = "80" /> </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderImage > < img src = "/your-spin-image.png" width = "80" height = "80" /> </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderImage > < img src = "/your-spin-image.png" width = "80" height = "80" /> </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderImage > < img src = "/your-spin-image.png" width = "80" height = "80" /> </ template > </ VPdfViewer > </ div > </ template > loaderProgress Prop Description Type progressState of loading progress in percentage number
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderProgress = " { progress } " > < p class = "m-0" > < strong >{{ progress }}</ strong > </ p > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderProgress = " { progress } " > < p class = "m-0" > < strong >{{ progress }}</ strong > </ p > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderProgress = " { progress } " > < p class = "m-0" > < strong >{{ progress }}</ strong > </ p > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # loaderProgress = " { progress } " > < p class = "m-0" > < strong >{{ progress }}</ strong > </ p > </ template > </ VPdfViewer > </ div > </ template > openFileTool Prop Description Type onClick Open file function handler () => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # openFileTool = " { onClick } " > < button @ click = " onClick " >open local file</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # openFileTool = " { onClick } " > < button @ click = " onClick " >open local file</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # openFileTool = " { onClick } " > < button @ click = " onClick " >open local file</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # openFileTool = " { onClick } " > < button @ click = " onClick " >open local file</ button > </ template > </ VPdfViewer > </ div > </ template > pageNavigationTool Prop Description Type totalTotal page count of the PDF document numbercurrentCurrent page number numberonNextNext page function handler () => voidonPrevPrevious page function handler () => voidonChangePagePage change function handler (page: number) => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; const handlePageEntered = ( e : Event , changePage : ( pageNumber : number ) => void ) => { const value = (e.target as HTMLInputElement ).value; changePage ( + value); }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageNavigationTool = " { total, current, onNext, onPrev, onChangePage } " > < input : value = " current " @ keyup . enter = " handlePageEntered ($event, onChangePage) " />/{{ total }} < button @ click = " onPrev " >Previous</ button > < button @ click = " onNext " >Next</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; const handlePageEntered = ( e , changePage ) => { const value = e.target.value; changePage ( + value); }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageNavigationTool = " { total, current, onNext, onPrev, onChangePage } " > < input : value = " current " @ keyup . enter = " handlePageEntered ($event, onChangePage) " />/{{ total }} < button @ click = " onPrev " >Previous</ button > < button @ click = " onNext " >Next</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, methods: { handlePageEntered ( e , changePage ) { const value = e.target.value; changePage ( + value); }, }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageNavigationTool = " { total, current, onNext, onPrev, onChangePage } " > < input : value = " current " @ keyup . enter = " handlePageEntered ($event, onChangePage) " />/{{ total }} < button @ click = " onPrev " >Previous</ button > < button @ click = " onNext " >Next</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, methods: { handlePageEntered ( e , changePage ) { const value = e.target.value; changePage ( + value); }, }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # pageNavigationTool = " { total, current, onNext, onPrev, onChangePage } " > < input : value = " current " @ keyup . enter = " handlePageEntered ($event, onChangePage) " />/{{ total }} < button @ click = " onPrev " >Previous</ button > < button @ click = " onNext " >Next</ button > </ template > </ VPdfViewer > </ div > </ template > printTool Prop Description Type onClickPrint PDF function handler () => void
Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # printTool = " { onClick } " > < button @ click = " onClick " >Print</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # printTool = " { onClick } " > < button @ click = " onClick " >Print</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # printTool = " { onClick } " > < button @ click = " onClick " >Print</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # printTool = " { onClick } " > < button @ click = " onClick " >Print</ button > </ template > </ VPdfViewer > </ div > </ template > themeTool Prop Description Type isDarkState of the browser preference mode booleanonClickFunction to switch the Viewer's appearence boolean
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # themeTool = " { isDark, onClick } " > < button @ click = " onClick " > < span v-if = " isDark " >Day</ span > < span v-else >Night</ span > </ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # themeTool = " { isDark, onClick } " > < button @ click = " onClick " > < span v-if = " isDark " >Day</ span > < span v-else >Night</ span > </ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # themeTool = " { isDark, onClick } " > < button @ click = " onClick " > < span v-if = " isDark " >Day</ span > < span v-else >Night</ span > </ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # themeTool = " { isDark, onClick } " > < button @ click = " onClick " > < span v-if = " isDark " >Day</ span > < span v-else >Night</ span > </ button > </ template > </ VPdfViewer > </ div > </ template > thumbnailTool Prop Description Type onToggleFunction to toggle the visibility of the thumbnail sidebar () => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # thumbnailTool = " { onToggle } " > < button @ click = " onToggle " >T</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # thumbnailTool = " { onToggle } " > < button @ click = " onToggle " >T</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # thumbnailTool = " { onToggle } " > < button @ click = " onToggle " >T</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # thumbnailTool = " { onToggle } " > < button @ click = " onToggle " >T</ button > </ template > </ VPdfViewer > </ div > </ template > zoomTool Prop Description Type currentScaleCurrent scale of the Vue PDF Viewer numberzoomZoom function (nextScale: number) => void
Example Composition TS Composition JS Options TS Options JS
vue < script setup lang = "ts" > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # zoomTool = " { currentScale, zoom } " > < button @ click = " zoom (currentScale - 2 ) " >ZoomOut</ button > < strong >{{ currentScale }}</ strong > < button @ click = " zoom (currentScale + 5 ) " >ZoomIn</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script setup > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; const pdfFileSource = "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" ; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # zoomTool = " { currentScale, zoom } " > < button @ click = " zoom (currentScale - 2 ) " >ZoomOut</ button > < strong >{{ currentScale }}</ strong > < button @ click = " zoom (currentScale + 5 ) " >ZoomIn</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script lang = "ts" > import { defineComponent } from "vue" ; import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default defineComponent ({ components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }); </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # zoomTool = " { currentScale, zoom } " > < button @ click = " zoom (currentScale - 2 ) " >ZoomOut</ button > < strong >{{ currentScale }}</ strong > < button @ click = " zoom (currentScale + 5 ) " >ZoomIn</ button > </ template > </ VPdfViewer > </ div > </ template > vue < script > import { VPdfViewer } from "@vue-pdf-viewer/viewer" ; export default { components: { VPdfViewer }, data () { return { pdfFileSource: "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf" , }; }, }; </ script > < template > < div : style = " { width: '1028px' , height: '700px' } " > < VPdfViewer : src = " pdfFileSource " > < template # zoomTool = " { currentScale, zoom } " > < button @ click = " zoom (currentScale - 2 ) " >ZoomOut</ button > < strong >{{ currentScale }}</ strong > < button @ click = " zoom (currentScale + 5 ) " >ZoomIn</ button > </ template > </ VPdfViewer > </ div > </ template >