Skip to content

Component API

Props

NameDescriptionTypeDefault
characterMapSpecify the character map (CMap) to be used for text rendering.CharacterMapundefined
darkModeTo set dark theme for the VPV. This can be used with the @update:dark-mode event.v-model:booleanfalse
initialPageThe page number of the PDF document that will be displayed on first load.number1
initialRotationThe initial rotation of the PDF document with respect to the VPV viewer.number0 (0, 90, 180, 270)
initialScaleThe initial zoom level of the PDF document with respect to VPV. If unspecified, it is determined by the page dimensions and the width of the container.numberZoomLevel.PageFit (Scale ranges from 0 to 1.)
initialScrollMode betaThe initial scroll mode of VPVScrollModeScrollMode.Vertical
initialThumbnailsVisibleTo display thumbnail on first loadbooleanfalse
initialViewMode betaThe initial view mode of VPVViewModeViewMode.SinglePage
srcSource of the PDF documentstring, Ref<string>-
textLayerA layer on a PDF to allow users to select text
Remark: Search, highlight text, and selection mode features depend on this property. If you disable it, these features won't work.
booleantrue
toolbarOptionsDetermine whether the toolbar is visible in the VPV.
Remark: The toolbar consists of top bar and left sidebar
Partial<ToolbarOptions> \false | ToolbarOptions, If false, the toolbar will not show.
workerUrlThe URL or relative path pointing to the web worker file for handling PDF document which must correspond to the pdfjs-dist version being used.
Normally, you will not need to configure the workerURL. To do so, please refer to the advanced configuration
string-
localeThe locale string key, which must match the key of the localization object; otherwise, it will fall back to en_USv-model:stringen_US
localizationThe locale object that will be used in the componentRecord<string, Localization>{ en_US: ...locale, zh_CN: ...locale, it_IT: ...locale, pt_PT: ...locale, th_TH: ...locale }

Events

EventDescriptionArgument type
loadProgressEmit the percentage of the PDF file loadednumber
loadedEmit when the PDF has finished loading-
rotateEmit when the PDF is rotated to a certain directionRotateEvent
update:darkModeEmit when the appearance mode changes to or from dark mode. More Infoboolean

loadProgress

ArgumentDescription
fn(value: number)Indicate the loading percentage

Example

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 onLoadProgress = (progress: number) => {
  // Do something with the loading progress percentage
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loadProgress="onLoadProgress" />
  </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 onLoadProgress = (progress) => {
  // Do something with the loading progress percentage
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loadProgress="onLoadProgress" />
  </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: {
    onLoadProgress(progress) {
      // Do something with the loading progress percentage
    },
  },
});
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loadProgress="onLoadProgress" />
  </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: {
    onLoadProgress(progress) {
      // Do something with the loading progress percentage
    },
  },
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loadProgress="onLoadProgress" />
  </div>
</template>

loaded

Example

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 onLoaded = () => {
  // PDF is already loaded
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loaded="onLoaded" />
  </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 onLoaded = () => {
  // PDF is already loaded
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loaded="onLoaded" />
  </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: {
    onLoaded() {
      // PDF is already loaded
    },
  },
});
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loaded="onLoaded" />
  </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: {
    onLoaded() {
      // PDF is already loaded
    },
  },
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @loaded="onLoaded" />
  </div>
</template>

rotate

ArgumentDescription
fn(value: RotateEvent)Indicate the rotation value

RotateEvent

KeyDescriptionType
directionLatest rotation direction`'clockwise' \'counterclockwise'`
rotateLatest rotation numbernumber

Example

vue
<script setup lang="ts">
import { VPdfViewer, type RotateEvent } from "@vue-pdf-viewer/viewer";
const pdfFileSource =
  "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf";
const onRotated = (value: RotateEvent) => {
  // Do something with the rotate event callback
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @rotate="onRotated" />
  </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 onRotated = (value) => {
  // Do something with the rotate event callback
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @rotate="onRotate" />
  </div>
</template>
vue
<script lang="ts">
import { defineComponent } from "vue";
import { VPdfViewer, type RotateEvent } 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: {
    onRotated(value) {
      // Do something with the rotate event callback
    },
  },
});
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @rotate="onRotate" />
  </div>
</template>
vue
<script>
import { VPdfViewer, type RotateEvent } 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: {
    onRotated(value) {
  // Do something with the rotate event callback
    }
  }
}
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @rotate="onRotate" />
  </div>
</template>

update:darkMode

ArgumentDescription
fn(value: boolean)Indicate that the current appearance is True if in dark mode

Example

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 onDarkModeChange = (isDark: boolean) => {
  // Do something with the current appearance mode
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @update:darkMode="onDarkModeChange" />
  </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 onDarkModeChange = (isDark) => {
  // Do something with the current appearance mode
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @update:darkMode="onDarkModeChange" />
  </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: {
    onDarkModeChange(isDark) {
      // Do something with the current appearance mode
    },
  },
});
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @update:darkMode="onDarkModeChange" />
  </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: {
    onDarkModeChange(isDark) {
      // Do something with the current appearance mode
    },
  },
};
</script>
<template>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer :src="pdfFileSource" @update:darkMode="onDarkModeChange" />
  </div>
</template>

Slots

VPV 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

NameDescription
iconThumbnailTo change the thumbnail icon
iconSearchTo change the search icon
iconPrevPageTo change the previous page icon
iconNextPageTo change the next page icon
iconZoomOutTo change the zoom-out icon
iconZoomInTo change the zoom-in 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
iconOpenFileTo change the open local file icon
iconDownloadTo change the download icon
iconPrintTo change the print icon
iconFullScreenTo change the full screen icon
iconMoreOptionsTo change the more option menu icon
iconFirstPageTo change the first page icon
iconLastPageTo change the last page icon
iconRotateClockwiseTo change the rotate clockwise icon
iconRotateCounterClockwiseTo change the rotate counterclockwise icon
iconTextSelectionTo change the text selection mode icon
iconHandModeTo change the hand mode icon
iconScrollingPageTo change the page scrolling icon
iconScrollingVerticalTo change the vertical scrolling icon
iconScrollingHorizontalTo change the horizontal scrolling icon
iconScrollingWrappedTo change the wrapped scrolling icon
iconPageViewSingleTo change the single page view icon
iconPageViewDualTo change the dual page view icon
iconDocPropertiesTo change the document properties icon

Example

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 - Tools

NameDescription
dropFileZoneTo change the style of the drop file zone
downloadToolTo override the icon or download flow
fullScreenToolTo override the icon or full 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 or open file flow
pageNavigationToolTo customize the display of the navigation UI
printToolTo override the icon or print flow
thumbnailToolTo override the icon or thumbnail flow
themeToolTo change the light and dark icons
zoomToolTo customize the display of the zoom UI

dropFileZone

Example

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

PropDescriptionType
onClickDownload file function handler() => void

Example

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

PropDescriptionType
isSupportedIndicate whether the browser's full screen mode is supportedboolean
onClickFull screen function handler() => void

Example

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

PropDescriptionType
progressState of loading progress in percentagenumber
loadedReturn true when the PDF has finished loadingboolean

Example

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

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

PropDescriptionType
progressState of loading progress in percentagenumber

Example

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

PropDescriptionType
onClickOpen file function handler() => void

Example

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>
PropDescriptionType
totalTotal page count of the PDF documentnumber
currentCurrent page numbernumber
onNextNext page function handler() => void
onPrevPrevious page function handler() => void
onChangePagePage change function handler(page: number) => void

Example

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

PropDescriptionType
onClickPrint PDF function handler() => void
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

PropDescriptionType
isDarkState of the browser preference modeboolean
onClickFunction to switch the VPV's appearenceboolean

Example

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

PropDescriptionType
onToggleFunction to toggle the visibility of the thumbnail sidebar() => void

Example

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

PropDescriptionType
currentScaleCurrent scale of the Vue PDF Viewernumber
zoomZoom function(nextScale: number) => void

Example

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>

Interfaces

CharacterMap

KeyDescriptionType
urlThe URL or relative path where the predefined Adobe CMaps are located. It must have / at the end.string
isCompressedSpecify if the Adobe CMaps are binary packed. The default value is true.boolean
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"
      :character-map="{
        url: 'https://cdn.jsdelivr.net/npm/[email protected]/cmaps/',
        isCompressed: true,
      }"
    />
  </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"
      :character-map="{
        url: 'https://cdn.jsdelivr.net/npm/[email protected]/cmaps/',
        isCompressed: true,
      }"
    />
  </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"
      :character-map="{
        url: 'https://cdn.jsdelivr.net/npm/[email protected]/cmaps/',
        isCompressed: true,
      }"
    />
  </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"
      :character-map="{
        url: 'https://cdn.jsdelivr.net/npm/[email protected]/cmaps/',
        isCompressed: true,
      }"
    />
  </div>
</template>

