New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mol-pdf

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mol-pdf

A PDF viewer based on mozilla's PDF.js.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

Cafe-PDF

NPM Publish NPM version GitHub stars GitHub issues GitHub forks

Render PDF files on Vue pages using pdf.js, supporting text rendering, lazy loading, paging, scaling, and printing.

Install

npm install cafe-pdf --save

Quick Start

import cafePdf from 'cafe-pdf'
import 'cafe-pdf/package/cafe-pdf.css'
Vue.use(cafePdf)

// OR
import cafePdf from 'cafe-pdf'
import 'cafe-pdf/package/cafe-pdf.css'
export default {
  // ...
  components: {
    cafePdf
  }
  // ...
}

Example

Demo:http://demo.const.team/pdf/

Note: the use of print, need to cooperate with the print style.

<template>
  <cafe-pdf ref="pdf" @on-success="load" @on-scroll="scroll" :filePath="src">
    <template slot="header">
      pdf-src:<input type="text" v-model.lazy="src" @change="fileChanged">
    </template>
    <template slot="footer">
      <button :disabled="currentNum<=1" @click="pre">pre</button>
      <input type="number" :min="1" :max="pageNum" v-model.number="currentNum" @change="pageChange(currentNum)">
      <button :disabled="currentNum>=pageNum" @click="next">next</button>
      <select v-model="scale" @change="setScale">
        <option value="auto">auto</option>
        <option value="page-actual">actual</option>
        <option value="page-fit">fit</option>
        <option value="page-width">width</option>
        <option value="0.50">50%</option>
        <option value="0.75">75%</option>
        <option value="1">100%</option>
        <option value="1.25">125%</option>
        <option value="1.50">150%</option>
        <option value="1.75">175%</option>
        <option value="2">200%</option>
        <option value="3">300%</option>
        <option value="4">400%</option>
      </select>
      <button @click="print">print</button>
    </template>
  </cafe-pdf>
</template>

<script>
export default {
  name: 'app',
  data() {
    return {
      src: 'https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf',
      pageNum: null,
      scale: 1,
      currentNum: 1
    };
  },
  components: {},
  methods: {
    fileChanged() {
      this.file = this.src;
    },
    load(val) {
      this.pageNum = val;
    },
    setScale() {
      this.$refs.pdf.changeScale(this.scale);
    },
    scroll(val) {
      this.currentNum = val;
    },
    pre(){
      this.$refs.pdf.prePage();
    },
    next(){
      this.$refs.pdf.nextPage();
    },
    pageChange(val) {
      this.$refs.pdf.goToPage(val);
    },
    print() {
      this.$refs.pdf.printFile();
    }
  }
};
</script>

<style>
html,
body {
  width: 100%;
  height: 100%;
}
* {
  margin: 0;
  padding: 0;
}
#app {
  color: #2c3e50;
  width: 100%;
  height: 100%;
}
@media print {
  #app {
    display: none;
  }
}
</style>

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
filePathpdf sourcestring
widthpdf widthstring, number100%
heightpdf heightstring, number100%
useOnlyCssZoomonly use css zoombooleanfalse
showNavshow catalogue (
If the file does not have a directory, it does not work)booleantrue
autoWidthWhether to scale PDF to container width during initializationbooleanfalse
textLayerModeRender in text mode, 0 use canvas,1 use text modenumber0/10

Events

Event NameDescriptionParameters
on-successsuccess eventcount page, pdf obj
on-errorerror eventerror
on-scrollTriggered when scrolling pdfCurrent pages , Pdf Object

Methods

MethodDescriptionParameters
scalescaleScaling
prePagepre page
nextPagenext page
goToPagePDF change pagepage
printFilePrint all pdfscale

Slot

nameDescription
headerheader slot
footerfooter slot

Keywords

pdfjs

FAQs

Package last updated on 03 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts