javascript - clientHeight of Element in PDF different to Element in Browser -


i'am trying identify javascript if need force page break in document.

one element overflow hidden. loop through each of elements within document. remove last childs until height of element within overflow:hidden element smaller. know, when page break , push removed childs in new page.

works fine in browser. not in pdf...

i'am using http://wkhtmltopdf.org/

see problem here: left: pdf, right: browser (chrome)

height of 3262px vs 358px...

same if use .clientheight or jquery .height().

does know workaround heights same?

some code:

    function isoverflowed(element){         // return element.scrollheight > element.clientheight;         // console.log(element.clientheight);         // console.log(element.parent().height() +'>'+ element.height());         return element.parent().height() < element.height();     }     // var dayswrapper = document.getelementbyid('days');     // var days = dayswrapper.queryselectorall(".section.day");     var days = $('#days .section.day');     // console.log(days);      days.each(function() {       var $this = $(this);       var area = $this.find('.day-info');       var content = area.children();       var lasts = $( '<div class="lasts">' );       var test = 0;       while(isoverflowed(content)) {         var last  = content.children().last();         // lasts.append( $( last ) );         last.clone().prependto(lasts);         last.remove();         test++;         if (test > 6) break;       }       content.find('h1').html(area.height() + ' - ' + content.height());       if (lasts.children().length ) {         var newpage = $this.clone();         newpage.insertafter($this);         newpage.find('.day-image').remove();         newpage.find('.day-info').removeclass('overflow');         newpage.find('.day-info').children().html(lasts.html());       }     }); 

thanks!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -