简体   繁体   English

如何使用Highcharts导出整个页面或html内容而不仅仅是图表?

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

hi all my chart is exporting fine with highcharts im getting the chart for my php project 嗨所有我的图表导出精细与highcharts即时获取我的PHP项目的图表

but the problem is 但问题是

that i am looking to import html content or the whole page along with the chart not just the chart 我希望导入HTML内容或整个页面以及图表而不仅仅是图表

is it possible to do ?? 有可能吗?

can any one help me 谁能帮我

or show here is a sample fiddle http://jsfiddle.net/YBXdq/ 或者在这里展示的是一个样本小提琴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 有很多直接和间接的方法来实现这一目标

Example

  exec('wkhtmltoimage --quality 50 http://www.bbc.com bbc.jpg');
  • Using wkhtmltopdf + ImageMagic 使用wkhtmltopdf + ImageMagic

    -- Convert the web page to pdf using wkhtmltopdf - 使用wkhtmltopdf将网页转换为pdf

    -- Convert pdf to jpg using ImageMagic - 使用ImageMagic将pdf转换为jpg

Example

exec("convert a.pdf a.jpg");

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 - 另请参阅使用PHP获取网站截图

For Possible Issues : Getting imagegrabscreen to work 对于可能的问题:使imagegrabscreen工作

  • use Webshort and call it from php using exec if you have python installed 如果安装了python,请使用Webshort并使用exec从php调用它

Example

exec("python webshot.py https://example.com/webshot/php example.png");

Example

webthumb.php?url=http://www.google.com&x=150&y=150

Example

exec('boxcutter -f image.png');
  • Capture Screenshots in PHP with GrabzIt 使用GrabzIt捕获PHP中的屏幕截图

Example

$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
$id = $grabzIt->TakePicture("http://www.google.com", "http://www.example.com/GrabzItHandler.php");

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

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 . 您可以尝试打印页面,或使用php文件函数制作pdf以获得所需的html内容。

or you can try the method told by baba to get the image :) 或者你可以尝试baba告诉的方法来获取图像:)

i found a simple workaround for exporting charts (printing) 我找到了一个简单的解决方法来导出图表(打印)

and

i didn't use any plugin just little plain old css and some javascript 我没有使用任何插件只是一点点旧的CSS和一些JavaScript

which in my case is 在我的情况下是

i wanted to print the chart with some specific html content of the page 我想打印带有页面特定html内容的图表

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 :- > 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 我们专注于打印页面打印时隐含的打印css

acess the divs or portions of the page which you dont want ot be printed via their class or id depending upon your usage 根据您的使用情况,访问您不希望通过他们的班级或ID打印的页面或部分页面

for example 例如

i didnt wanted to display the button 我不想显示按钮

 .linkBTN{ display:none;}

which can be simply called via javascript. 这可以通过javascript简单地调用。

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 我们可以通过调用我的案例“printpage”中的函数来调用打印功能来打印页面减去我们不想打印的页面,只需点击一个按钮就可以看到这个按钮在打印作为printhide类显示时也不会显示在priting时设置为none

<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 . 除了经过测试的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM