Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-pdf-eurlanda

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-pdf-eurlanda - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

package.json
{
"name": "vue-pdf-eurlanda",
"version": "1.0.6",
"version": "1.0.7",
"description": "vue.js pdf viewer",

@@ -5,0 +5,0 @@ "main": "src/vuePdfNoSss.vue",

@@ -73,4 +73,3 @@ import resizeSensor from 'vue-resize-sensor'

return;
let calHeight = this.pdf.getCanvas().offsetWidth * (this.pdf.getCanvas().height / this.pdf.getCanvas().width);
let calHeight = width * (this.pdf.getCanvas().height / this.pdf.getCanvas().width);
if (calHeight > height) {

@@ -101,7 +100,9 @@ calHeight = height;

this.pdf = new PDFJSWrapper(this.$refs.canvasParent, this.$refs.annotationLayer, this.$emit.bind(this));
this.pdf = new PDFJSWrapper(this.$refs.canvasParent, this.$refs.annotationLayer, this.$emit.bind(this), this.container);
this.$on('loaded', function() {
let docheight = document.getElementById(this.container).offsetHeight;
let calHeight = this.pdf.getCanvas().offsetWidth * (this.pdf.getCanvas().height / this.pdf.getCanvas().width);
let docwidth = document.getElementById(this.container).offsetWidth;
//通过当前容器的宽度,根据当前的缩放比例计算高度
let calHeight = docwidth * (this.pdf.getCanvas().height / this.pdf.getCanvas().width);
if (calHeight > docheight) {

@@ -119,3 +120,4 @@ calHeight = docheight;

let docheight = document.getElementById(this.container).offsetHeight;
let calHeight = this.pdf.getCanvas().offsetWidth * (this.pdf.getCanvas().height / this.pdf.getCanvas().width);
let docWidth = document.getElementById(this.container).offsetWidth;
let calHeight = docWidth * (this.pdf.getCanvas().height / this.pdf.getCanvas().width);
if (calHeight > docheight) {

@@ -128,2 +130,5 @@ calHeight = docheight;

//初始设置高度
let docheight = document.getElementById(this.container).offsetHeight;
this.pdf.setCanvasHeight(docheight + "px");
this.pdf.loadDocument(this.src);

@@ -130,0 +135,0 @@ },

@@ -52,3 +52,3 @@ import { CMapCompressionType } from 'pdfjs-dist/lib/shared/util';

function PDFJSWrapper(canvasParent, annotationLayerElt, emitEvent) {
function PDFJSWrapper(canvasParent, annotationLayerElt, emitEvent, container) {

@@ -230,14 +230,9 @@ var pdfDoc = null;

}
//这里先使用高度作为缩放比例
var scale = canvasElt.offsetHeight / pdfPage.getViewport(1).width * (window.devicePixelRatio || 1);
//计算如果使用高度作为缩放比例,计算宽度
var calWidth = pdfPage.getViewport(1) * scale;
//如果使用宽度比例计算下来的宽度大于容器的宽度,那么使用宽度作为缩放比例
if (calWidth > canvasElt.offsetWidth) {
scale = canvasElt.offsetWidth / pdfPage.getViewport(1).width * (window.devicePixelRatio || 1);
//如果按照宽度计算下来的比例。大于容器的高度,那么按照容器高度来进行比例计算
if (pdfPage.getViewport(1).height * scale > canvasElt.offsetHeight) {
scale = canvasElt.offsetHeight / pdfPage.getViewport(1).height * (window.devicePixelRatio || 1);
}
var docWidth = document.getElementById(container).offsetWidth;
var scale = docWidth / pdfPage.getViewport(1).width * (window.devicePixelRatio || 1);
//如果按照宽度计算下来的比例。大于容器的高度,那么按照容器高度来进行比例计算
if (pdfPage.getViewport(1).height * scale > canvasElt.offsetHeight) {
scale = canvasElt.offsetHeight / pdfPage.getViewport(1).height * (window.devicePixelRatio || 1);
}
var viewport = pdfPage.getViewport(scale, rotate);

@@ -249,3 +244,3 @@

canvasElt.height = viewport.height;
canvasElt.style.width = viewport.width + 'px';
canvasElt.style.width = viewport.width + "px";
pdfRender = pdfPage.render({

@@ -398,3 +393,3 @@ canvasContext: canvasElt.getContext('2d'),

//annotationLayerElt.style.transformOrigin = '0 0';
annotationLayerElt.style.transformOrigin = '0 0';
}

@@ -401,0 +396,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc