Issue
I am trying to take a screenshot of a page using GD library but as a result Screen capture only returns a black image.
<?php
header('Content-type: text/html; charset=windows-1251');
?>
<?php
header("Location:http://10.32.172.30:9080/RTOnline/b/p/115");
$img = imagegrabscreen();
imagepng($img, 'screenshot.png');
?>
Solution
Well you can use a command line tool to take a screenshot of a webpage. You can run the tool within Php using shell_exec function. For example the wkhtmltopdf command line tool allows converting from html to pdf and other formats.
If the web page contains complex JavaScript or Ajax, then you can use a headless browser to take the screenshot. For example see: Chrome Headless. Also see the Html2Canvas script. It allows taking screenshots using JavaScript.
Also see this question: Website screenshots
Answered By - Nadir Latif Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.