How does phpfpdf output a header?

Source: Internet
Author: User
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}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.