html2pdf add content in footer on each page - php

I have 5-10 table in pdf in which I am showing all the records of that table and each have approx 1000-2000 records. I have try to use below code to make footer on each page but instead of that its showing after completion of table. My template looks like below
<page backtop="0" backbottom="30mm" footer="page" style="font-size: 9pt">
<table>
<Records>
</table>
<page_footer>
<table class="page_footer" style="width: 100%;">
<tr>
<td style="width: 80%; text-align:center">
<p style='font-size: 6pt;color:red;'>
...Content...
</p>
</td>
</tr>
</table>
</page_footer>

You can add custom header and footer by using mixture of tcPDF and wkhtml2pdf. Here is an example html2pdf/tcpdf/example . Here is another example html2fpdf/discussion/thread

Related

PHP mpdf handling block level elements inside table

I am using mpdf library to generate PDF from HTML.I came across the limitation of mpdf that we cannot use block level elements inside table.Is there any possible way to make mpdf work with following code?. I tried span instead of p but its not act like block level elements.
<table style="width:100%; table-layout:fixed">
<tr>
<td>
<p style="text-align:left;font-size:14px;font-family:Arial;padding-left:105px;">Some text</p>
<p style="text-align:left;font-weight:normal;font-size:14px;font-family:Arial;padding-left:125px;">Some text Some text Some text </p>
</td>
</tr>
</table>
The styles of Block level elements inside table,td won't reflect in PDF.I have fixed above issue with using another table by following.Hope it will help someone.
<table style="width:100%; table-layout:fixed">
<tr>
<td>
<table>
<tr>
<td style="text-align:left;font-size:14px;font-family:Arial;padding-left:105px;">
Some text
</td>
</tr>
<tr>
<td style="text-align:left;font-weight:normal;font-size:14px;font-family:Arial;padding-left:125px;">
Some text Some text Some text
</td>
</tr>
</table>
</td>
</tr>
</table>

Avoid table td repetition in WordPress theme

I have created my first WordPress Theme from HTML and I want to add a space to the right hand side of my blog posts with profile information and links to other sites etc..
I am using the below code and it seems to repeat the table td where I would like to add the profile and other information?
Can anyone shed some light on a solution for this?
To see what it looks like.
<table style="width: 1000px; height: 150px" cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="width: 740px">
<table style="width: 740px" cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="width: 200px; height: 44px" background='Date.jpg'>
<h2>
<?php the_time('F jS, Y'); ?>
</h2>
</td>
<td style="width: 540px; height: 44px" background='Title.jpg'>
<h4>
" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
</h4>
</td>
</tr>
<tr>
<td colspan="2">
<div class="entry">
<?php the_content(); ?></div>
</td>
</tr>
<tr>
<td style="height: 44px" background='Comments.jpg'>
Posted By <?php the_author_posts_link(); ?>
</td>
<td style="height: 44px" background='Comments.jpg'>
in <p class="postmetadata"><?php _e( 'Posted in' ); ?> <?php the_category( ', ' ); ?></p>
</td>
</tr>
</table>
</td>
<td style="width: 260px">
SIDEBAR AND PROFILE TAGS HERE</td>
</tr>
</table>
How I can fix this issue in the index.php?
The problem is that you're printing your table inside The Loop. That sidebar <td style="width: 260px"> is being printed at every post. It is not a sidebar for all posts, it's just an individual sidebar to each post.
You'll need to read about Theme Development at the Codex to understand theme structures and best practices.
The reference to 1998 made in a comment is that tables are not used for layout purposes since long ago, see Why not use tables for layout in HTML?.
I'd suggest that you search for Starter Themes (like this) to build upon. For complete, exemplary, themes look for WordPress default ones, from Twenty Ten to Twenty Fourteen, to see how themes evolved in the last years.

mPDF: Hide table row (CSS display:none) not work

