How does phpfpdf output a table header? I need to output a table here, but there may be many words in the table header, and the page width is fixed. So you must use MultiCell. how can you use it? Actually, I used it, but it's messy...
My code:
$ Pdf-> Cell (30,6, 'Field 1', 'L, T, B ', 0, 'L', true );
$ Pdf-> Cell (, 'Field 2', 't, B ', 0, 'L', true );
Foreach ($ fields as $ key => $ val ){
// $ Pdf-> Cell ($ tax_width, 20, $ book, 0, 'L ');
$ Pdf-> MultiCell ($ tax_width, 6, $ key, 't, B ', 0, 'C', true );
}
If cell is used, it may be overwritten. if MultiCell is used, it cannot be a header...
Reply to discussion (solution)
You need to go to $ pdf-> MultiCell ($ tax_width, 6, $ key, 't, B ', 0, 'C', true );
Specify the current location later (before)
You need to go to $ pdf-> MultiCell ($ tax_width, 6, $ key, 't, B ', 0, 'C', true );
Specify the current location later (before)
How to specify it? this is not easy to calculate... Some fields in the header are not necessarily, but there are many and many fields, such as long and short fields. I don't know how to do this .. How can I locate the problem?
This post was last edited by xuzuning at 17:20:40, January 22 ,.
If it is not calculated, it cannot be done!
$ Top = $ pdf-> gety (); // Y coordinate in the upper left corner $ left = $ pdf-> getx (); // X coordinate in the upper left corner $ height = 60; // header height $ width = 100; // column width $ ar = array ('title', 'long Title long title '); // the column title foreach ($ ar as $ text) {$ h = $ height/ceil ($ pdf-> GetStringWidth ($ text)/$ width ); // calculate the row height after the branch $ pdf-> multicell ($ width, $ h, $ text, 1, 'C '); $ pdf-> setxy ($ this-> getx () + $ width, $ top); // locate the next column}