WriteHTML is not working in mpdf, blank screen displays - php

I am trying to figure out the problem in this, but not able to. Query is proper, Result i am getting. If i echo $html i get result, but nothing for WriteHTML();
Here is my code
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("connect.php");
$id = $_GET['id'];
include("mpdf/mpdf.php");
$mpdf=new mPDF('utf-8', 'A4');
$mpdf->debug = true;
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetProtection(array());
$mpdf->SetTitle("My Company");
$mpdf->SetAuthor("MeAuthor");
$mpdf->SetWatermarkText("Demo");
$mpdf->showWatermarkText = false;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$s1 = "SELECT * FROM mytable WHERE cid=".$id."";
$sql = mysqli_query($con, $s1) or die (mysqli_error($con));
$row = mysqli_fetch_array($sql);
$html = '
<html>
<head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="80%" style="text-align: center; font-size: 16pt;">Company Name<br>
<span style="font-size: 11pt;text-align: center;">Address 123, Lorel Ipsum, sdfsdf sdsdgsdg,</span><br>
<span style="font-size: 11pt;text-align:center;">sdfdsfdsf, sfsdf - 100066
</td>
</tr>
</table>
</htmlpageheader>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="off" />
mpdf-->
<table width="100%">
<tr><td colspan="2" align="right" width="40%"> Vocher No : '.$id.' </td></tr>
<tr>
<td width="70%">Debit A/C. : '.$row['account_no'].' </td>
<td width="30%" style="text-align: right">Date: '.date("d-m-Y").'</td></tr>
</table>
<div style="border: 1px solid black">
<table border="0" style="white-space:nowrap; border-spacing:0;" height="100%" cellspacing="5"><thead>
<tr>
<th width="30%" style="border-right:1px solid #000;">Name</th>
<th width="20%" style="border-right:1px solid #000;">E-Mail</th>
<th width="20%" style="border-right:1px solid #000;">Mobile</th>
<th width="30%" style="border-right:1px solid #000;">Particulars</th>
<th width="15%" style="border-right:1px solid #000;">RS.</th>
<th width="5%" style="border-right:1px solid #000;">P.</th>
</tr>
</thead>
<tr>
<td style="border-right:1px solid #000;" width="30%" height="100px;" >'.$row['name'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['email'].'</td>
<td style="border-right:1px solid #000;" width="20%">'.$row['mobile'].'</td>
<td style="border-right:1px solid #000;" width="30%">'.$row['purpose'].'</td>
<td style="border-right:1px solid #000;" width="15%">'.$row['amount'].'</td>
<td style="border-right:1px solid #000;" width="5%">00</td>
</tr>
<tr><td colspan="4" style="font-weight:bold;">Total Rs.</td> '.$row['amount'].'<td></tr>
</table></div>
<br>
<table border="0"><tr><td style="width=50%;">Mode of Payment : '.$row['mode'].' </td><td width="50%">Date : '.date('Y-m-d').'</td></tr>
<tr><td colspan="2">Rupees : </td></tr>
</table>
<br><br><br>
<table width="100%" border="0">
<tr><td width="20%"> Hon. Secretary </td>
<td width="20%">Hon. Treasurer</td>
<td width="20%">Hon. Trustee</td>
<td width="20%">Receiver s Signature</td></tr>
</table>
</body>
</html>
';
//echo $html;
echo $mpdf->WriteHTML($html);
//$mpdf->Output('Receipt.pdf','D');
$mpdf->Output();
?>

Method WriteHTML() returns void! So you'll not get any echo.
Note that you have not send anything to browser (even http-header) before Output().

Related

In php I'm able to download excel file, but when I use same code in codeigniter it's directly sending HTML content instead of downloading XLS file?

