Menu

#147 Add support for css vertical-align property

open
nobody
None
5
2016-03-14
2010-07-15
No

MultiCell() already supports vertical alignment for simple text: https://sourceforge.net/tracker/?func=detail&aid=2824787&group_id=128076&atid=710535

Adding support for the css vertical-align property would be a wonderful addition.

Discussion

  • Saul Willers

    Saul Willers - 2010-07-29

    Here's a graphic to illustrate one use case for vertical alignment:
    http://img834.imageshack.us/img834/1524/selection022.png

     
  • Nicola Asuni

    Nicola Asuni - 2010-07-29

    You can get the same effect on the example using the ... tag.

     
  • Saul Willers

    Saul Willers - 2010-07-29

    So you can, hadn't thought of the tag, thanks Nicola.

    However it doesn't allow any control over the vertical alignment. There are some assumptions in tcpdf.php about sup/sub tags, line 17809, 18645 and 19185 where the y offset is hard coded.

    Back to the core issue here, I appreciate that you've left this issue open as it pertains to vertical-align in general. Any estimation of how large a task it'd be to implement?

    Thanks, Saul

     
  • Barries Barnard

    Barries Barnard - 2010-08-30

    Sorry for the duplicate request, I havent seen this one.

     
  • Meglio

    Meglio - 2011-11-29

    nicolaasuni, what I think is that you can easily add valign property for TD and make it working only if there is only text inside TD - because you actually have valign already working for cells in tcpdf.

    This will cover more then 50% of user needs, because I see almost everyones just asking this feature for text, not for combined content inside TD.

    What do you think?

     
  • Guido Gallenkamp

    Oh, I really would like to have this feature :)

    Nicolaasuni, could you possibly just write where to start digging? I could do it myself but it would be quicker if you told me where to look first.

    I already have the code to look for vertical-align in css styles. I don't know where it goes next.

     
  • Guido Gallenkamp

    I solved it :)

     
  • Saul Willers

    Saul Willers - 2012-01-09

    @gallenkamp Care to share your solution? Or better yet see if it can be incorporated into TCPDF itself?

     
  • Guido Gallenkamp

    Its more a workaround than a propper solution. I'll post the workaround later today (3pm here) when I wrote it at my website, ok? Promise!

     
  • Saul Willers

    Saul Willers - 2012-01-09

    @gallenkamp Thanks for posting that. Interesting work around, it really is a hack, but as you say it is working for you so well done.

    My original usecase, as noted here in my first comment, is for vertical-align support on inline tags (e.g. span tags) as per http://img834.imageshack.us/img834/1524/selection022.png - I've still yet to find a way to do this. So this feature request is still valid.

     
  • Hank Cape

    Hank Cape - 2016-03-14

    I have a table with one column having a different font size (cause the numbers are big and wouldn't stay on one line if not made smaller) and the client wants them to be vertically centered in the cells.

    After trying all the hacks I have learnt in my history of HTML and CSS and TCPDF every time mocking at me I finally deviced such a clever solution which it didn't anticipateand finally got the vertical cell alignment more or less into the place ie in the middle of the cell.

    I found out that if there is an image in the same cell, TCPDF aligns the text on the bottom-line of the image. So I made an utility script to serve me with a white image of parametrized width and height and put that in front of the text. One can also just make a white image of wanted dimensions and use it but I found it easier to experiment with the script and varying parameters. In my case the width is just 1px, but theoretically one could also push text to the right with the image.

    Of course there are some problems with this approach as well but in my case all the numbers are quite well-behaving. If the height of either the centered text or other columns vary heavily it is very difficult to find a good value (though with parametrization one could try to calculate the height needed from the lengths of each cell on the row).

    I would still prefer if there could at least be top-padding or top-margin that one could set into the cell (working vertical-align would be even more desirable but even having any tool would make life easier)

    Hope this helps even some other poor coder

    hank

     

Log in to post a comment.