npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pdfjs-vue3

v0.2.2

Published

Using pdfjs to display PDFs as a vue 3 component.

Downloads

107

Readme

pdfjs-vue3

A experimental Vue 3 component for displaying PDFs using pdfjs.

Installation

Install the package and its peer dependencies:

npm install pdfjs-vue3 pdfjs-dist

Setup

Copy the PDF.js Worker Script

The PDF.js library requires a worker script to render PDFs. You need to copy it from pdfjs-dist into your app's public/static folder so it can be served at runtime.

For example, copy it into public/js/pdfjs/:

# unix/mac
cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/js/pdfjs/

# windows
copy node_modules\pdfjs-dist\build\pdf.worker.min.mjs public\js\pdfjs\

You can choose any path under your public folder — just remember the URL for the next step.

Import Styles

Import the component styles in your app entry or root component:

import 'pdfjs-vue3/dist/pdfjs-vue3.css'

Usage

Basic Example

<script setup lang="ts">
import { ref } from 'vue'
import { PdfHost, ZoomType } from 'pdfjs-vue3'

const zoomType = ref(ZoomType.Auto)
const zoom = ref(1)
const files = ['/samples/my-document.pdf']
</script>

<template>
  <PdfHost
    worker-src="/js/pdfjs/pdf.worker.min.mjs"
    :sources="files"
    v-model:zoom-type="zoomType"
    v-model:zoom="zoom"
    style="height: 100vh;"
  />
</template>

PdfHost Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | workerSrc | string | — | URL to the pdfjs worker script. Must be set if not configured elsewhere. | | sources | PdfSource[] | — | Array of PDF sources to display. Each source can be a URL string, URL, TypedArray, ArrayBuffer, or a pdfjs DocumentInitParameters object. | | sourceKey | (source: PdfSource, index: number) => string \| number | — | Optional key generator for source identity in rendering. Use this when sources may contain duplicate values. | | zoomType | ZoomType | ZoomType.Auto | Type of zoom behavior. | | zoom | number | 1 | Custom zoom percentage (1 = 100%). Used when zoomType is Custom. | | hideText | boolean | false | Hides the selectable text layer. | | hideNumber | boolean | false | Hides the page number display. |

PdfHost Events

| Event | Payload | Description | |------|---------|-------------| | update:zoom | number | Emitted when zoom changes. | | update:zoomType | ZoomType | Emitted when zoom mode changes. | | error | { source: PdfSource, error: unknown } | Emitted when loading a source fails. |

ZoomType Enum

| Value | Description | |-------|-------------| | Auto | Fits width up to a certain limit. | | WidthFit | Fits width of the host with no limit. | | PageFit | Fits the whole page in the host. | | Custom | Uses the zoom prop value. |

Exposed Methods

The PdfHost component exposes zoomIn() and zoomOut() methods via template ref:

<script setup lang="ts">
import { ref } from 'vue'
import { PdfHost } from 'pdfjs-vue3'

const host = ref()
</script>

<template>
  <button @click="host.zoomIn()">+</button>
  <button @click="host.zoomOut()">-</button>
  <PdfHost ref="host" worker-src="/js/pdfjs/pdf.worker.min.mjs" :sources="['/doc.pdf']" />
</template>

Page Slot

Use the #page slot to render custom overlays on each page:

<PdfHost worker-src="/js/pdfjs/pdf.worker.min.mjs" :sources="files">
  <template #page="{ page, displaySize }">
    <div>Page {{ page.pageNumber }} — {{ displaySize.width }}×{{ displaySize.height }}</div>
  </template>
</PdfHost>

License

Apache-2.0