<?php
$data1 ='<div id="prnittab">
<table width="100%" style="font-size:13px; margin-top:11px;border:solid 1px #333333;border-
bottom: 0px;">
<tr>
<td width="100%" style="padding:20px;">
<table width="100%" style="border:0px;">
<tr>
<td width=20% height="5px;" colspan="2"><img src="https://www.fillmurray.com/640/360"
width="220" height="75" alt="logo" /></td>
</tr>
<tr>
<td colspan="2" height="10"></td>
</tr>
<tr>
<td width="50%" align="left" valign="top style="font-size:16px;font-weight:bold;padding-left:15px;">Report Data</td>
<td width="50%" align="right" valign="top"
style="font-size:12px;font-weight:bold;padding-right:15px;">Monday, September 23, 2019</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" style="border-collapse: collapse;border: 1px solid #333333;">
<tr height="30">
<td align="left" style="font-size:12px;font-size:12px;font-weight:bold;padding-left:10px;">XYZ</td>
<td align="left"
style="font-size:12px;font-size:12px;font-weight:bold;height:20px !important;padding-right:10px;">Check
</td>
<td align="right"
style="font-size:12px;font-size:12px;font-weight:bold;height:20px !important;padding-right:10px;">
$540.00</td>
</tr>
</table>
</div>';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $data1;

Passing input type file through ajax

