How to Calculate Pixel Height with PHP

Asked

Viewed 212 times

0

I have a screen on which a report is generated with a limit amount of tables that cannot be broken.

I have to paginate this report. How to calculate the height of pixels generated ??

1 answer

4


With php I think it is not possible, friend, because it is server-side, but with javascript is possible, give an ID to the table and then do it

var tabela = document.getElementById('tabela');
var altura = tabela.innerHeight;
alert(altura);
  • 1

    I did not understand the fact that it is negative, and it is not possible to do this that you are asking with PHP, even if you could, when CSS changes the style of the table it may already have changed in size.

  • How do I take this Alert value and assign it to a PHP variable?

  • Alex, when the page is loaded, PHP has already been executed and it won’t do you any good to assign the height value to a PHP variable (unless you make a new request). Remember that PHP works with DATA. Don’t keep trying to reinvent the wheel and javascript can do this for you easily. Think about the following PHP brings you the data and javascript displays this data in the best way possible (the way you develop)

  • If you already have this specific amount that cannot be broken, do the style, see how many records fit in the specific size and at PHP time just search from the database the required amount.

  • I use the fpdf library to generate a pdf.. file but cannot break the lines. That is when a block starts on a page has to end on that page. On the other page you have to start a new block!!!

  • Did you solve the problem ? @alexjosesilva

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.