-1

I need to print some pages. I generate div´s for every page with fixed size, so I can control the content of every page and no content will appear on a wrong page.

So here is my problem: Sometimes the content of the first page is larger than the div. I need to check if it fit´s into the div. Is there any way to do this?

Thank you!

1 Answers1

0

Compare the scrollHeight vs clientHeight?

scrollHeight: ENTIRE content & padding (visible or not) Height of all content + paddings, despite of height of the element.

clientHeight: VISIBLE content & padding Only visible height: content portion limited by explicitly defined height of the element.

Great explanation here: What is offsetHeight, clientHeight, scrollHeight?

enter image description here enter image description here

More info:

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight

https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight

Bobz
  • 2,394
  • 1
  • 19
  • 20