So I am trying to pass a file through Ajax along with other data in the form. Every data except the file is getting passed. I am sending an email with all the data using php. I am new to Ajax and tried many ways. But still not sure where I am going wrong.
So here is my jQuery code
$(document).ready(function(){
$("#submitbtn").click(function(){
var uname = $("#uname").val();
var uemail= $("#uemail").val();
var subject= $("#subject").val();
var resume= $('input[type=file]').val();
var message= $("#message").val();
if(uname == '')
{
$("#errormsgs1").html("Please Enter Name");
$("#uname").css("border","1px solid #f00");
$("#uname").focus();
return false;
}
if(uemail == '')
{
$("#errormsgs2").html("Please Enter Email");
$("#uemail").css("border","1px solid #f00");
$("#uemail").focus();
return false;
}
if(subject == '')
{
$("#errormsgs3").html("Please Enter Subject");
$("#subject").css("border","1px solid #f00");
$("#subject").focus();
return false;
}
if(resume == '')
{
$("#errormsgs4").html("Please Enter Your Resume");
$("#resume").css("border","1px solid #f00");
$("#resume").focus();
return false;
}
if(message == '')
{
$("#errormsgs5").html("Please Enter Message");
$("#message").css("border","1px solid #f00");
$("#message").focus();
return false;
}
$("form#data").submit(function(){
var formData = new FormData(this);
$.ajax({
url: mycareer.php,
type: 'POST',
data: formData,
async: false,
success: function (data) {
alert(data)
},
cache: false,
contentType: false,
processData: false
});
return false;
});
Below is the mycareer.php file
<?php
$uname = $_POST['uname'];
print_r($uname);
$uemail = $_POST['uemail'];
print_r($uemail);
//$subject = $_POST['subject'];
$resume = $_FILES['resume'];
print_r($resume );
$message = $_POST['message'];
print_r($message );
if($uname !='' && $uemail !='')
{
$to = 'sayantan.m#gmail.in';
$subject = "My Career";
$message ='<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<title>Mycareer.in</title>
<style type="text/css">
div, p, a, li, td {
-webkit-text-size-adjust:none;
}
.ReadMsgBody {
width: 100%;
background-color: #d1d1d1;
}
.ExternalClass {
width: 100%;
background-color: #d1d1d1;
line-height:100%;
}
body {
width: 100%;
height: 100%;
background-color: #d1d1d1;
margin:0;
padding:0;
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust:100%;
}
html {
width: 100%;
}
img {
-ms-interpolation-mode:bicubic;
}
table[class=full] {
padding:0 !important;
border:none !important;
}
table td img[class=imgresponsive] {
width:100% !important;
height:auto !important;
display:block !important;
}
#media only screen and (max-width: 800px) {
body {
width:auto!important;
}
table[class=full] {
width:100%!important;
}
table[class=devicewidth] {
width:100% !important;
padding-left:20px !important;
padding-right: 20px!important;
}
table td img.responsiveimg {
width:100% !important;
height:auto !important;
display:block !important;
}
}
#media only screen and (max-width: 640px) {
table[class=devicewidth] {
width:100% !important;
}
table[class=inner] {
width:100%!important;
text-align: center!important;
clear: both;
}
table td a[class=top-button] {
width:160px !important;
font-size:14px !important;
line-height:37px !important;
}
table td[class=readmore-button] {
text-align:center !important;
}
table td[class=readmore-button] a {
float:none !important;
display:inline-block !important;
}
.hide {
display:none !important;
}
table td[class=smallfont] {
border:none !important;
font-size:26px !important;
}
table td[class=sidespace] {
width:10px !important;
}
}
#media only screen and (max-width: 520px) {
}
#media only screen and (max-width: 480px) {
table {
border-collapse: collapse;
}
table td[class=template-img] img {
width:100% !important;
display:block !important;
}
}
#media only screen and (max-width: 320px) {
}
</style>
</head>
<body style="background:#f2f2f2;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" class="full">
<tr>
<td height="54"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="full">
<tr>
<td align="center"><table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="devicewidth">
<tr>
<td><table width="100%" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0" align="center" class="full" style="border-radius:5px 5px 0 0; background-color:#ffffff;">
<tr>
<td height="29"> </td>
</tr>
<tr>
<td><table border="0" cellspacing="0" cellpadding="0" align="left" class="inner" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
<tr>
<td width="23" class="hide"> </td>
<td height="75" class="inner" valign="middle"><img class="logo" src="http://my.in/img/my-logo.png" width="180" height="61" alt="Logo" style="background: #000;padding: 10px;"></td>
</tr>
</table>
<table width="150" border="0" cellspacing="0" cellpadding="0" align="right" class="inner" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
<tr>
<td height="15"> </td>
</tr>
<tr>
<td align="center">View online</td>
<td class="hide" width="20"> </td>
</tr>
</table></td>
</tr>
<tr>
<td style="border-bottom:1px solid #dbdbdb;"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="full">
<tr>
<td align="center"><table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="devicewidth">
<tr>
<td><table width="100%" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0" align="center" class="full" style="background-color:#ffffff;">
<tr>
<td height="23"> </td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="23" class="sidespace"> </td>
<td><table width="76%" border="0" cellspacing="0" cellpadding="0" align="left" class="inner" id="banner" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
<!--<tr>
<td style="font:bold 20px Arial, Helvetica, sans-serif; border-right:1px solid #dbdbdb;color: #000;" class="smallfont">THE BEST NUTRITION PLANS ARE HERE</td>
</tr>-->
<tr>
<td height="20"> </td>
</tr>
</table>
<!--<table width="22%" border="0" cellspacing="0" cellpadding="0" align="right" class="inner" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
<tr>
<td align="center"><img src="http://www.quanutrition.com/images/facebook.png" width="32" height="atuo" alt="Social Media" /></td>
<td align="center"><img src="http://www.quanutrition.com/images/twitter.png" width="32" height="atuo" alt="Social Media" /></td>
<td align="center"><img src="http://www.quanutrition.com/images/google.png" width="32" height="atuo" alt="Social Media" /></td>
</tr>
<tr>
<td height="20"> </td>
<td height="20"> </td>
<td height="20"> </td>
</tr>
</table>--></td>
<td width="23" class="sidespace"> </td>
</tr>
</table>
<!--<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="3.33%" class="sidespace"> </td>
<td width="93.33%"><img class="imgresponsive" src="http://www.quanutrition.com/images/banner1.jpg" width="554" height="atuo" alt="Banner" /></td>
<td width="3.33%" class="sidespace"> </td>
</tr>
<tr>
<td height="20"> </td>
<td height="20"> </td>
<td height="20"> </td>
</tr>
</table>-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="23" class="sidespace"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="left" class="inner">
<tr>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;width: 20%;color: #000;" class="smallfont">Name </td>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont" width="23">'.$uname.'</td>
</tr>
<tr>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont">Email </td>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont" width="23">'.$uemail.'</td>
</tr>
<tr>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont">Mobile </td>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont" width="23">'.$resume.'</td>
</tr>
<tr>
<tr>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont">Message:</td>
<td style="font:15px/19px Arial, Helvetica, sans-serif;padding-bottom: 8px;color: #000;" class="smallfont" width="23">'.$message.'</td>
</tr>
<tr>
<td height="20"> </td>
<td class="hide" height="20"> </td>
</tr>
</table>
</td>
<td width="23" class="sidespace"> </td>
</tr>
<tr>
<td height="16"> </td>
<td height="16"> </td>
<td height="16"> </td>
</tr>
</table></td>
</tr>
<tr>
<td style="border-bottom:1px solid #dbdbdb;"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" class="full">
<tr>
<td align="center"><table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="devicewidth">
<tr>
<td><table width="100%" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0" align="center" class="full" style="border-radius:0 0 7px 7px;">
<tr>
<td height="18"> </td>
</tr>
<tr>
<td><table class="inner" align="right" width="340" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; text-align:center;">
<tr>
<td width="21"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" class="full">
<tr>
<td height="18"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table class="inner" align="left" width="230" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; text-align:center;">
<tr>
<td width="21"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center" style="font:11px Helvetica, Arial, sans-serif; color:#000000;">© 2017, All rights reserved </td>
</tr>
<tr>
<td height="18"> </td>
</tr>
</table></td>
<td width="21"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20"> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: mail#my.in' . "\r\n";
$headers .= 'Reply-to: '.$uemail.'' . "\r\n";
//$headers .= 'Cc: rajendra.b#my.in' . "\r\n";
$sent = mail($to,$subject,$message,$headers);
echo "Thankyou for Contacting with us. We will get back you soon !!.";
}
else
{
echo "Please enter all the fields.";
}
?>
Below is the form
<form action="purpledotcareer.php" id="fileUploadForm" method="post" enctype="multipart/form-data" onsubmit="return checkvalidate()">
<div class="form-group">
<label for="email">Enter Your Name:</label>
<input type="text" class="form-control" id="uname" name="uname" onblur="if (this.value == '') {this.value = '';}" onfocus="this.value = '';" required="" type="text" value="" >
</div>
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="uemail" name="uemail" onblur="if (this.value == '') {this.value = '';}" onfocus="this.value = '';" required="" type="text" value="" >
</div>
<div class="form-group">
<label for="email">Message:</label>
<textarea class="form-control" id="message" name="message" onblur="if (this.value == '') {this.value = '';}" onfocus="this.value = '';" required="" rows="3" ></textarea>
</div>
<div class="form-group">
<label for="email">Upload Resume:</label>
<input type="file" class="form-control" id="resume" name="resume" onblur="if (this.value == '') {this.value = '';}" onfocus="this.value = '';" required="" accept=".xlsx,.xls,.doc, .docx,.ppt, .pptx,.txt,.pdf" >
</div>
<button type="submit" id="btnSubmit" class="btn btn-default">Submit</button>
</form>
It will be really helpful if anybody can solve this. Thanks in advance

php foreach loop repeat td's 2 times in a tr

I creating a PDF for print the address of users. I have the below HTML structure:
I have tried with the below code:
<?php $i=0; ?>
<tr valign="top">
foreach ($users as $user): ?>
<?php if ($i % 2 == 1) {?>
<tr valign="top">
<?php } ?>
But it's now work as expect.
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="48%" align="left" valign="top" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
<td width="4%" align="left"> </td>
<td width="48%" align="left" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td height="15" align="left"></td>
<td height="15" align="left"></td>
<td height="15" align="left"></td>
</tr>
</table>
In the abolve table I want to repeat the TD in each TR 2 times and added the blank TR after every TR.
The above HTML out should be the below image:
Could any one can help me out this.
If I get properly what you're looking for : I want to repeat in one TR repeat two TD
Then this code:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
echo"<table>";
for ($i = 1; $i <= 10; $i++) {
if(($i % 2) == 1) // odd -> start TR
{ echo "<tr><td class=\"dark\">$i</td>"; }
else // even -> close TR
{ echo "<td class=\"red\">$i</td></tr><tr><td colspan=\"2\">whatever here</tr>"; }
}
echo"</table>";
?>
will give you this output :
<table>
<tr><td class="dark">1</td><td class="red">2</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">3</td><td class="red">4</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">5</td><td class="red">6</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">7</td><td class="red">8</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">9</td><td class="red">10</td></tr><tr><td colspan="2">whatever here</tr>
</table>
EDIT after you comment : added one 'blank' TR
Try below solution you missed out to close
<?php
$i=0;
foreach ($users as $user){
if ($i % 2 == 0) {?>
<tr valign="top">
<?php } ?>
<td width="48%" align="left" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
<?php if ($i % 2 == 0) {?>
</tr>
<?php } }?>

HTMl Table's border not showing on Php PDF

