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

kh-pdf-vue3

v1.0.2

Published

kh vue3 pdf viewer

Downloads

16

Readme

kh-pdf-vue3

English中文

vue3 pdf viewer

Add some callback events on the basis of the original project pdf-vue3

Install

  npm i kh-pdf-vue3

Usage

<script setup>
import PDF from 'kh-pdf-vue3';
</script>

<template>
  <PDF src="/demo.pdf" />
  <!-- <PDF :src="BASE64" /> -->
  <!-- <PDF :src="Uint8Array" /> -->
</template>

Config API

Props

| Attribute | Description | Type | | :----------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------: | | src | The URL or binary data(Uint8Array) or BASE64-encoded of the PDF. | string | Uint8Array | BASE64 | | showProgress | Whether to download the progress bar. The default value is true. | boolean | | progressColor | Download progress bar color. The default value is #87ceeb. | string | | showPageTooltip | Whether to show page tooltips. The default value is true. | boolean | | showBackToTopBtn | Whether to show back to the top button. The default value is true. | boolean | | scrollThreshold | Scrolling distance over how much to display the back to top button. The default value is 300. | number | | pdfWidth | pdf page width. The default value is 100%. | string | | rowGap | Line spacing between pdf pages. The default value is 8. | number | | page | Controls the current page number, and supports responsive variables to dynamically change the page number. The default value is 1 | number | | cMapUrl | Custom cMapUrl. The default value is https://unpkg.com/[email protected]/cmaps/ | string | | httpHeaders | Basic authentication headers. | object | | withCredentials | Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers. The default is false. | boolean | | password | For decrypting password-protected PDFs. | string | | useSystemFonts | When true, fonts that aren't embedded in the PDF document will fallback to a system font. The default value is true in web environments and false in Node.js; unless disableFontFace === true in which case this defaults to false regardless of the environment (to prevent completely broken fonts). | boolean | | stopAtErrors | Reject certain promises, e.g. getOperatorList, getTextContent, and RenderTask, when the associated PDF data cannot be successfully parsed, instead of attempting to recover whatever possible of the data. The default value is false. | boolean | | disableFontFace | By default fonts are converted to OpenType fonts and loaded via the Font Loading API or @font-face rules. If disabled, fonts will be rendered using a built-in font renderer that constructs the glyphs with primitive path commands. The default value is false in web environments and true in Node.js. | boolean | | disableRange | Disable range request loading of PDF files. When enabled, and if the server supports partial content requests, then the PDF will be fetched in chunks. The default value is false. | boolean | | disableStream | Disable streaming of PDF file data. By default PDF.js attempts to load PDF files in chunks. The default value is false. | boolean | | disableAutoFetch | Disable pre-fetching of PDF file data. When range requests are enabled PDF.js will automatically keep fetching more data even if it isn't needed to display the current page. The default value is false. NOTE: It is also necessary to disable streaming, see above, in order for disabling of pre-fetching to work correctly. | boolean |

Events

| Event Name | Description | Parameters | | :------------: | :-------------------------------------------------------------------------------------------------------------- | :---------------------: | | onProgress | listen to the pdf download progress, the parameters for 0-100. | loadRatio: number | | onComplete | pdf download complete. | - | | onScroll | Listen to the pdf scrolling, the parameter is the current scrollTop value. | scrollOffset: number | | onPageChange | Listen for page number changes. | page: number | | onPdfInit | pdf is init. PDFDocumentProxy: https://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib-PDFDocumentProxy.html | pdf: PDFDocumentProxy | | onPdfError | Listen renderPDF error | err: any |

Slots

| Slot Name | Description | Parameters | | :------------: | :------------------------------- | :---------------------------------------: | | progress | Customized progress bar | loadRatio: number | | pageTooltip | Customized page tooltips | currentPage: number, totalPages: number | | backToTopBtn | Customize the Back to Top button | scrollOffset: number |