Download PDF using php with logo always on top of each page - php

I have this code to display on the page, however I also want to give users the option to download PDF , but on top of each PDF page I want there to be a logo picture, how can I do this? Is there a way with datatables? or just plain code?
<table>
<?php
foreach($sheets as $s):
echo "<tr>";
echo "<td>";
$name= explode(' ',$s['customer_name'])
?>
<div style="text-align: center">
<img alt="" src="/adminpanel2/public/logo.png">
</div>
<h2 style="text-align: center">Hi <?php echo $name[0] ?>!</h2>
<div align="center">
<br> Here is your delivery for: <br>
<?php echo date('l, F dS', strtotime($s['delivery_week']));?>
<br>
ORDER NO. <?php echo $s['order_id'] ?> | CUSTOMER NO.<?php echo $s['client_id'] ?>
<hr style="height: 5px;border-top:1px solid #000 !important;margin-bottom:0px">
<hr style="height: 5px;border-top:1px solid #000 !important;margin-top: 5px !important;">
</div>
<?php foreach($s['meals'] as $m):?>
<h3><?php echo $m['display_name'];?> </h3>
<?php echo $m['count']?> SERVING SHIPPED<br><br>
COMPONENTS
<hr align = "left" style="width: 115px; border-top:1px solid #000 !important;margin-top: 5px !important;margin-bottom:0px">
<br>
<?php foreach($m['components'] as $c):?>
<?php echo $c?><br>
<?php endforeach;?>
<hr align="left" style="width: 400px; border-top:1px solid #000 !important;margin-top: 5px !important;margin-bottom:0px" >
<?php endforeach;?>
<hr align="left" style="width: 600px; border-top:1px solid #000 !important;margin-top: 5px !important;margin-bottom:0px" >
<div align="center"><h3> Thank you,<?php echo $name[0] ?>!</h3>
<hr style="width: 600px; border-top:1px solid #000 !important;margin-top: 5px !important;margin-bottom:0px" >
</div>
<br>
<br>
<br>
<br>
<br>
</td>
</tr>
<?php endforeach; ?>
</table>
Here is my code (above) I am using php fuel

Related

How to remove extra borders in continues pages of HTML table in mpdf?

<div id="page-details">
<table style="page-break-inside: avoid !important;" width="1280px" cellspacing="0" cellpadding="0">
<tr style="page-break-inside: avoid !important; ">
<td width="1280px">
<table autosize="1" cellspacing="0" cellpadding="0" width="1280px">
<tr>
<td style="border-right:1px solid; height:25px; text-align:center;" width="40px">No</td>
<td width="320px" style="border-right:1px solid; text-align:center; height:25px;">Typology</td>
<td width="415px" style="border-right:1px solid; text-align:center; height:25px;">Description of Goods</td>
<td width="100px" style="border-right:1px solid; text-align:center; height:25px;">Width</td>
<td width="100px" style="border-right:1px solid; text-align:center; height:25px;">Height</td>
<td width="80px" style="border-right:1px solid; text-align:center; height:25px;">Qty</td>
<td width="100px" style="border-right:1px solid; text-align:center; height:40px;">Sq Feet
</td>
<td width="125px" style="text-align:center; height:40px;">Total
</td>
</tr>
</table>
</td>
</tr>
<!-- for loop start -->
<?php
if($quotation->items != null && count($quotation->items) > 0) {
$index = 1;
for ($i=0; $i < count($quotation->items); $i++) {
?>
<tr style="page-break-inside: avoid !important;">
<td width="1280px">
<table cellspacing="0" cellpadding="0" width="1280px" style="overflow-wrap: break-word; page-break-inside: avoid !important; ">
<tr>
<td style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; height:75px; text-align:center;" width="40px">
<?php echo $index++; ?>
</td>
<td width="320px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; height:275px;">
<?php
if ($quotation->items[$i]->seriesType == 7 ||
$quotation->items[$i]->seriesType == 8) {
?>
<img src="<?php echo $quotation->items[$i]->url;?>" style="max-height: 320px; max-width: 275px; padding: 5px;">
<?php
} else {
?>
<img src="<?php echo $quotation->items[$i]->url;?>" style="max-height: 320px; max-width: 275px; padding: 5px;">
<?php
}
?>
</td>
<td width="415px" style="word-wrap: break-word; border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; overflow-wrap: break-word; padding: 5px;">
<?php
echo "Pattern: <b>" . $quotation->items[$i]->patternName . "</b>";
?>
<br>
<p style="font-size: 20px;">
<?php
echo "Series: <b>" . $quotation->items[$i]->seriesName . "</b>";
?>
<br>
<?php
echo "Section Company: <b>" . $quotation->items[$i]->companyName . "</b>";
?>
<br>
<?php
echo "Glass: <b>" . $quotation->items[$i]->type . "</b>";
?>
<br>
<?php
echo "Color: <b>" . $quotation->items[$i]->colorType . "</b>";
?>
</p>
<br>
<?php
if (isset($quotation->items[$i]->location)) {
?>
<p style="font-size: 20px; font-weight: bold;">
<?php
echo "Location: " . $quotation->items[$i]->location;
?>
</p>
<?php
}
?>
<br>
<p style="font-size: 20px;">
<?php
if ($quotation->items[$i]->lockId > 0) {
echo "Lock - <b>" . $quotation->items[$i]->lockName . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->lockDescription)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Description - <b>" . $quotation->items[$i]->lockDescription . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->make)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Make - <b>" . $quotation->items[$i]->make . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->model)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Model - <b>" . $quotation->items[$i]->model . "</b>";
?>
</p>
<?php
}
?>
<?php
if (!empty($quotation->items[$i]->brand)) {
?>
<p style="font-size: 20px; margin-left: 20px;">
<?php
echo "Brand - <b>" . $quotation->items[$i]->brand . "</b>";
?>
</p>
<br>
<?php
}
?>
</td>
<td width="100px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php echo number_format($quotation->items[$i]->totalWidth, 2); ?>
</td>
<td width="100px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php echo number_format($quotation->items[$i]->totalHeight, 2); ?>
</td>
<td width="80px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php echo $quotation->items[$i]->qty; ?>
</td>
<td width="100px" style="border-top:1px solid; border-right:1px solid; border-bottom: 1px solid; text-align:center; height:75px;">
<?php
$totalSqFeet = $quotation->items[$i]->totalFoot * $quotation->items[$i]->qty;
echo number_format($totalSqFeet, 2);
?>
</td>
<td width="125px" style="border-top:1px solid; border-bottom: 1px solid;text-align:center; height:75px;">
<?php echo number_format($quotation->items[$i]->total, 2); ?>
</td>
</tr>
</table>
</td>
</tr>
<?php
}
}
?>
<!-- for loop end -->
</table>
</div>
Following is the Image of the issue I am facing in PDF for the reference.
I have placed page-break-inside: avoid !important; code inside table and tr both.
Also set $mpdf->shrink_tables_to_fit = 1; in MPDF object but still I am getting extra borders.

