team2005
asked on
convert my report (html5 page + php) to PDF.
Hi!
Have made a html5 (php) page that display a report.
Need to make this report in PDF
Is there some great PDF-librarys out there ?
Have made a html5 (php) page that display a report.
Need to make this report in PDF
Is there some great PDF-librarys out there ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The Google search for terms like "convert my html5+css3 to PDF" turns up nothing that I would bet my enterprise application on! The reason for this is pretty simple.
HTML is a semantic markup language. It is meant to give the meaning to data elements, but it has nothing to do with layout (at least not in this millennium) which is now handled with CSS. I'm sure you can find old web pages where tables were used to force layout, etc., but that's ancient history by now.
PDF is a document layout language. It is meant to position data on the printed page, in much the same way that CSS is used to define layout within the browser viewport.
Semantics and layout are not quite as different as fish and bicycles, but that's close. It explains in part why browser / mobile layouts are fluid and adaptive, whereas print layouts are precise to the millimeter within rigidly defined page areas. Browser output and print output are just not the same thing. So rather than trying to find a fish that can ride a bicycle, consider using the popular and mainstream tools.
Using PHP and PDF extensions, these are good resources.
http://www.tcpdf.org/
http://www.fpdf.org/
HTML is a semantic markup language. It is meant to give the meaning to data elements, but it has nothing to do with layout (at least not in this millennium) which is now handled with CSS. I'm sure you can find old web pages where tables were used to force layout, etc., but that's ancient history by now.
PDF is a document layout language. It is meant to position data on the printed page, in much the same way that CSS is used to define layout within the browser viewport.
Semantics and layout are not quite as different as fish and bicycles, but that's close. It explains in part why browser / mobile layouts are fluid and adaptive, whereas print layouts are precise to the millimeter within rigidly defined page areas. Browser output and print output are just not the same thing. So rather than trying to find a fish that can ride a bicycle, consider using the popular and mainstream tools.
Using PHP and PDF extensions, these are good resources.
http://www.tcpdf.org/
http://www.fpdf.org/
ASKER
Hi!
Okey, so its not possible to use CSS and table and Mysql to make my PDF ?
My customer want me to make the same styling of tables like my code described abow..
Okey, so its not possible to use CSS and table and Mysql to make my PDF ?
My customer want me to make the same styling of tables like my code described abow..
Sometimes customers want a pink unicorn. Because they're not knowledgeable about the details of semantics and layout, they look at the screen and think, "give me that in print." It's a reasonable line of thinking, and it would seem to be easy, but if you think about it for a moment you'll realize that we are using different devices (screens and printers) to render the output. Different devices means different programming. Different programming means another abstraction layer, another set of development and testing, and all of the cost and complexity that comes with it.
If all the client needs is a one-shot screen capture, you might do this with "print screen" and Photoshop.
You might also consider using CSS for media=print. It will be less precise than PDF conversion but it might work for "quick and dirty" solutions.
If you want professional quality printed documents, the industry standard is PDF.
If all the client needs is a one-shot screen capture, you might do this with "print screen" and Photoshop.
You might also consider using CSS for media=print. It will be less precise than PDF conversion but it might work for "quick and dirty" solutions.
If you want professional quality printed documents, the industry standard is PDF.
ASKER
Hi!
So its not possible to use Mysql and styled tables ?
So its not possible to use Mysql and styled tables ?
MySQL has nothing to do with it. The issue is in the presentation layer where the output data is formatted for web or print. HTML is used for web. PDF is used for print. You might experiment with CSS media=print and see if that offers a satisfactory shortcut. It will take longer to get the document right with PDF (trust me, I've been there) but the results will be very fast and highly accurate.
ASKER
Hi!
Found a very god html to PDF converter
Its called MPDF -> http://www.mpdf1.com/mpdf/index.php
Have setup a test for this, but have problem to use PHP variabel
lock at this code, this is building a html string to be renderd to PDF
The problem is on this line:
$html .= $html + echo $test1;
Have tryed many different ways, but no luck
How can i fix this ?
Found a very god html to PDF converter
Its called MPDF -> http://www.mpdf1.com/mpdf/index.php
Have setup a test for this, but have problem to use PHP variabel
lock at this code, this is building a html string to be renderd to PDF
$test1="ssss";
$html = '
<html>
<head>
<style>
table.testtabell
{
border:1px solid #cccccc;
border-collapse: collapse;
font-family: Verdana;
font-size: 20px;
margin-right: 15px;
}
.rapport2_header
{
background-color: #efefef;
border:1px solid #cccccc;
color:#cccccc;
font-size: 15px;
font-family: Verdana;
border-collapse: collapse;
box-shadow: none ! important;
padding-left:10px;
}
.rapport1_del8
{
background-color: #ffffff;
border:1px solid #cccccc;
border-collapse: collapse;
box-shadow: none ! important;
padding-left:10px;
font-size:12px;
color:#b2b3c3;
}
</style>
</head>
<body>
';
$html .= '<table width="100%" align="left" class="testtabell">';
$html .= '<tr>';
$html .= '<th class="rapport2_header" height="40px" align="left">';
$html .= $html + echo $test1;
$html .='</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Lokasjon</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Dato</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Spørsmål</th>';
$html .= '<th class="rapport2_header" height="40px" align="left">Svar</th>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 1</td>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 2</td>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 3</td>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 4</td>';
$html .= '<td class="rapport1_del9" bgcolor="#ccc" align="left">Test 5<img src="images/jasvar.png" alt="Smiley face" align="right"></td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 1</td>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 2</td>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 3</td>';
$html .= '<td class="rapport1_del8" bgcolor="#ccc" align="left">Test 4</td>';
$html .= '<td class="rapport1_del9" bgcolor="#ccc" align="left">Test 5<img src="images/jasvar.png" alt="Smiley face" align="right"></td>';
$html .= '</tr>';
$html .= '</table>';
$html .= '</body>';
$html .= '</html>';
The problem is on this line:
$html .= $html + echo $test1;
Have tryed many different ways, but no luck
How can i fix this ?
Yes, that would probably cause a PHP parse error. I don't know exactly what you want there. Why not remove that line and try it without the parse error? You may also find that you want to use echo to send the HTML document to the browser.
Good luck with MPDF. I don't know why you didn't want to use my suggestions of FPDF or TCPDF, but it's your application so you have to be responsible for the choices. You might want to read the recent posts in the MPDF forum before you bet the ranch on MPDF.
Good luck with MPDF. I don't know why you didn't want to use my suggestions of FPDF or TCPDF, but it's your application so you have to be responsible for the choices. You might want to read the recent posts in the MPDF forum before you bet the ranch on MPDF.
ASKER
Hi!
I dident use FPDF -> dident give me the css styling i wanted...
Same problem for TCDF
I find ou of my problem:
$html .= '<td class="rapport1_del8" bgcolor=' . $valgfarge . ' align="left">' . $kontrollernavn . '</td>';
I dident use FPDF -> dident give me the css styling i wanted...
Same problem for TCDF
I find ou of my problem:
$html .= '<td class="rapport1_del8" bgcolor=' . $valgfarge . ' align="left">' . $kontrollernavn . '</td>';
ASKER
thanks
ASKER
This is not easy to know what to use here.
Have made a report system in html5 (mysql)
My question is :
Must be able to convert my html5+css3 to PDF.
And to use MYSQL
Like this code:
Open in new window
Realy happy if there are some good examples using Converter -> html5 to PDF
using HTML5 + mysql + css3