I am making a PHP report and depending on the data received from the database is how long each page will be, I would like some text at the bottom of the last page when it is printed (doesn't matter what it really looks like on screen).
I have this for the footer, but it is showing it at the bottom of the first page, not the last page, Any help to move this would greatly be appreciated.
CSS:
#media print{
.footer{
position:absolute;
bottom:0;
}
}
HTML:
<span class="footer">Text 1</span>
that means you have a pagination right ?
if yes you have to check it in php. if the last page comes pass some parameter to the view. then check if the parameter is true sho the footer
for example in PHP do this :
if ($pagination.last) $last = true;
in HTML :
<?php if ($last) { ?><span class="footer">Text 1</span><?php }; ?>
Related
Hi everyone i want to hide date from my AD section (http://prntscr.com/lgsb8), i tried few CSS codes with inspect element but they seems to be not working.
Any one please check and provide me correct CSS code to hide or remove this from page.?
You can use nth-child to achieve this.
.short-features div:nth-child(3){
display: none;
}
Here you have some information about it, let me know if that helps.
You can change the date display in the theme editor by commenting out this code in your template:
<?php the_time('F j, Y'); ?> at <?phpthe_time() ?>
do this:
<!--<?phpthe_time('F j, Y'); ?> at <?phpthe_time() ?>-->
these will leave the code intact in case you ever want to put the date back in. As long as the code is commented out the date will not appear on the live page.
I have a problem with mPDF footer generating.
I am using mPDF with nette framework
<sethtmlpageheader name="default_head" value="1" page="ALL" show-this-page="1" />
{include #content}
<sethtmlpagefooter name="default_foot" value="1" page="ALL" />
Where #content is one or more a tables. Header is on every page, but footer is still only on the last page, no matter how many pages the document has.
Anyone has any idea what i might be doing wrong or forgeting?
Thank you for advice in advance
I have got one more solution by which you can add a content only on last page of mPDF.
Please follow below steps
Add header
Add footer
Write your HTML
Add Footer again (this will be only displayed on last page)
Output
$header = "Page header for all"; // Will be shown on all pages
$footer = "Page footer for all"; // Will be shown on all pages
$lastPageFooter = "Add New text for last page footer".$footer; // Adding new text
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLFooter($footer);
$html = $patientDetails . '' . $reportContent;
$mpdf->WriteHTML($html);
$mpdf->SetHTMLFooter(lastPageFooter); // This will display footer for last page
$mpdf->Output();
Hope it helps
I am currently working on a semi dynamic page where I use some GET functionality to personalize it. I also echo the date a couple of places. At the bottom of this page, I would like to have a button that gives the visitor the option to download/open this page as PDF. Without the header. I have integrated DOMPDF, but I simply cant get it to work properly and need some help. I have tried a couple of things found here on Stackoverflow, with no success.
In basic, I need the whole page printed in the PDF, but it should not open when page is loaded. But triggered by the button. And then without the header (one spesific div). Is this possible?
<?php
require_once("dompdf/dompdf_config.inc.php");
$html =
'<html><body>'.
'<p>This is a test for '.
'<?php echo htmlentities(substr(urldecode($_SERVER["QUERY_STRING"]), 1)); ?> </p>'.
'<p>Thank you for reading.</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("the_inquiry.pdf");
return true;
?>
<html>
<body>
<div class="shouldnotPrintToPDF">
Content.
</div>
<div class="shouldPrintToPDF">
Sensitive content.
Open or save as PDF
</div>
</body>
</html>
This is basically our one page presentation. And contains a lot of text, so I will not present all of that here. But in this way, I have to write the page twice, in $html = as well as inside the actual tag. And the PDF save/open option pops up right from the start, which it should not. I also wish to append the echo htmlentities part to the actual pdf-name.. is this possible? The PDF opens and contains what put into the $html = just fine. But not triggered by the link.
Update:
When i do exactly what you perform here, I get an error "The requested URL /inquiry.php&pdf=1 was not found on this server." I have the page I am trying to print in pdf on root level, but the DOMPDF is in /dompdf.. I dont know if that has anything to do with it?
Update:
When i edited the link, i get all this information up in a new page, like below.
[_parse_properties(margin:=1.2cm)(empty)_parse_properties]
[_parse_sections[section[_parse_properties(display:=-dompdf-page)
(counter-reset:=page)(empty)_parse_properties]#html#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]
_parse_sections][_parse_sections[section[_parse_properties(display:=block)
(empty)_parse_properties]#div##map##dt##isindex#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]
_parse_sections][_parse_sections[section[_parse_properties(page-break
-before:=avoid)(display:=block)(counter-increment:=page)
(empty)_parse_properties]#body#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(margin:=1em
0)(empty)_parse_properties]#p##dl##multicol#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(margin-left:=40px)
(empty)_parse_properties]#dd#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(margin:=1em
40px)(empty)_parse_properties]#blockquote#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(font-style:=italic)
(empty)_parse_properties]#address#section]
[section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
[_parse_sections[section[_parse_properties(display:=block)(text-align:=center)
(empty)_parse_properties]#center#section]
Do you have any idea what it might be caused by?
Breakthrough:
When I activated DOMPDF_DPI it actually opens as PDF, but now all of the text comes on first line of the second page of the PDF. Like, all the text comes out on top of each other. Also, when it opens the PDF, the ?&pdf=1 are included in the htmlentities query string, which looks very messy since it is supposed to be a personalized page as well as the PDF.
You can set dompdf to parse CSS #media queries for standard media types (screen, print, voice, etc.). By default dompdf parses the "screen" media type styles, but you can change this in the configuration file. See the DOMPDF_DEFAULT_MEDIA_TYPE configuration setting. Then you just need to pass the original URL querystring with an appended variable telling the page to render to PDF. If your original URL is something like the_inquiry.php?name=Joe then your PDF URL could be the_inquiry.php?name=Joe&pdf=1.
Your code would then look similar to the following:
<?php
ob_start();
?>
<html>
<head>
<style>
#media print {
.shouldnotPrintToPDF, .pdflink { display: none; }
}
</style>
</head>
<body>
<div class="shouldnotPrintToPDF">
Content.
</div>
<div class="shouldPrintToPDF">
Sensitive content.
Open or save as PDF
</div>
</body>
</html>
<?php
if ( isset( $_GET['pdf'] ) ) {
require_once 'dompdf/dompdf_config.inc.php';
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("the_inquiry.pdf");
}
?>
I am working on this website that has a printing problem, if I do a print, the hyperlinks got printed out twice: here is what I meant by twice
Html code: <p>Urgent Care: 765-494-1724.</p>
Print output:
Urgent Care: 7654941724 (tel:7654941700)
I ONLY NEED Urgent Care: 765-494-1724 (NOT tel:7654941700). But, I do need the hyperlink to be <a href="tel:765-494-1700"> because this hyperlink needs to be used on cellphone, and when people click on it, it will auto driven them to the dial screen.
In my print.css file, I actually already try to fix this problem by doing:
a:link, a:visited {
content: "";
}
But It did not work :( So I am hoping that I could get some ideas on this problem if possible. Thanks a million!!!
P.S.: Working on MAC OS, chrome, safari, firefox all NOT printing right...
Add this to your print.css (and remove your a:link, a:visited rule)
#media print {
a[href]:after {
content: none !important;
}
}
Your HTML:
Urgent Care: <span class="phonenumber">765-494-1724</span>
Your CSS:
#media print {
a span.phonenumber{
display:none;
}
}
This will hide the text within the link, so it only shows the text of the link itself, which is the phone number (tel:765-494-1700).
Maybe you don't need to create a link, though, because most mobile browser will recognise any number as a phone number.
Alternatively, you can also make the phone number plain text (or a link with an empty href) and fill in the href using Javascript.
What if you just made the link like this:
.</p>
Does that make it just show up once?
in your print css do like below :
#media print
{
a.no_print{display:none;}
a.to_print{display:block;}
}
in the regular css you do the reverse :
a.no_print{display:block;}
a.to_print{display:none;}
And your html :
<p>Urgent Care: <a href="tel:765-494-1700" class="no_print" >765-494-1724</a> <a class="to_print" >765-494-1724</a>.</p>
I am making a application form for a survey of sorts, and want to include a progress bar at the top showing graphically (not really high end) how far the user has got.
I've spent a while surfing the net and asking Google in various ways to do this but it all comes out with progress bar for upload/download.
I am writing the form in XHTML and CSS with a PHP handler to a MySQL Database. The general thinking seems to be ASP (a few are JQuery)to which I have no experience, if it needs to be ASP then fine, but is there any other way and if it does need to be ASP can you please help?
Thank you in advance.
Possible solutions:
Include another image on each page, showing the progress.
Use php to get the current progress and include the image.
Make a div as a progressbar with different width
...
You could even just use simple html... However, here are two possible solutions with php:
<?php
$progress = 1;
$max = 5
echo "<img src=\"progress_".$progress.".jpg\" />"
?>
where progress_1.jpg, progress_2.jpg,... are your images.
Without images - just CSS:
<?php
$progress = 70;
$max = 100;
?>
<div style="height:15px; width:<?=$max?>px; background-color:silver; padding:1px;">
<div style="height: 100%; width:<?=$progress?>px; background-color:yellow"></div>
</div>