I added function to sort pics according to price they appeared in abnormal size

[enter image description here][1]
[1]: below is the code of sort by button i don't know why this happens while this is not the actually dimensions of the photos
https://i.stack.imgur.com/qxTt1.jpg
<center>
<table>
<?php
$opt=$_POST['sorting'];
if ($opt=="low") {
$qy="SELECT * FROM `men` order by `price` ASC";
$rt=mysqli_query($con,$qy);
while ($row1=mysqli_fetch_array($rt)) {
?>
<tr style="text-align: center; display: inline;">
<td style="border: thin solid lightgrey; width: 300px;
height: 200px;">
<pre>
<img src="<?php echo $row1['img']; ?>">
<b> <?php echo $row1['name']; ?> </b>
<span style="color: blue; font-weight: bold;">
<?php echo $row1['price']; ?>
</span>
</pre>
</td>
</tr>
<?php
}
}
else {
$qy="SELECT * FROM `men` order by `price` DESC";
$tt=mysqli_query($con,$qy);
while ($row1=mysqli_fetch_array($tt)) {
?>
<tr style="text-align: center; display: inline;">
<td style="border: thin solid lightgrey; width: 300px;
height: 300px;">
<pre>
<img src="<?php echo $row1 ['img']; ?>">
<b> <?php echo $row1['name']; ?></b>
<span style="color: blue; font-weight: bold;">
<?php echo $row1['price']; ?>
</span>
</pre>
</td>
</tr>
<?php
}
}
?>
</table>
</center>
<?php
}
?>

How to fix the value from php to use bootstrap?

I am using bootstrap accordion style to show the list of speakers in our website.
For that, I have a list of speakers table in my database. And I am getting the fields using php. In the following way.
<?php
global $wpdb;
$result = $wpdb->get_results( "SELECT * FROM `Invited_Speakers`");
foreach ( $result as $print ) { ?>
<tr style="width:100%">
<div class="maindrop" style="float: left; text-align: justify;">
<a class="bar" style="text-decoration: none;" href="#<?php echo $print->Last_Name;?>"> <?php echo $print->First_Name; ?> <?php echo $print->Last_Name; ?>, <?php echo $print->Institue_Address; ?>
</a>
<div id="<?php echo $print->Last_Name;?>" class="dropbox">
<img style="border-radius: 10%; padding: 10px; float: left;" src="<?php echo $print->Image_link;?>" alt="" width="20%" align="left" />
<table style="width:79%;float: right;">
<tbody>
<td > <?php echo $print->Designation;?> </td>
</tr>
<tr>
<td ><?php echo $print->Department_Address;?></td>
</tr>
<tr>
<td> Email Id: <?php echo $print->Email_Id;?></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td >Research Interests</td>
<td>:</td>
<td> <?php echo $print->Research_Interests;?> </td>
</tr>
<tr>
<td>
Achievements
</td>
<td> : </td>
<td><?php echo $print->Acheivements;?>
<button style="float:right;"><a style="color: white;" href="<?php echo $print->Home_page_Link;?>" target="_blank" rel="noopener"> More Info </a> </button>
</td>
</tr>
</tbody>
</table>
</div>
<?php }
?>
It has given me as expected, but the problem is,
when I click the bar, it should show me the dropbox which contains the details of the speaker. But it is not showing.
It seems like the link is not available.
How to rectify this??
I have around 60 speakers and for everybody, writing html code manually does not sound like good idea.
Link of the page is given here: Click here
In the above link, the problem is with the invited speakers list.
Thanks in advance
CSS:
.maindrop {
width: 100%;
}
.bar {
padding: 0px;
display: block;
border-bottom:1px solid #06394D;
text-decoration: none;
font-family: "Times New Roman", Times, serif;
font-size: 18px;
font-weight:300;
transition: .5s ease-out;
}
.bar:hover {
background: #F6F7F7;
padding: 15px;
text-decoration: none;
}
.dropbox {
max-height: 0;
transition: .2s ease-out;
overflow: hidden;
width: 100%;
}
.dropbox:target {
max-height: 5000px;
}
Assuming you're using Bootstrap 3, '.dropbox' does not exist as a class. What I believe you're looking for is an Accordion, which can be found under the Collapse documentation section.
Here is a little sample that should get you started in the right direction. The $count is there to make sure each row has a unique identifier to open it's associated accordion. I simplified the markup from which you have but you should be fine replacing with what you need.
<table style="width:100%">
<?php
$count = 0;
foreach($result as $print): ?>
<tr data-toggle="collapse" href="#collapseExample-<?php echo $count; ?>" aria-expanded="false" aria-controls="collapseExample-<?php echo $count; ?>">
<td>Speaker Name</td>
<td>Speaker Description</td>
</tr>
<tr class="collapse" id="collapseExample-<?php echo $count?>">
<td>This should be hidden</td>
</tr>
<?php $count++; endforeach; ?>
</table>

dompdf page breakes not working

