### Vue PDF Viewer Setup (TypeScript Options API)
Source: https://docs.vue-pdf-viewer.dev/instance-api/search-controller
This snippet demonstrates initializing the VPdfViewer component using the Options API in TypeScript. It sets up reactive references for PDF viewer state and search functionality, leveraging the `@vue-pdf-viewer/viewer` package.
```vue
```
--------------------------------
### Vue PDF Viewer with Navigation (Options API TS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/page-controller
This example utilizes the VPdfViewer component with Vue 2/3's Options API and TypeScript. It defines components, setup function for reactivity, and exports methods for page navigation and event handling, similar to the Composition API approach. The '@vue-pdf-viewer/viewer' package is a prerequisite.
```vue
```
--------------------------------
### Vue PDF Viewer: Basic Setup and Component Instance
Source: https://docs.vue-pdf-viewer.dev/tutorial/creating-your-own-toolbar
Illustrates the fundamental setup for using the `VPdfViewer` component in a Vue application. It shows how to create a reference to the component instance and expose it for use in other parts of the setup function.
```vue
```
```javascript
import { VPdfViewer } from '@vue-pdf-viewer/viewer'
import { ref, computed, defineComponent, unref } from 'vue'
export default defineComponent({
components: { VPdfViewer },
setup() {
const vpvRef = ref(null)
// Other computed properties and methods would follow...
return {
vpvRef
}
}
})
```
--------------------------------
### Vue PDF Viewer: Extract Text (Options API JS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/page-controller
This example showcases the VPdfViewer component within a Vue.js Options API structure using plain JavaScript. It defines the necessary refs and computed properties in the setup function and exposes them to the template for functionality like text extraction. This requires the '@vue-pdf-viewer/viewer' package.
```vue
```
--------------------------------
### Vue PDF Viewer with Navigation (Options API JS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/page-controller
This snippet demonstrates the VPdfViewer component using Vue's Options API with plain JavaScript. It includes basic setup for the viewer, page control logic, and event handling for page changes. This code requires the '@vue-pdf-viewer/viewer' package to be installed.
```vue
```
--------------------------------
### Vue PDF Viewer: Extract Text (Options API TS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/page-controller
This example shows the VPdfViewer integration using Vue.js Options API with TypeScript. It defines components, sets up refs within the setup function, and makes page control and text extraction logic available in the template. The '@vue-pdf-viewer/viewer' package is a dependency.
```vue
```
--------------------------------
### Configure PDF Loading Options in Vue (JavaScript Setup)
Source: https://docs.vue-pdf-viewer.dev/component-api/interfaces
Shows how to configure PDF loading options using plain JavaScript with the Vue Composition API. It imports the VPdfViewer component, defines the PDF source and options, and passes them to the VPdfViewer. Dependencies include '@vue-pdf-viewer/viewer'.
```vue
```
--------------------------------
### Setup VPdfViewer Component
Source: https://docs.vue-pdf-viewer.dev/tutorial/highlighting-multiple-keywords
Initializes the VPdfViewer component to display a PDF document. The 'src' prop specifies the PDF file, and the 'ref' attribute allows programmatic interaction with the viewer for features like highlighting.
```vue
```
--------------------------------
### Vue PDF Viewer Setup and Logic
Source: https://docs.vue-pdf-viewer.dev/tutorial/creating-your-own-toolbar
This Vue.js script setup defines the core logic for a PDF viewer component. It uses `ref` and `computed` to manage viewer state, including current page, total pages, and search results. It provides methods for navigating between pages and handling key presses for page input. Dependencies include the `VPdfViewer` component from '@vue-pdf-viewer/viewer' and Vue's composition API.
```vue
```
--------------------------------
### Configure PDF Loading Options in Vue (TypeScript Setup)
Source: https://docs.vue-pdf-viewer.dev/component-api/interfaces
Demonstrates how to configure PDF loading options using TypeScript with the Vue Composition API. It imports necessary components and types, defines PDF source and options, and passes them to the VPdfViewer. Dependencies include '@vue-pdf-viewer/viewer'.
```vue
```
--------------------------------
### Vue PDF Viewer Highlighting with Options API (TS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/highlight-controller
This snippet demonstrates how to implement PDF text highlighting using the VPdfViewer component within Vue 3's Options API and TypeScript. It defines components, refs, computed properties, and watchers within the `setup` function, returning them to be used in the template.
```vue
```
--------------------------------
### Vue PDF Viewer with Search (JavaScript Composition API)
Source: https://docs.vue-pdf-viewer.dev/instance-api/search-controller
This example shows the VPdfViewer component usage with the Composition API in plain JavaScript. It mirrors the TypeScript version, providing search and navigation features for PDF documents loaded via the `@vue-pdf-viewer/viewer` package.
```vue
Searching: {{ searching }}
TotalSearchMatch: {{ totalMatches }}
```
--------------------------------
### Import and Utilize Annotation Plugin in Vue PDF Viewer (Options API)
Source: https://docs.vue-pdf-viewer.dev/annotation-plugin/getting-started
Shows how to integrate the VPdfAnnotationPlugin with VPdfViewer using Vue's Options API. This involves importing necessary components and plugins, and passing the plugin instance to the 'plugins' prop. Requires Vue 3 and the @vue-pdf-viewer/viewer package.
```vue
```
--------------------------------
### Set VPdfViewer Locale and Localization Props (Vue)
Source: https://docs.vue-pdf-viewer.dev/tutorial/adding-a-custom-localization
This snippet shows the basic setup for defining a custom locale and providing localization data directly within the VPdfViewer component's template. It's a starting point for custom translations.
```vue
```
--------------------------------
### Vue PDF Viewer with Search (TypeScript Composition API)
Source: https://docs.vue-pdf-viewer.dev/instance-api/search-controller
This example demonstrates how to use the VPdfViewer component with the Composition API in TypeScript. It includes functionality for searching text within the PDF, navigating through search results, and displaying the total number of matches. It relies on the `@vue-pdf-viewer/viewer` package.
```vue
Searching: {{ searching }}
TotalSearchMatch: {{ totalMatches }}
```
--------------------------------
### Custom Portuguese Localization (Vue Options API JS)
Source: https://docs.vue-pdf-viewer.dev/tutorial/adding-a-custom-localization
This example demonstrates implementing custom Portuguese (pt_PT) localization for VPdfViewer using the Options API with plain JavaScript. The localization details are configured within the component's `data` object.
```vue
import { VPdfViewer } from "@vue-pdf-viewer/viewer";
import VPdfAnnotationPlugin from "@vue-pdf-viewer/annotation";
// Custom configuration
const annotationPlugin = VPdfAnnotationPlugin({
highlight: {
// Set available highlight colors
colors: [
{ label: "Red", value: "red" },
{ label: "Green", value: "#007700" }, // Hex color
{ label: "Blue", value: "#0000ff90" },// Hex color with opacity
],
},
});
```
--------------------------------
### Vue License Initialization (Global Plugin)
Source: https://docs.vue-pdf-viewer.dev/tutorial/making-vue-pdf-viewer-reusable
Provides an alternative method for Vue license initialization using a global plugin. This approach is cleaner for larger projects, abstracting the license setup into a dedicated plugin file (`plugins/pdf-viewer.ts`) and then registering it with the Vue app.
```typescript
// plugins/pdf-viewer.ts
import { useLicense } from '@vue-pdf-viewer/viewer'
export default {
install: () => {
useLicense('Your VPV Domain Token')
}
}
// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import PdfViewerPlugin from './plugins/pdf-viewer'
const app = createApp(App)
app.use(PdfViewerPlugin)
app.mount('#app')
```
--------------------------------
### Import and Utilize Annotation Plugin in Vue PDF Viewer (Composition API)
Source: https://docs.vue-pdf-viewer.dev/annotation-plugin/getting-started
Demonstrates how to import the VPdfAnnotationPlugin and pass it to the 'plugins' prop of the VPdfViewer component using Vue 3's Composition API. Requires Vue 3 and the @vue-pdf-viewer/viewer package.
```vue
:plugins="[VPdfAnnotationPlugin()]"
/>
```
--------------------------------
### Handle Annotation Updates in Vue with TypeScript (Options API)
Source: https://docs.vue-pdf-viewer.dev/annotation-plugin/usage-guide/handling-annotations-with-callback-functions
Provides an example of handling the `onAnnotationUpdated` event using TypeScript with Vue's Options API. Annotations are processed and logged within the `created` hook and `methods`. This setup requires the same dependencies: `@vue-pdf-viewer/viewer` and `@vue-pdf-viewer/annotation`.
```typescript
```
--------------------------------
### Vue PDF Viewer Highlighting with Composition API (JS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/highlight-controller
This snippet demonstrates the same PDF highlighting functionality as the TypeScript version but uses plain JavaScript with Vue 3's Composition API. It allows developers to implement PDF highlighting without needing a TypeScript setup, providing flexibility in project configuration.
```vue
```
--------------------------------
### Access Vue PDF Viewer Instance with ref (TypeScript Setup)
Source: https://docs.vue-pdf-viewer.dev/tutorial/creating-your-own-toolbar
Access the Vue PDF Viewer instance using Vue.js `ref` in a TypeScript setup script. This allows you to interact with the Viewer's API for custom control implementation. It requires importing `VPdfViewer` and declaring a ref to hold the instance.
```vue
```
--------------------------------
### Configure CharacterMap with Local Path in Vue (Composition API TS)
Source: https://docs.vue-pdf-viewer.dev/component-api/interfaces
This example shows how to configure the CharacterMap for VPdfViewer by pointing to a local CMaps directory. It uses the Composition API with TypeScript and assumes CMaps are in the 'public/cmaps/' folder.
```vue
```
--------------------------------
### Install Canvas Dependencies for Apple M Series
Source: https://docs.vue-pdf-viewer.dev/introduction/getting-started
Installs necessary canvas dependencies using Homebrew for Apple M series chips. This is required because the default version of pdfjs-dist in Vue PDF Viewer depends on the 'canvas' package, which needs these system libraries.
```bash
$ brew install pkg-config cairo pango
```
--------------------------------
### Vue: Prop Precedence with v-bind
Source: https://docs.vue-pdf-viewer.dev/tutorial/adding-a-custom-localization
Demonstrates how the order of props, especially when using v-bind, affects value overriding in Vue components. Example A preserves explicit props, while Example B shows how defaultProps can override explicitly set localization values if v-bind is placed last.
```vue
```
--------------------------------
### Configure CharacterMap with Local Path in Vue (Options API TS)
Source: https://docs.vue-pdf-viewer.dev/component-api/interfaces
This example illustrates configuring the CharacterMap for VPdfViewer with a local CMaps directory using the Options API and TypeScript. CMaps should be placed in the 'public/cmaps/' folder.
```vue
```
--------------------------------
### Configure Custom Highlight Colors in Vue PDF Viewer Annotation (JavaScript Script Setup)
Source: https://docs.vue-pdf-viewer.dev/annotation-plugin/interfaces
This example shows how to set custom highlight colors for the Vue PDF Viewer annotation plugin using the `
```
--------------------------------
### Import VPdfViewer in Vue 3 (Options API)
Source: https://docs.vue-pdf-viewer.dev/introduction/basic-usage
Illustrates how to import and utilize the VPdfViewer component within a Vue 3 project using the Options API. This example includes setting the PDF source via component data.
```vue
```
--------------------------------
### Vue PDF Viewer Rotation Control (Options API, TS)
Source: https://docs.vue-pdf-viewer.dev/instance-api/rotate-controller
This example demonstrates using the VPdfViewer component with the Options API in TypeScript. It sets up refs and computed properties within the `setup` function to manage PDF rotation and display the current rotation state. The '@vue-pdf-viewer/viewer' package is a dependency.
```vue