When you download CMaps files and place them in the public/cmaps directory

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"
      :character-map="{
        url: '/cmaps/',
        isCompressed: true,
      }"
    />
  </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"
      :character-map="{
        url: '/cmaps/',
        isCompressed: true,
      }"
    />
  </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"
      :character-map="{
        url: '/cmaps/',
        isCompressed: true,
      }"
    />
  </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"
      :character-map="{
        url: '/cmaps/',
        isCompressed: true,
      }"
    />
  </div>
</template>

ToolbarOptions

The toolbar consists of top bar and left sidebar. The tools are icons located on the Vue PDF Viewer's toolbar.

KeyDescriptionType
docPropertiesEnabledDetermine whether the toolbar will show the icon of the document properties icon
Remark: This icon is part of More Options icon.
boolean
downloadableSpecify whether the toolbar will show the download iconboolean
fullscreenIndicate whether the toolbar will show the fullscreen iconboolean
jumpNavigatableDetermine whether the toolbar will show the first page & last page assets
Remark: This icon is part of More Options icon.
boolean
pointerSwitchableDetermine whether the toolbar will show the selection mode assets
Remark: This icon is part of More Options icon.
boolean
navigatableIndicate whether the toolbar will show the navigation assetsboolean
newFileOpenableIndicate whether the toolbar will show the icon to open local file, including the drag-and-drop zoneboolean
printableDetermine whether the toolbar will show the print iconboolean
rotatableSpecify whether whether the toolbar will show the rotation assets
Remark: This icon is part of More Options icon.
boolean
searchableDetermine whether the toolbar will show the search icon
Remark: The text-layer property must be true.
boolean
sidebarEnableDetermine whether the toolbar will show the sidebarboolean
themeSwitchableSpecify whether the toolbar will show the icon to switch theme
Remark: themeSwtichable may be used together with is-dark prop and @dark-mode-changed emit event.
boolean
thumbnailViewableIndicate whether the toolbar will show the thumbnail iconboolean
zoomableSpecify whether the toolbar will show the zoom assetsboolean

Remark: The toolbar will show all options by default since each key's value is set to true.

docPropertiesEnabled, jumpNavigatable, pointerSwitchable and rotatable are grouped within ... icon (More Options). There are two conditions to hide More Options:

  1. Set false on the 4 keys mentioned above - This will hide More Options on the desktop view;
  2. Repeat step 1 and set false on downloadable, fullscreen, newFileOpenable and printable - This will hide More Options on the mobile view.

Here is an example of how to disable the search icon on the toolbar

vue
<script setup lang="ts">
import { VPdfViewer, type ToolbarOptions } from "@vue-pdf-viewer/viewer";

const toolbarOptions: Partial<ToolbarOptions> = {
  searchable: false,
};
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" :toolbarOptions="toolbarOptions" />
  </div>
</template>
vue
<script setup>
import { VPdfViewer } from "@vue-pdf-viewer/viewer";

const toolbarOptions = {
  searchable: false,
};
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" :toolbarOptions="toolbarOptions" />
  </div>
</template>
vue
<script lang="ts">
import { defineComponent } from "vue";
import { VPdfViewer } from "@vue-pdf-viewer/viewer";

