Skip to main content
Inspiring
September 18, 2020
Answered

How get page width and height?

  • September 18, 2020
  • 1 reply
  • 2035 views

How get page width and height?

 

 

This topic has been closed for replies.
Correct answer look997
I did this and it works, at the end of `await apis.getPageZoom(1)` it returns zoom `1`. But as I opened this PDF file in another viewer it's 100% bigger.
 
PDF Embed API confuses 100% for 75%. Now I don't know if it does this with every PDF file?
If with everyone then I can just do

 

const view100ProcentWidth =(viewWidth/zoom) + (viewWidth/zoom)/3 + scrollbarWidth​;

 

and get a real 100% zoom.

 

 

Code that takes width and sets 100% width:

 

document.querySelector("#adobe-dc-view").style.setProperty("height", "50px");
const zoom = await apis.getPageZoom(1);
document.querySelector("#adobe-dc-view").style.removeProperty("height");
const viewWidth = document.querySelector("#adobe-dc-view").clientWidth-scrollbarWidth;
const view100ProcentWidth = (viewWidth/zoom)+scrollbarWidth;
console.log("view100ProcentWidth",view100ProcentWidth);
document.querySelector("#adobe-dc-view").style.width = `${view100ProcentWidth}px`;

 

 

1 reply

Joel Geraci
Community Expert
Community Expert
September 18, 2020

You can't currently get the page dimensions with Embed API. What exactly are you trying to accomplish? There might be a work around. 

look997AuthorCorrect answer
Inspiring
September 22, 2020
I did this and it works, at the end of `await apis.getPageZoom(1)` it returns zoom `1`. But as I opened this PDF file in another viewer it's 100% bigger.
 
PDF Embed API confuses 100% for 75%. Now I don't know if it does this with every PDF file?
If with everyone then I can just do

 

const view100ProcentWidth =(viewWidth/zoom) + (viewWidth/zoom)/3 + scrollbarWidth​;

 

and get a real 100% zoom.

 

 

Code that takes width and sets 100% width:

 

document.querySelector("#adobe-dc-view").style.setProperty("height", "50px");
const zoom = await apis.getPageZoom(1);
document.querySelector("#adobe-dc-view").style.removeProperty("height");
const viewWidth = document.querySelector("#adobe-dc-view").clientWidth-scrollbarWidth;
const view100ProcentWidth = (viewWidth/zoom)+scrollbarWidth;
console.log("view100ProcentWidth",view100ProcentWidth);
document.querySelector("#adobe-dc-view").style.width = `${view100ProcentWidth}px`;