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

@v2v/vue-pdf

v0.0.14

Published

Aurora Stream Vue PDF

Downloads

22

Readme

Aurora Stream Vue PDF

提供快速集成到项目中的PDF Core 和 Vue3组件

用法

安装

npm install @v2v/vue-pdf

yarn add @v2v/vue-pdf

使用

<script setup lang="ts">
import {ref, computed } from 'vue';
import type {fitType} from '@v2v/pdf'
import { APdf } from '@v2v/vue-pdf'
import '@v2v/vue-pdf/dist/style.css'

import {NButton, NSelect, NSpace} from 'naive-ui';

const page = ref(2)
const scale = ref(1)
const fit = ref<fitType>('auto')
const loadAll = ref(false)
const APdfRef = ref<InstanceType<typeof APdf> | null>(null)

const url = ref('https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf')

const options = [
  {label: "50%", value: 0.5},
  {label: "75%", value: 0.75},
  {label: "100%", value: 1},
  {label: "150%", value: 1.5},
  {label: "200%", value: 2}
]


const total = computed(() => {
  return APdfRef.value?.getTotal() || 0
})

function switchRenderType() {
  loadAll.value = !loadAll.value
}

function setScale(value: number) {
  scale.value = value
}

function nextPage() {
  if (page.value >= total.value)
    return
  page.value += 1
}

function prevPage() {
  if (page.value <= 1)
    return
  page.value -= 1
}

function setMode(type: fitType) {
  fit.value = type
}


</script>

<template>
  <div class="content">
    <NSpace class="header">
      <NButton size="small" :disabled="page <= 1" @click="prevPage">
        &lt
      </NButton>
      <NButton size="small" :disabled="page >= total" @click="() => nextPage()">
        &gt
      </NButton>
      <NButton size="small" @click="(() => {
        switchRenderType()
      })">
        {{ loadAll ? '单页' : '全部' }}
      </NButton>
      <NButton size="small" @click="(() => {setMode('page-actual')})">
        原始
      </NButton>
      <NButton size="small" @click="(() => {setMode('page-width')})">
        铺满
      </NButton>
      <span>
        {{ page }}
        /
        {{ total }}
      </span>
      <NSelect size="small" style="width: 80px" placeholder="缩放" @update:value="setScale" :options="options" />
    </NSpace>
    <a-pdf :url="url" :loading-size="20" ref="APdfRef" :page="page" :fit-type="fit" :load-all="loadAll" :scale="scale" />
  </div>
</template>

<style scoped>
.header {
  position: absolute;
  top: 10px;
  left: 0;
  color: green;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 20px 0;
  padding: 0 10px;
  box-sizing: border-box;
}

.content {
  width: 90%;
  max-width: 1100px;
  margin: 100px auto 0;
  height: calc(100vh - 140px);
  overflow: auto;
  padding-right: 3px;
}

#app {
  overflow: hidden;
}
</style>

高亮

提供快速后台返回数据进行全部高亮或者部分高亮

文书定位

轻松完成高亮或者文本精准定位,无需后台关心PDF的坐标系

高度定制(设计中)

快速完成在线编辑、和预览pdf

备注

关于worker

1.打包到代码中:

import { GlobalWorkerOptions } from 'pdfjs-dist'

import workerUrl from 'pdfjs-dist/build/pdf.worker.min.js?url'

GlobalWorkerOptions.workerSrc = workerUrl

2.使用CDN:


import { GlobalWorkerOptions, version } from 'pdfjs-dist'

GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${version}/pdf.worker.js` //替换成你的CDN地址