Chrome headless printtopdf - total page number in body - google-chrome

I am trying to get totalPages number from the footer to the body so i can use it in javascript, to remove some table if there is more then 1 page.
Any idea ?

You can do this:
"footerTemplate" => "<span class='totalPages'></span>"
this will show you the count of all pages in the footer

Related

HTML Foot on page 2

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 }; ?>

mPDF footer showing only on last 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

What's wrong with this Facebook Graph JSON call?

I'm trying to pull photos from an album (timeline) on Facebook and insert them into a list on a website but it's not grabbing all the photos.
I am using the ?limit=xxx in the URL to grab more than the first page but it still isn't working. Should I be using the paging ids and if so, what would be the syntax?
$.getJSON('https://graph.facebook.com/616894958361877/photos?limit=500&callback=?',function(json){
$.each(json.data,function(){
$('<li></li>').append('<span class="thumb" style="background: url(' + this.images[1].source + ') center center no-repeat; background-size: cover;"></span>').appendTo('#timeline');
});
});
This is the public facebook album in question:
https://goo.gl/ofrVjw
Looks like the limit is 100. Check the graph explorer for that. The limit 500 is overridden with 100 and the api return pagination details.
Also in the above code snippet, while accessing images array there can be cases where images which might not have images[1] so try to handle that. Something like this
((photo.images[1]) ? photo.images[1].source: ''
In this demo http://jsbin.com/nalusu/1/ you can see that the api returns 100 results.

Load html table at specific column

I'm trying to on page load get my html table to load at a specific column, I wouldn't even know where to start with this.
I've uploaded it here to see a demo: http://jsfiddle.net/3EFqD/
I've tried this in my body tag:
onload=' location.href="#right_column" '
and added id='right_column' to the correct td but that didn't work
Trying to get it to load on the cell that is labeled "this one"
Here's a fiddle incorporating the width of the header: Fiddle
Again, a jquery solution, essentially the same as above but needs to subtract the header width to hit the right position. See the fiddle for where the id's are added
$(document).ready(function(){
var hw = $('#headerWidth').width();
var f = $('#scrollToMe').position().left - hw;
$('.inner').scrollLeft(f);
})
If Im right in thinking you want a specific column to be scrolled to on page load, the easiest way would be to use a library, e.g. jQuery:
$('.inner').stop().animate({
scrollLeft: $('#right_column').offset().left
}, 1000);
Demo Fiddle
You're trying to make it work in a similar way to using anchors- however this isnt possible for horizontally aligned content.
May be if you are trying to load some html code(like table) in the mentioned td(This one), as you mentioned add id=right_column to this td and then use the below jquery logic -
var newtable = '<table class="newtable">New table, this may be from ajax call also</table>'
$('#right_column').html(newtable);

Drupal + LightBox2 component = use body as title (caption) for lightbox

I am using the LightBox2 component on my website to display the gallery images in a grouped lightbox. I add images to the website by using the Image component and adding all the images to the Photos book. However, images can still be viewed separately on a page, if I so choose. The url would then look something like this: www.myurl.com/node/37 with body content (that I added in the Create Image process) displaying beneath the image.
I was wondering if I can get this body content of this new image node page to display as the title for the Lightbox when it opens, if a user clicks on an image in the gallery.
TIA
It seems impossible without hacking the Lightbox2 module.
If you modify Image Gallery's view to include image's body field, you'll be able to hack lightbox2\js\auto_image_handling.js to take body as title.
yes, write a function that prints the html you want to show, register the function with hook_menu, then call it. voila.
e.g.
function mymodule_menu() {
$items['lightboxhtml'] = array(
'page callback' => 'mymodule_html4lightbox',
'page arguments' => array(1),
...
}
function mymodule_html4lightbox($nid) {
$node = node_load($nid);
print $node->body;
exit;
}
in the that calls lightbox, call it with /lightboxhtml/$nid as the href.