Why do the borders of my tables not appear when I print my pdf to the screen?
I'm using the mPDF library.
I create the tables in html and for some reason it is not showing.
I already tried using inline CSS but it didn't work, for me.
<?php
require_once 'MPDF57\MPDF57\mpdf.php';
class TablePDF {
public function printPDF() {
$mpdf = new mPDF();
$border = 2 ;
$mpdf->SetHeader("Tabela");
$mpdf->SetFooter("Tabela");
$htmlpdf= "
<html>
<head>
<link type='text/css' rel=' rel='heet' href=' href='tstrap.min.css'>
<link type='text/css' rel='stylesheet' href='css/estilo.css'>
<style type='.text/css.'>
<title>Table</title>
</style>
.td{
style='border: 1px solid';
}
</head>
<body>
<table class='tabela' border=".$border." style='border:10px solid;'>
<tr style='border:10px solid black'>
<th width='150' style='border:10px solid black; '>GE</th>
<td width='200' style='border:10px solid black; '>0</td>
<td width='200' style='border:10px solid black; '><strong>Nome Curto</strong></td>
<td width='200' style='border:10px solid black; '>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>Valor</th>
<td width='200'>0</td>
<td width='200'><strong>FG</strong></td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'> Jugular </th>
<td width='117'>0</td>
<td width='117'>0</td>
<td width='117'>0</td>
<td width='118'>0</td>
<td width='119'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>EXP3D</th>
<td width='200'>0</td>
<td width='200'>0</td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>EXP28D</th>
<td width='200'>0</td>
<td width='200'>0</td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>Carotida</th>
<td width='303'>0</td>
<td width='303'>0</td>
</tr>
</table>
</body>
</html>";
$mpdf -> useOnlyCoreFonts = true;
$mpdf->WriteHTML($htmlpdf);
$mpdf->Output();
}
}
?>
Then I use this to use this function to print the pdf:
<?php
require_once 'TablePDF.php';
$var = new TablePDF();
$var->printPDF();
?>
EDIT: the problem has been solved, i just started deleting the table class in the TABLE tag line because for some reason it wastn recognizing it as a class.
thanks alot folks.
td {
border: 1px solid;
}
You don't have to create style every time that you need to use a td in your page, you only call the style.

dompdf render doesn't look like html

i use dompdf with codeigniter to convert my php (html) file into pdf.
My problem is the dompdf render doesn't appear like my php page :
Style for php file :
body {font-family:Arial, Helvetica, sans-serif;
font-size:15px;
color:#000;}
.xls {
border-top:1px solid #868686; }
.xls tr > td {
border-right:1px solid #868686; padding: 2px 3px 2px 5px;}
.t-pad tr > td {
border-right:1px solid #868686; padding: 2px 3px 2px 5px;}
.xls tr:first-child >td {
border-top:1px solid #868686;border-bottom:1px solid #000;}
.xls tr:last-child >td {
border-bottom:1px solid #868686;
text-align: center;
}
.xls {
border-right:1px solid #868686;
border-left:1px solid #868686;
}
.xls .m-td{
border-bottom: 0 none !important;
border-left: 1px solid #868686;
border-right: 1px solid #868686;
border-top: 0 none !important;}
.last-col{border-right:0 !important;
border-top: 0 none !important; }
.td-tab{ padding:10px 10px 10px 20px !important;}
.tab-center{ border-left: 1px solid #868686; }
.tab-center td{ padding: 0 0 0 5px; border-bottom: 1px solid #868686; }
.first-td {
border-top: 1px solid #868686 !important;
}
.border-r{border-right: 1px solid #868686 !important;}
.tab-cc{
border: 1px solid #868686;
}
.border-bt{border-bottom: 1px solid #868686 !important;}
.titre-tab {
background:#b2b1b1;
}
and it appear like :
http://info-du-jour.net/wp-content/uploads/2014/06/php.png
fil in controller to convert into pdf :
$data = $this->data_paie($ids);
$this->load->view('paie/fdp_etat', $data);
// Get output html
$html = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($html);
$this->dompdf->render();
$this->dompdf->stream("fiche_de_paie.pdf",array('Attachment'=>0));
and it look like
http://info-du-jour.net/wp-content/uploads/2014/06/dompdf.png
html rendering code :
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="50" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="font-size:24px; font-weight:bold;">BULLETIN DE PAIE</td>
<td align="right">
<img src="/logo/logo_simple1.jpg"
width="136" height="31" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" width="101"><strong>Période :</strong></td>
<td width="197" colspan="3" align="center">
<div style="font-size:14px; font-weight:bold;">
01-06-2014 au 30-06-2014 </div>
</td>
</tr>
</table>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="48%" valign="top">
<table border="0" cellpadding="0" cellspacing="2" class="tab-cc t-pad" width="100%" style="height:150px;">
<tr>
<td width="137"><strong>Matricule</strong></td>
<td width="217">SAL003</td>
</tr>
<tr>
<td><b>Nom et Prénom</b></td>
<td>AYARI Marwa</td>
</tr>
<tr>
<td><strong>Fonction</strong></td>
<td>Développeur</td>
</tr>
<tr>
<td><strong>Sit. familiale</strong></td>
<td>Marié </td>
</tr>
<tr>
<td><strong>Nbre d'enfants</strong></td>
<td>3</td>
</tr>
</table></td>
<td width="4%"> </td>
<td width="48%" align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="2" class="tab-cc" style="height:150px;">
<tr>
<td align="center"><b>EMPLOYEUR</b></td>
</tr>
<tr>
<td align="center"><strong>TOPO+</strong><br />
6 Rue des Cyclamens<br />
1004 EL MENZAH 5, ARIANA.<br />
CNSS Employeur : 45454 </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><table border="1" cellspacing="2" cellpadding="0" class="tab-cc xls" width="48%" >
<tr>
<td rowspan="2"><b>Droit congés payés</b></td>
<td align="center">Ancien solde</td>
<td align="center">(+) Droits</td>
<td align="center">(-) Pris</td>
<td align="center">Nouv. solde</td>
</tr>
<tr>
<td align="center">12</td>
<td align="center">1</td>
<td align="center">5</td>
<td align="center">2</td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<table width="100%" border="1" cellpadding="0" cellspacing="2" class="xls">
<tr class="titre-tab">
<td height="40"><strong>Désignation</strong></td>
<td><strong>Nombre</strong></td>
<td><strong>Base</strong></td>
<td><strong>Gains</strong></td>
<td><strong>Retenues</strong></td>
</tr>
<tr>
<td>Nombre de jours de présence</td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">26</td>
<td align="right"> </td>
</tr>
<tr>
<td>Salaire de base</td>
<td align="right"> </td>
<td align="right">1258,799</td>
<td align="right">1258,799</td>
<td align="right"> </td>
</tr>
<!-- autant de lignes que de primes dans la conv collective -->
<tr>
<td>Indemnité de transport</td>
<td align="right"> </td>
<td align="right">40,000</td>
<td align="right">40,000</td>
<td align="right"> </td>
</tr>
<tr>
<td>Prime de présence</td>
<td align="right"> </td>
<td align="right">2,080</td>
<td align="right">2,080</td>
<td align="right"> </td>
</tr>
<tr>
<td>Indemnité de déplacement</td>
<td align="right"> </td>
<td align="right">0,000</td>
<td align="right">0,000</td>
<td align="right"> </td>
</tr>
<tr>
<td> <b>Total Brut</b></td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">1300,879</td>
<td align="right"> </td>
</tr>
<tr>
<td>Retenu C.N.S.S</td>
<td align="right"> </td>
<td align="right">1300,879</td>
<td align="right"> </td>
<td align="right">119,421</td>
</tr>
<tr>
<td><b>SALAIRE IMPOSABLE</b></td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">1181,458</td>
</tr>
<tr>
<td>IRPP</td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">173,646</td>
</tr>
<tr>
<td> <b>Total Cotisations</b></td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right">293,067</td>
</tr>
<tr height="35">
<td> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table cellpadding="0" cellspacing="2" border="0" width="100%">
<tbody>
<tr height="21">
<td align="right"> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr height="21">
<td width="66%" align="right"><strong>Net à Payer</strong></td>
<td width="3%"></td>
<td width="2%"></td>
<td width="29%" colspan="2" align="right" class="tab-cc"><span style="font-weight:bold;padding-right: 4px;">1007,812</span> </td>
</tr>
<tr height="21">
<td align="right"> </td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
Instead of using $html = $this->output->get_output(); you can get the same HTML as it is rendering on browser . for that you need to make changes in script like :
$html = $this->load->view('paie/fdp_etat', $data , true); // so now your `$html` will be string which will return string from your view and both will be same.
For reference SEE HERE

Categories