export default defineComponent({
  components: { VPdfViewer },
  data() {
    return {
      toolbarOptions: { searchable: false },
      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" :toolbarOptions="toolbarOptions" />
  </div>
</template>
vue
<script>
import { VPdfViewer } from "@vue-pdf-viewer/viewer";

export default {
  components: { VPdfViewer },
  data() {
    return {
      toolbarOptions: {
        searchable: false,
        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" :toolbarOptions="toolbarOptions" />
  </div>
</template>

Localization

Currently, Vue PDF Viewer component comes with built-in translations of 5 languages, namely: The default localizations provided are:

  • en_US (English - United States)
  • it_IT (Italian - Italy)
  • pt_PT (Portuguese - Portugal)
  • th_TH (Thai - Thailand)
  • zh_CN (Chinese - China)

To change the translations, VPV provide localization keys for easy customization. Each key corresponds to a specific text that will be displayed in the component for each locale.

Here are the keys you can localize:

KeyDescriptionTypeDefault (en_US)
documentPropertiesLabelLabel of the document properties option in More Options and the title of document properties modalstringDocument properties
documentPropertiesTooltipTooltip text of the document properties optionstringView document properties
dragDropFileMessageMessage of the drag & drop mask when a file is dragged over the componentstringDrag and drop the PDF file here
dualPageLabelLabel of the dual page panel in More OptionsstringDual Page
firstPageLabelLabel of the first page option in More OptionsstringFirst page
firstPageTooltipTooltip text of the first page optionstringGo to first page
fullScreenLabelLabel of the full screen option in More Options on mobile responsivestringFull screen
fullScreenTooltipTooltip text of the full screen button and the full screen optionstringFull screen
handToolLabelLabel of the hand tool option in More optionsstringHand tool
handToolTooltipTooltip text of the hand tool optionstringEnable hand tool
lastPageLabelLabel of the last page option in More OptionsstringLast page
lastPageTooltipTooltip text of the last page optionstringGo to last page
moreOptionTooltipTooltip text of the More Options buttonstringMore options
nextPageTooltipTooltip text of the next page buttonstringNext page
openLocalFileLabelLabel of open local file option within More Options on mobile responsivestringOpen local file
openLocalFileTooltipTooltip text of the open local file button and open local file optionstringOpen local file
pageScrollingLabelLabel of the page scrolling option in More OptionsstringPage Scrolling
passwordConfirmLabelLabel of the confirm button in the password modalstringSubmit
passwordErrorError message in the password modal when the password is incorrectstringIncorrect password
passwordModalMessageDescription message of the input password modalstringThis document is password protected. Please enter a password to open the file
passwordModalTitleTitle of the input password modalstringPassword Required
passwordPlaceholderInput placeholder of the password modalstringEnter password
previousPageTooltipTooltip text of the previous page buttonstringPrevious page
printCancelLabelLabel of the button to cancel printing processstringCancel
printLabelLabel of print option in More Options on mobile responsivestringPrint
printLoadingMessageLoading message on the progress modal while preparing printingstringPreparing Document
printTooltipTooltip text of the print button and the print optionstringPrint
propertiesAuthorLabelLabel of the author in document properties modalstringAuthor
propertiesCreateOnLabelLabel of the created date in document properties modalstringCreated on
propertiesCreatorLabelLabel of the creator in document properties modalstringCreator
propertiesFilenameLabelLabel of the filename in document properties modalstringFile name
propertiesFileSizeLabelLabel of the file size in document properties modalstringFile size
propertiesKeywordLabelLabel of the keyword in document properties modalstringKeywords
propertiesModifiedOnLabelLabel of the modified date in document properties modalstringModified on
propertiesPDFProducerLabelLabel of the PDF producer in document properties modalstringPDF producer
propertiesPDFVersionLabelLabel of the PDF version in document properties modalstringPDF version
propertiesPageCountLabelLabel of the page count in document properties modalstringPage count
propertiesSubjectLabelLabel of the subject in document properties modalstringSubject
propertiesTitleLabelLabel of the title in document properties modalstringTitle
rotateClockwiseLabelLabel of the rotate clockwise option in More OptionsstringRotate clockwise
rotateClockwiseTooltipTooltip text of the rotate clockwise optionstringRotate clockwise
rotateCounterclockwiseLabelLabel of the rotate counterclockwise option in More OptionsstringRotate counterclockwise
rotateCounterclockwiseTooltipTooltip text of the rotate counterclockwise optionstringRotate counterclockwise
searchButtonTooltipTooltip text of the search buttonstringSearch in Document
searchCloseButtonTooltipTooltip text of the close icon for the search popoverstringClose
searchInputPlaceholderPlaceholder of the search inputstringEnter to search
searchNextTooltipTooltip text of the next search match iconstringNext match
searchPrevTooltipTooltip text of the previous search match iconstringPrevious match
singlePageLabelLabel of the single page panel option in More OptionsstringSingle Page
textSelectionLabelLabel of the text selection option in More OptionsstringText selection tool
textSelectionTooltipTooltip text of the text selection optionstringEnable text selection tool
themeEnableDarkTooltipTooltip text of the button to enable dark themestringEnable dark theme
themeEnableLightTooltipTooltip text of the button to enable light themestringEnable light theme
thumbnailTooltipTooltip text of the thumbnail buttonstringThumbnail
verticalScrollingLabelLabel of the vertical scrolling option in More OptionsstringVertical Scrolling
wrappedScrollingLabelLabel of the wrapped scrolling option in More OptionsstringWrapped Scrolling

| zoomActualSize | Label of the actual zoom option of the zoom menu select | string | Actual size | | zoomInTooltip | Tooltip text of the zoom in button | string | Zoom in | | zoomOutTooltip | Tooltip text of the zoom out button | string | Zoom out | | zoomPageFit | Label of the page fit zoom option of the zoom menu select | string | Page fit | | zoomPageWidth | Label of the page width zoom option of the zoom menu select | string | Page width | | zoomSelectTooltip | Tooltip text of the selector between zoom buttons | string | Select zoom level |

Here is an example on how to replace the existing localization

vue
<script setup lang="ts">
import { VPdfViewer, Locales } from "@vue-pdf-viewer/viewer";
const pdfFileSource =
  "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf";
const locale = ref("en_US");

const localization = {
  it_IT: Locales.it_IT,
  en_US: { ...Locales.en_US, searchButtonTooltip: "Click here to open search" },
};

const switchLanguage = () => {
  const prevLocale = locale.value;
  locale.value = prevLocale === "en_US" ? "it_IT" : "en_US";
};
</script>
<template>
  <button @click="switchLanguage">Switch Language</button>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer
      :src="pdfFileSource"
      :localization="localization"
      :locale="locale"
    />
  </div>
</template>
vue
<script setup>
import { VPdfViewer, Locales } from "@vue-pdf-viewer/viewer";
const pdfFileSource =
  "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf";
const locale = ref("en_US");

const localization = {
  it_IT: Locales.it_IT,
  en_US: { ...Locales.en_US, searchButtonTooltip: "Click here to open search" },
};
const switchLanguage = () => {
  const prevLocale = locale.value;
  locale.value = prevLocale === "en_US" ? "it_IT" : "en_US";
};
</script>
<template>
  <button @click="switchLanguage">Switch Language</button>
  <div :style="{ width: '1028px', height: '700px' }">
    <VPdfViewer
      :src="pdfFileSource"
      :localization="localization"
      :locale="locale"
    />
  </div>
</template>
vue
<script lang="ts">
import { VPdfViewer, Locales } from "@vue-pdf-viewer/viewer";

export default {
  components: { VPdfViewer },
  data() {
    return {
      toolbarOptions: {
        searchable: false,
        pdfFileSource:
          "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf",
      },
      locale: "en_US",
      localization: {
        it_IT: Locales.it_IT,
        en_US: {
          ...Locales.en_US,
          searchButtonTooltip: "Click here to open search",
        },
      },
    };
  },
  methods: {
    switchLanguage() {
      const prevLocale = this.locale;
      this.locale = prevLocale === "en_US" ? "it_IT" : "en_US";
    },
  },
};
</script>
<template>
  <div>
    <button @click="switchLanguage">Switch Language</button>
    <div :style="{ width: '1028px', height: '700px' }">
      <VPdfViewer
        :src="pdfFileSource"
        :localization="localization"
        :locale="locale"
      />
    </div>
  </div>
</template>
vue
<script setup>
import { VPdfViewer, Locales } from "@vue-pdf-viewer/viewer";

export default {
  components: { VPdfViewer },
  data() {
    return {
      toolbarOptions: {
        searchable: false,
        pdfFileSource:
          "https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf",
      },
      locale: "en_US",
      localization: {
        it_IT: Locales.it_IT,
        en_US: {
          ...Locales.en_US,
          searchButtonTooltip: "Click here to open search",
        },
      },
    };
  },
  methods: {
    switchLanguage() {
      const prevLocale = this.locale;
      this.locale = prevLocale === "en_US" ? "it_IT" : "en_US";
    },
  },
};
</script>
<template>
  <div>
    <button @click="switchLanguage">Switch Language</button>
    <div :style="{ width: '1028px', height: '700px' }">
      <VPdfViewer
        :src="pdfFileSource"
        :localization="localization"
        :locale="locale"
      />
    </div>
  </div>
</template>

If you wish to add a custom language, please do so by using the locale and localization props in the component:

html
<VPdfViewer locale="customLang" :localization="{ customLang: { .... } }" />

It's important to note that the locale string must match the key in the localization object. Otherwise, it will fall back to en_US.

Remark: If you would like to request another built-in language, please submit a request on Github.

ScrollMode

Currently available in the beta version.

The ScrollMode enumeration is used to define how pages will be scrolled in the viewer. This is configured via the initialScrollMode prop:

  • ScrollMode.Horizontal: Pages are scrolled horizontally. This mode is compatible with ViewMode.SinglePage only.
  • ScrollMode.Page: Displays one page at a time, enabling users to scroll through individual pages.
  • ScrollMode.Vertical : Pages are scrolled vertically, displaying multiple pages stacked on top of each other.
  • ScrollMode.Wrapped : Pages are wrapped, allowing multiple pages to be visible in a grid-like structure while scrolling.

ViewMode

Currently available in the beta version.

The ViewMode enumeration defines how pages are visually laid out in the viewer. This is configured using the initialViewMode prop:

  • ViewMode.SinglePage: Displays a single page in each row, making it easy to focus on one page at a time.
  • ViewMode.DualPage: Displays two pages side-by-side, ideal for viewing documents that are meant to be read in pairs.