![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
pdfvuer
Advanced tools
Readme
A PDF viewer for Vue using Mozilla's PDF.js
npm install --save pdfvuer
<template>
<pdf src="./static/relativity.pdf" :page="1">
<template slot="loading">
loading content here...
</template>
</pdf>
</template>
<script>
import pdf from 'pdfvuer'
export default {
components: {
pdf
}
}
<template>
<div id="pdfvuer">
<div id="buttons" class="ui grey three item inverted bottom fixed menu transition hidden">
<a class="item" @click="page > 1 ? page-- : 1">
<i class="left chevron icon"></i>
Back
</a>
<a class="ui active item">
{{page}} / {{ numPages ? numPages : '∞' }}
</a>
<a class="item" @click="page < numPages ? page++ : 1">
Forward
<i class="right chevron icon"></i>
</a>
</div>
<div id="buttons" class="ui grey three item inverted bottom fixed menu transition hidden">
<a class="item" @click="scale -= scale > 0.2 ? 0.1 : 0">
<i class="left chevron icon" />
Zoom -
</a>
<a class="ui active item">
{{ formattedZoom }} %
</a>
<a class="item" @click="scale += scale < 2 ? 0.1 : 0">
Zoom +
<i class="right chevron icon" />
</a>
</div>
<pdf :src="pdfdata" v-for="i in numPages" :key="i" :id="i" :page="i"
:scale.sync="scale" style="width:100%;margin:20px auto;">
<template slot="loading">
loading content here...
</template>
</pdf>
</div>
</template>
<script>
import pdfvuer from 'pdfvuer'
export default {
components: {
pdf: pdfvuer
},
data () {
return {
page: 1,
numPages: 0,
pdfdata: undefined,
errors: [],
scale: 'page-width'
}
},
computed: {
formattedZoom () {
return Number.parseInt(this.scale * 100);
},
},
mounted () {
this.getPdf()
},
watch: {
show: function (s) {
if(s) {
this.getPdf();
}
},
page: function (p) {
if( window.pageYOffset <= this.findPos(document.getElementById(p)) || ( document.getElementById(p+1) && window.pageYOffset >= this.findPos(document.getElementById(p+1)) )) {
// window.scrollTo(0,this.findPos(document.getElementById(p)));
document.getElementById(p).scrollIntoView();
}
}
},
methods: {
getPdf () {
var self = this;
self.pdfdata = pdfvuer.createLoadingTask('./static/relativity.pdf');
self.pdfdata.then(pdf => {
self.numPages = pdf.numPages;
window.onscroll = function() {
changePage()
stickyNav()
}
// Get the offset position of the navbar
var sticky = $('#buttons')[0].offsetTop
// Add the sticky class to the self.$refs.nav when you reach its scroll position. Remove "sticky" when you leave the scroll position
function stickyNav() {
if (window.pageYOffset >= sticky) {
$('#buttons')[0].classList.remove("hidden")
} else {
$('#buttons')[0].classList.add("hidden")
}
}
function changePage () {
var i = 1, count = Number(pdf.numPages);
do {
if(window.pageYOffset >= self.findPos(document.getElementById(i)) &&
window.pageYOffset <= self.findPos(document.getElementById(i+1))) {
self.page = i
}
i++
} while ( i < count)
if (window.pageYOffset >= self.findPos(document.getElementById(i))) {
self.page = i
}
}
});
},
findPos(obj) {
return obj.offsetTop;
}
}
}
</script>
<style lang="css" scoped>
#buttons {
margin-left: 0 !important;
margin-right: 0 !important;
}
/* Page content */
.content {
padding: 16px;
}
</style>
The url of the pdf file. src
may also be a string|TypedArray|DocumentInitParameters|PDFDataRangeTransport
for more details, see PDFJS.getDocument()
.
The page number to display.
The page rotation in degrees, only multiple of 90 are valid.
The scaling factor. By default, the pdf will be scaled to match the page width
with the container width.
When passed value page-width
and / or using resize
prop, will send back the scale
computed accordingly via update:scale
event (use it with scale.sync="scale"
)
Enable Auto Resizing on window resize. By default, autoresizing is disabled.
Show the annotations in the pdf. By default, annotation layer is disabled.
Show the text layer in the pdf. By default, text layer is enabled.
The total number of pages of the pdf.
The provided PDF's loading state
Function handler for errors occurred during loading/drawing PDF source.
src
: see :src
prop:src
property.Advanced Example - https://blog.koley.in/pdfvuer
Made with :heart: at IIIT Bangalore
MIT © Gaurav Koley, 2018
FAQs
A PDF viewer for Vue using Mozilla's PDF.js
The npm package pdfvuer receives a total of 7,241 weekly downloads. As such, pdfvuer popularity was classified as popular.
We found that pdfvuer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.