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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@certifaction/vue-pdf-viewer

v1.7.2

Published

PDF-Viewer for Vue.js based on Mozillas PDF.js

Downloads

158

Readme

@certifaction/vue-pdf-viewer

npm lerna

PDF-Viewer for Vue.js based on Mozillas PDF.js

Table of contents

Install

As NPM package

npm install @certifaction/vue-pdf-viewer

# or if using yarn
yarn add @certifaction/vue-pdf-viewer

Usage

ES6

import PDFViewer from '@certifaction/vue-pdf-viewer'

new Vue({
    components: {
        PDFViewer
    }
})

Load locales

Example code how to load the component translations:

import merge from 'lodash.merge'

import pdfViewerEN from '@certifaction/vue-pdf-viewer/src/locales/en.json'
import pdfViewerDE from '@certifaction/vue-pdf-viewer/src/locales/de.json'
import pdfViewerFR from '@certifaction/vue-pdf-viewer/src/locales/fr.json'
import pdfViewerIT from '@certifaction/vue-pdf-viewer/src/locales/it.json'

function loadLocaleMessages() {
    // Load your messages
}

const messages = merge({
    en: pdfViewerEN,
    de: pdfViewerDE,
    fr: pdfViewerFR,
    it: pdfViewerIT
}, loadLocaleMessages())

new VueI18n({
    messages
})

Load stylesheet

$pdf-viewer-asset-base-path: "/node_modules/@certifaction/pdfjs/dist/";
@import "@certifaction/vue-pdf-viewer/src/style/index";

Props

pdfjsWorkerSrc

Type: string | Required: false (either pdfjsWorkerSrc or pdfjsWorkerInstance is required)

URL to the pdfjs.worker.js or pdfjs.worker.min.js.

pdfjsWorkerInstance

Type: Worker | Required: false (either pdfjsWorkerInstance or pdfjsWorkerSrc is required)

When the worker is loaded with the Webpack worker-loader, you can also pass the instance of the worker.

vue.config.js example:

chainWebpack: config => {
    config.module
        .rule('js')
        .exclude.add(/\.worker\.js$/)

    config.module
        .rule('worker')
        .test(/\.worker(\.min)?\.js$/)
        .use('worker-loader')
        .loader('worker-loader')
        .options({ filename: 'js/[name].[hash:8].js' })
        .end()
}

Usage example:

<template>
    <div class="test">
        <PDFViewer :pdfjs-worker-instance="pdfjsWorker"/>
    </div>
</template>

<script>
import PdfjsWorker from '@certifaction/pdfjs/dist/pdfjs.worker.min'

export default {
    name: 'Test',
    components: {
        PDFViewer
    },
    data() {
        return {
            pdfjsWorker: new PdfjsWorker()
        }
    }
}
</script>

pdfjsCMapUrl

Type: string | Required: true

Pass the path where the cmaps can be accessed.

vue.config.js example to copy the cmaps to the dist folder:

chainWebpack: config => {
    config.plugin('copy')
        .tap(args => {
            args[0].push({
                from: '@certifaction/pdfjs/dist/cmaps',
                to: 'pdf/cmaps',
                toType: 'dir',
                context: './node_modules'
            })
            return args
        })
}

source

Type: string or Uint8Array | Required: true

The URL of the PDF document as string or the PDF documents content as Uint8Array which should be displayed.

defaultScale

Type: string or number | Required: false | Default: 'auto'

The PDF Viewer renders the pages initially with the defined defaulScale.

Possible number values: Min = 0.1, Max = 10

Possible string values: 'auto', 'page-actual', 'page-fit', 'page-width'

documentName

Type: string | Required: false | Default: 'pdf-viewer-document.pdf'

The documentName is used for downloadable files.

allowDocumentDownload

Type: boolean | Required: false | Default: false

Shows the document download button if true

pdfjsViewerOptions

Type: Object | Required: false | Default: {}

These options are passed to the constructor of PDFViewer. Possible options are the PDFViewerOptions from https://github.com/mozilla/pdf.js/web/base_viewer.js.

container and eventBus are always overridden by the component.

License

License

Released by Certifaction AG