How to export the whole page or html content with Highcharts not just the chart?

后端 未结 3 804
清酒与你
清酒与你 2020-12-28 21:54

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 th

3条回答
  •  清歌不尽
    2020-12-28 22:21

    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

提交回复
热议问题