我需要缩放pdf以使其填满屏幕的高度,但我发现的只是函数scale()
。我怎么知道要缩放多少呢?
答案 0 :(得分:6)
要确定页面的宽度/高度,您需要执行以下操作:
获取页面
在“promise”函数中(页面只能异步检索):
一个。以1
湾调用视口的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 );
});