andieje
asked on
mpdf - tables not laid out properly
I am using mpdf 6.0 with php and i am having a problem with tables. They look fine in the html then look crazy when converted to pdf
Here is the code
Here is a website with screenshots of the output:
The second one is the pdf
Any help to fix this is much appreciated
Here is the code
<table width="100%">
<tr>
<td style = "text-align:center;border: 1px solid black; font-size:28pt;" width="80%" rowspan="2">Task Activity</td>
<td rowspan ="4"></td>
<td style = "border: 1px solid black;" rowspan="2" width="10%">Risk Assessment no</td>
<td style = "font-size:21pt;text-align:center;border: 1px solid black;" rowspan="2" width="5%">199999</td>
</tr>
<tr>
</tr>
<tr>
<td style = "text-align:center;border: 1px solid black; font-size:24pt;" width="80%" rowspan="2">Site</td>
<td style = "border: 1px solid black;">dc</td>
<td style = "text-align:center;border: 1px solid black;">10/10/2000</td>
</tr>
<tr>
<td style = "border: 1px solid black;">dr</td>
<td style = "text-align:center;border: 1px solid black;">10/10/2000</td>
</tr>
</table>
Here is a website with screenshots of the output:
http://217.199.187.73/tolpitsmotors.com/index.html
The top one is the htmlThe second one is the pdf
Any help to fix this is much appreciated
ASKER
I appreciate your comments but what tools create pdf directly? Do you mean fpdf? or something else?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks - but is fpdf still supported? it hasnt been updated since 2011
It's "supported" through the "Forum" links and through web sites like E-E. This is free, open-source software. We are all kind of expected to know how to read the online manual, use it and how to extend the class, etc. The last time I used it for a big project was in 2011, and it worked perfectly with PHP 5.3. Nothing about PHP is likely to change in a way that would degrade FPDF, and if it did, there would be someone in the community that would step up with a change (it's on Google Code and GitHub). Executive summary: I would not hesitate to rely on it for a project today.
ASKER
excellent - thanks
It's the right way to go. A little more work up front, but much better results over time!
Thanks for the points and thanks for using E-E, ~Ray
Thanks for the points and thanks for using E-E, ~Ray
Which brings us to the question of "what's the right tool?" If what you're designing is the layout of a web page, the right tool is CSS. If what you're designing is a printed document, the right tool is PDF. These are two different applications, two different "views" of the information, if you subscribe to the concept of Model-View-Controller.
I've had very good results using FPDF and have a little experience with TCPDF (mostly as a test), but I've never found anything that dependably copies HTML markup and translates it into PDF. Instead, I've always made the PDF view of the data into a separate project. There are a lot of things in HTML that do not make sense on paper (links, for example) and these can be omitted. Working with FPDF allows you very fine positioning - I believe that 1/100 inch is possible. Pictures and fonts are available. It's an all-around good tool for creating a printed document. But it doesn't create an HTML document any better than HTML creates a PDF document. Executive summary - forget the HTML markup and just create the PDF you need, directly, with one of the free and open-source tools.