我需要按比例缩放pdf格式,以使其填满屏幕的高度,但是我发现的只是function scale()
。我怎么知道要缩放多少?
要确定页面的宽度/高度,您需要执行以下操作:
获取页面
在“承诺”功能中(只能异步检索页面):
一个。以比例尺检索视口1
b。调用width
视口的属性
代码:
//Get the page with your callback
pdf.getPage(1).then( function(page) {
//We need to pass it a scale for "getViewport" to work
var scale = 1;
//Grab the viewport with original scale
var viewport = page.getViewport( 1 );
//Here's the width and height
console.log( "Width: " + viewport.width + ", Height: " + viewport.height );
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句