here is sample image
<!DOCTYPE html>
<html class="bg-black">
<head>
<meta charset="UTF-8">
<title><?php if(isset($title)) echo $title.' | '; ?> Sales agent management software (SAMS) </title>
<style>
body{
font-size: 9px;
margin: 20px;
}
th,td,p,div,table,h3{margin:0;padding:0}
#page { margin: 20px; }
.header{
border-bottom: 1px solid #dddddd;
text-align: center;
position: fixed; top: 0;
}
.footer { position: fixed; bottom: 0px; text-align: center }
.pagenum:before { content: counter(page); }
</style>
</head>
<body>
<div class="header">
<h2><?php echo get_option('company_name'); ?> Catalog</h2>
</div>
<br /><br />
<div class="footer">Page: <span class="pagenum"></span>, creation time : <?php echo date('l jS \of F Y h:i:s A') ?>, create by: <?php echo user_full_name(singleDbTableRow(loggedInUserData()['user_id'])); ?></div>
<br />
<div class="box-body">
<?php
$usd = get_option('lkr_per_usd', 134);
?>
<?php
$result = array_chunk($products->result_array(), 3);
foreach($result as $products){ ?>
<table style="width:100% style="page-break-after:always;" >
<tr>
<?php
foreach($products as $productArray){
$product = (object) $productArray;
echo '<td>';
?>
<div style="width: 100%; height: 210px; border: 1px solid #dddddd; margin: 10px; padding: 5px;">
<div class="box-header">
<p class="box-title"><FONT SIZE=12><?php echo $product->product_name; ?></FONT></p>
</div>
<div style="height: 80px; text-align: center;">
<?php echo '<img src="'.'uploads/'. $product->photo.'" class="img-responsive" style="height:80px !important; width: 150px !important" />'; ?>
</div>
<div style="clear: both"></div>
<table class="table table-responsive">
<tr>
<th><FONT SIZE=12>ID</FONT></th>
<td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td>
</tr>
<tr>
<th><FONT SIZE=12>LKR</FONT></th>
<td><FONT SIZE=14><?php $lkr = get_selling_price($product);
echo number_format(round($lkr, get_option('round_precision')) ); ?></FONT>
</td>
</tr>
<tr>
<th> <FONT SIZE=12>US $</FONT></th>
<td><FONT SIZE=14><?php echo number_format(round(lkr_to_usd($lkr), get_option('round_precision')) ); ?></FONT></td>
</tr>
</table>
</div>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</div><!-- /.box-body -->
</body>
</body>
</html>
when i try to generate pdf it's always coming like this. i added my generate pdf code above .
2 nd page is not coming like 1st page.. i searched and found other dompdf solution for other peoples problem. but my problem is on 2nd page it's not coming as 1stpage.
There's some buggy behavior here on the part of dompdf. For some reason styling the DIV containing your product info with width: 100% is breaking the layout when the table row is paged. If you remove that styling from the DIV then the document should render as expected. The default DIV layout is full-width so you can leave the width styling on the DIV out

JavaScript Paging

I have the java and everything set up, but it's not paging. It shows the pagination page links but it doesn't limit it. Here is what I have:
<div class="pagination-holder clearfix" style="float: right;">
<div id="compact-pagination" ></div></div>
</div>
<div class="pagination-holder clearfix" style="float: right;">
<div id="compact-pagination" style="float: right;"></div></div>
<div id="compact-pagination" style="float: right;"></div>
<SCRIPT type="text/javascript">
$(function() {
$('#compact-pagination').pagination({
edges: 2,
currentPage: 1,
hrefText: "#page-",
prevText: "Prev",
nextText: "Next",
items: <? echo $count; ?>,
itemsOnPage: 2,
cssStyle: 'compact-theme'
});
});
</SCRIPT>
Then my php here.
So why won't it limit?
Link: http://flaviusmatis.github.com/simplePagination.js/
Php:
<?php $sql = "SELECT
*
FROM
users
ORDER BY user_id";
$result = mysql_query($sql);
if(!$result)
{
echo 'The category could not be displayed, please try again later.' . mysql_error();
}
else
{
if(mysql_num_rows($result) == 0)
{header('/');
echo 'This category does not exist.';
}
else
{
//display category data
while($row = mysql_fetch_assoc($result))
{
?>
<ul class="memberlist">
<li> <div id="memberlist" style="float: left; width: 300px; margin-left: 11px; margin-top: 10px; margin-bottom: 10px; border: 1px solid #CCC; border-radius:7px; background-color:#666;padding:5px 5px 5px 5px;">
<div id="memberlist_top">
<div id="memberlist_avatar">
<img src="<?php echo $row['avatar'] ?>" style="border: 1px solid #CBCBCB; padding: 3px; width: 100px; height: 100px;" />
</div>
<div id="memberlist_top_right">
<p id="memberlist_username"><?php echo $row['user_name'] ?></p>
<p style="text-align: center;"><img src="<?php echo$row['site_rank_image']?>"</p>
<p style="text-align: center;" id="ml_rep"> Reputation: 0 </p>
<p id="ml_posts">Post count: <?php echo $row['post'] ?></p>
</div>
<div class="clearfix" style="height: 5px;"> </div>
</div>
<div id="memberlist_bottom">
<p id="ml_bottom_p"><img src="template/images/layout/icon.png" style="vertical-align: middle" /> Date Registered: <span id="ml_bottom_span"><?php echo date(" F j, Y, g:i A", strtotime($row['user_date']))?> </span></p>
<p id="ml_bottom_p"><img src="template/images/layout/icon.png" style="vertical-align: middle" /> Last online: <span id="ml_bottom_span"><?php echo date(" F j, Y, g:i A", strtotime($row['dt']))?> </span></p>
<p id="ml_bottom_p" style="width: 284px; height: 30px; overflow-x: hidden; cursor: pointer;" title="Coming Soon"><img src="template/images/layout/icon.png" style="vertical-align: middle;" /> Last Activity: <span id="ml_bottom_span" style="text-decoration: underline;">Coming Soon</span></p>
<p id="ml_bottom_p"><img src="template/images/layout/icon.png" style="vertical-align: middle" /> Is online now: <span id="ml_bottom_span"> <? if($row
['online'] == 1) { // checks to see if the user allows their email to be shown, where '1' means they allow it to be shown
echo'Yes';
} else {
echo'No'; // if they allow it, it displays their email
} ?> </span></p>
</div>
</div> </li>
</ul>
<? }}}?>
How To Use
Step 1: together with JQuery, include jquery.simplePagination.js in your page:
<script type="text/javascript" src="path_to/jquery.js"></script>

Categories