mPDF: Hide table row (CSS display:none) not work.
Do you have any suggest?
My code:
<table align="center">
<tr style="display:none">
<td valign="top" align="left">InfoOption1:</td>
<td valign="top" align="left" colspan="2">#InfoOption1</td>
</tr>
</table>
I feel very dirty for posting this suggestion, but it's the best I got working:
<tr><td>...</td></tr>
<div style="display: none;">
<tr><td>...</td></tr>
</div>
The DIV is the working part. Luckily, html validnes for seo isnt relevant for mPDF
It works if you enclose the row you want to hide inside a Div. The div will have a class which have declared hidden property.
<div class='hide_this_row'>
<tr>
<td>...</td>
</tr>
</div>
<!-- CSS file will look like this -->
<style>
.hide_this_row{
display :none;
}
</style>

converting page with nested tables to pdf

heyy.. I am new to php.. I am trying to convert a page containing nested tables into pdf.. this is the page i need to convert
<!DOCTYPE html>
<html>
<body>
<div style="margin-left: auto; margin-right: auto; width: 75%">
<table width="1000" border="1" bordercolor="#500000">
<tr>
<td colspan="2" style="background-color:#500000;">
<h1 style="text-align:center;"><font color="#FFFFFF">COMPANY NAME</font></h1>
<h2 style="text-align:center;"><font color="#FFFFFF">BALANCE SHEET</font></h2>
<h3 style="text-align:center;"><font color="#FFFFFF">DATE</font></h3>
</td>
</tr>
<tr>
<th width="50%">ASSETS</th>
<th width="50%">LIABILITIES</th>
</tr>
</tr>
<tr>
<!-- <td width="480"><?php include('assets.php') ?></td>
<td width="480">fadffd</td> -->
<td><iframe src="assets.php" frameborder="0" width="500" height="500"></iframe></td>
<td><iframe src="liabilities.php" frameborder="0" width="500" height="500"></iframe></td></tr>
<tr>
<td colspan="2" style="background-color:#500000;text-align:center;"><font color="#FFFFFF">lkfjsdgjljsglhlhfsaj</font></td>
</tr>
</table>
</div>
</body>
</html>
here i have included two tables as table data using iframe.. when i try to import it to pdf using the code shown below, the nested tables are not displayed.
<?php
include("MPDF53/MPDF53/mpdf.php");
$mpdf=new mPDF('win-1252','A4','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L.
$mpdf->SetHeader('|Your Header here|');
$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
$mpdf->useOnlyCoreFonts = true; // false is default
$mpdf->SetDisplayMode('fullpage');
// Buffer the following html with PHP so we can store it to a variable later
ob_start();
?>
<?php include "balancesheet.php";
//This is your php page ?>
<?php
$html = ob_get_contents();
ob_end_clean();
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($html);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>
please help..
Are you sure that you want to use mpdf? There are several other options. For example, dompdf explicitly supports complex tables. And you can see some other options in this answer

Is there a way to sync column widths in an html table?

If I have these two tables:
<table>
<tr>
<td>Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
How can I make it so that the two columns have the same width?
I can't combine the tables so thats not an option. I also can't use fixed widths since its dynamic content. Any ideas? Perhaps something in javascript to have the top columns match the width of the lower table? I'm no js expert so I have no idea if thats possible or how to do it. Php is an option on the table as well if theres a way to use that to solve it as well.
Are you able to define css for this dynamic content? Suppose these tables were nested inside a div like so:
<div id="content">
<table>
<tr>
<td>Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
</div>
I would write some css like this:
#content table td { width: 80%; }
I would use a percentage-based width on the 'flowing' column, and buffer it with fixed-width columns if necessary. ie.:
<table style="width: 100%;">
<tr>
<td style="width: 80%;">Small Length Content</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td style="width: 80%;">Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
You can use CSS to accomplish this. You will have to have the longer content wrap.
td{
width:80%;
}
Try
<table>
<tr>
<td style="width:200px">Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
or add a class to name to the td element and define the style somewhere else like an external file or in header style

Categories