hi all my chart is exporting fine with highcharts i m getting the chart for my php project
but the problem is
that i am looking to import html content or the whole page along with the chart not just the chart
is it possible to do ??
can any one help me
or show here is a sample fiddle http://jsfiddle.net/YBXdq/
i need to export the text below the chart has well
There are so many direct and indirect way to achieve this
Use HTML Canvas : http://html2canvas.hertzen.com/
Using wkhtmltoimage
Example
exec('wkhtmltoimage --quality 50 http://www.bbc.com bbc.jpg');
Using wkhtmltopdf + ImageMagic
-- Convert the web page to pdf using wkhtmltopdf
-- Convert pdf to jpg using ImageMagic
Example
exec("convert a.pdf a.jpg");
Use PHP imagegrabwindow and imagegrabscreen
Example
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://localhost");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);
Advance Examples
-- Also See Get Website Screenshots Using PHP
For Possible Issues : Getting imagegrabscreen to work
use Webshort and call it from php using exec if you have python installed
Example
exec("python webshot.py https://example.com/webshot/php example.png");
Download and use Website Thumbnail Generator
Example
webthumb.php?url=http://www.google.com&x=150&y=150
Use boxcutter
Example
exec('boxcutter -f image.png');
Capture Screenshots in PHP with GrabzIt
Example
$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
$id = $grabzIt->TakePicture("http://www.google.com", "http://www.example.com/GrabzItHandler.php");
using wimg.ca
Example with this current page
http://wimg.ca/https://stackoverflow.com/questions/10328457/how-to-export-the-whole-page-or-html-content-with-highcharts-not-just-the-chart/10330701#10330701
TimThumb – PHP Image Resizer
Example
timthumb.php?src=http://www.google.com/&webshot=1
I think have given more than enough example
You can try to print the page , or make a pdf using php file functions to get the desired html content .
or you can try the method told by baba to get the image :)
i found a simple workaround for exporting charts (printing)
and
i didn't use any plugin just little plain old css and some javascript
which in my case is
i wanted to print the chart with some specific html content of the page
or in my case i wanted to remove header , footer and left menu
i dint wanted to show buttons or unecessary content
and just show the page content , description table and chart
so here is i how i achieved it.
> CSS :-
<style type="text/css">
#media print{
#page
{
size: auto; /* auto is the initial value */
margin: 0mm; /* this affects the margin in the printer settings */
}
body{ background-color:#FFFFFF; background-image:none; color:#000000 }
.navimainbg{ display:none;}
.printhide{ display:none;}
.usercontent-footer{ display:none;}
.linkBTN{ display:none;}
.userheader{ display:none;}
.user-profile-left{ display:none;}
#userbgcontent{ width:100%;}
}
</style>
We are focussing on the print css here which we implied when the page is printed
acess the divs or portions of the page which you dont want ot be printed via their class or id depending upon your usage
for example
i didnt wanted to display the button
.linkBTN{ display:none;}
which can be simply called via javascript.
Javascript :->
<script type="text/javascript">
function printpage()
{
window.print()
}
<script type="text/javascript">
we can invoke the print function to print the page minus elements we dont want to print with the page via click of a button by calling function in my case "printpage" as you can
see this button will also not display while printing as printhide class display is set to none while priting
<input title="Print a Printer Friendly Page" class ="printhide" type="button" value="Print this page" onclick="printpage()">
isnt is it a simple way to print chart other than highcharts printing if you want to print more
only con is that sometime the image will slide down when you want to show it along with some conetent due to lack of size to render an image . it will shift to next page . other than its tested working .
Related
I am trying to include a pdf file in my HTML page and allow users to print that by using cmd+p or ctrl+p.
Here is my code -
<html>
<body>
<p> I want to print this page with pdf </p>
<iframe src="/my.pdf" width="800px" height="2100px" />
</body>
<html>
When I visit my page I am able to see the pdf file but when I try to print it shows me a blank page for pdf.
I am building this application with PHP. I have tried the embed and object tag also but had no luck with this.
Please help me to fix this.
Such functionality is not possible as explained here: Print Pdf from javascript embed tag
The only real thing you can do is try to convert the PDF to images and use the "#media print" tag to style the printing page appropiately.
It's a different matter
Record it for others.
If there are a lot of blank pages, the class you want to print out:
#media print{
.paper {
display:inline-block
}
}
Apply above CSS. My problem solve by this trick.
I hope there's someone out there that can help. I am trying to use jQuery Backstretch to apply a different background image for each specific page within Bootstrap/Wordpress. e.g:
Home - bg image a
About - bg image b
News - bg image c
and so on...
I've managed to use the standard Backstretch script to display a single image for all pages, but I am totally lost (even after searching) on how to apply the the above.
My code so far:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://myurl.co.uk/wp-content/themes/wpbootstra/bootstrap/js/jquery.backstretch.min.js"></script>
<script>
$.backstretch("http://myurl.co.uk/wp-content/themes/wpbootstrap/bootstrap/img/test_bg.jpeg");
</script>
I have used this in my footer.php.
Does anyone have a solution?
You could try:
<?php
if(is_page(42))
{
echo '<script>$.backstretch("http://myurl.co.uk/wp-content/themes/wpbootstrap/bootstrap/img/test_bg.jpeg");</script>';
}
else if(is_page(41))
{
echo '<script>$.backstretch("http://myurl.co.uk/wp-content/themes/wpbootstrap/bootstrap/img/test_bg_b.jpeg");</script>';
}
?>
The number 42, 41 being the id of the page. Sp text_bg_b.jpeg will only display on the About us page (assuming its id is 41).
I think there is no need for using backstretch: Just add this css styles inline to your body or main container:
background: url(PATHTOYOURIMAGE) center center no-repeat;
background-size: cover;
You should consider using a custom field for giving the path to your image. I think the easiest way is to install Advanced Custom Fields and to add a field called bg_image to every site with the image url in it. Then you can replace PATHTOYOURIMAGE with
<?php the_field('bg_image'); ?>
It is another way but I think you should give it a try.
<script type="text/php">
if(isset($pdf)){
$w = $pdf->get_width();
$h = $pdf->get_height();
$footer = $pdf->open_object();
global $id
$pdf->image('s/'.$id.'-here.jpg', "jpg", 0, $h - 279, 611, 279);
$pdf->close_object();
$pdf->add_object($footer, "all");
}
</script>
I am trying to add a footer similar image on the end of the page and this is the only code I actually managed to have the picture on the bottom, however I got two problems now:
If the tables text (content) of the PHP html goes to long it's hidden by the image (in this case) i want to break the page and then add the image in the bottom on the new page.
How can I make it's only added on the last page if there are more than one by simply the dynamic output I am doing on a table.
Anyway I can overcome the problems above with simply this code? I've been trying using header/bottom CSSes like https://code.google.com/p/cleanstickyfooter/ as well but the method above is working expect the sligh issues just described.
THE HTML is simple tables with a width of 100%...
QUICK update (though)
I think I can solve the first issue by adding a empty div with a set height of the image, now I would only want to add this onto the last page... How?
Inline script is rendered starting with the page dompdf is currently laying out. If you want your image to apply only to the end of the document you can just relocate the script to the end of the HTML content.
Also, if you only need to apply the image to the last page you don't need to use detached objects ($pdf->open_object()/$pdf->close_object()/$pdf->add_object()). The purpose of detached objects is to provide a means of reusing content. So your inline script can be as simple as:
<script type="text/php">
if(isset($pdf)){
$w = $pdf->get_width();
$h = $pdf->get_height();
global $id
$pdf->image('s/'.$id.'-here.jpg', "jpg", 0, $h - 279, 611, 279);
}
</script>
Lastly, if you're using dompdf 0.6.0 (currently in beta) you can skip the inline script and just position the image. Positioned content is also rendered starting with the page dompdf is currently laying out. So you can also get the desired image layout adding the following to the bottom of your HTML content:
<div style="position: absolute; bottom: 10px;">
<img src="s/$id-here.jpg">
<div>
You must, of course, generate the required HTML for the image. I'm assuming you're already doing that since you're accessing the $id global variable in the inline script.
I want to print only the image in a HTML page.
I used
function printImg(){
var URL = "image.png";
var W = window.open(URL);
W.window.print();
}
But executing the code, whole page prints rather the image. Are there any method to print only the image? Pls guide me.
Thanks.
create one print.css that hide all other unwanted divs except the image
If you heard about CSS Media types then you can achieve your desired task with this technique.
Example:
Define Media Type Print and then add a css class.noprint with a css rule display:none; in your css file like given below:
#media print {
.noprint{ display: none }
}
And then apply this class on the elements you don't want to print.
SEE AN EXAMPLE
Hope this will help you a lot.
Use
W.print();
instead of
W.window.print();
W.window makes reference to the parent's window of the pop-up.
Besides this you may consider using an empty page with a window.print triggered on load, instead of your current method which is not waiting for the image to be ready.
== EDIT ==
This can't be done. You can't modify browser settings (i.e. printer settings) from JavaScript
Finally I thought of convert my result to PDF format and print using FPDF Library
You can create an image element then append it to the DOM.
function printImg() {
var img = document.createElement( "img" );
img.src = "image.png";
document.body.appendChild( img );
}
hi all my chart is exporting fine with highcharts i m getting the chart for my php project
but the problem is
that i am looking to import html content or the whole page along with the chart not just the chart
is it possible to do ??
can any one help me
or show here is a sample fiddle http://jsfiddle.net/YBXdq/
i need to export the text below the chart has well
There are so many direct and indirect way to achieve this
Use HTML Canvas : http://html2canvas.hertzen.com/
Using wkhtmltoimage
Example
exec('wkhtmltoimage --quality 50 http://www.bbc.com bbc.jpg');
Using wkhtmltopdf + ImageMagic
-- Convert the web page to pdf using wkhtmltopdf
-- Convert pdf to jpg using ImageMagic
Example
exec("convert a.pdf a.jpg");
Use PHP imagegrabwindow and imagegrabscreen
Example
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://localhost");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);
Advance Examples
-- Also See Get Website Screenshots Using PHP
For Possible Issues : Getting imagegrabscreen to work
use Webshort and call it from php using exec if you have python installed
Example
exec("python webshot.py https://example.com/webshot/php example.png");
Download and use Website Thumbnail Generator
Example
webthumb.php?url=http://www.google.com&x=150&y=150
Use boxcutter
Example
exec('boxcutter -f image.png');
Capture Screenshots in PHP with GrabzIt
Example
$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
$id = $grabzIt->TakePicture("http://www.google.com", "http://www.example.com/GrabzItHandler.php");
using wimg.ca
Example with this current page
http://wimg.ca/https://stackoverflow.com/questions/10328457/how-to-export-the-whole-page-or-html-content-with-highcharts-not-just-the-chart/10330701#10330701
TimThumb – PHP Image Resizer
Example
timthumb.php?src=http://www.google.com/&webshot=1
I think have given more than enough example
You can try to print the page , or make a pdf using php file functions to get the desired html content .
or you can try the method told by baba to get the image :)
i found a simple workaround for exporting charts (printing)
and
i didn't use any plugin just little plain old css and some javascript
which in my case is
i wanted to print the chart with some specific html content of the page
or in my case i wanted to remove header , footer and left menu
i dint wanted to show buttons or unecessary content
and just show the page content , description table and chart
so here is i how i achieved it.
> CSS :-
<style type="text/css">
#media print{
#page
{
size: auto; /* auto is the initial value */
margin: 0mm; /* this affects the margin in the printer settings */
}
body{ background-color:#FFFFFF; background-image:none; color:#000000 }
.navimainbg{ display:none;}
.printhide{ display:none;}
.usercontent-footer{ display:none;}
.linkBTN{ display:none;}
.userheader{ display:none;}
.user-profile-left{ display:none;}
#userbgcontent{ width:100%;}
}
</style>
We are focussing on the print css here which we implied when the page is printed
acess the divs or portions of the page which you dont want ot be printed via their class or id depending upon your usage
for example
i didnt wanted to display the button
.linkBTN{ display:none;}
which can be simply called via javascript.
Javascript :->
<script type="text/javascript">
function printpage()
{
window.print()
}
<script type="text/javascript">
we can invoke the print function to print the page minus elements we dont want to print with the page via click of a button by calling function in my case "printpage" as you can
see this button will also not display while printing as printhide class display is set to none while priting
<input title="Print a Printer Friendly Page" class ="printhide" type="button" value="Print this page" onclick="printpage()">
isnt is it a simple way to print chart other than highcharts printing if you want to print more
only con is that sometime the image will slide down when you want to show it along with some conetent due to lack of size to render an image . it will shift to next page . other than its tested working .