-1

In php i have a site to where an html form is generated from database.Now my client requires that this list should be converted to image and should be downloaded in client system.So i need a method to convert HTML page form to image with help of basic PHP.

user3085576
  • 167
  • 1
  • 1
  • 5
  • 1
    Googling will help. Even `PHP Convert HTML to image with PHP` will turn up plenty of useful results. That should really be your first stop before asking here. – Pekka Dec 10 '13 at 06:59
  • Possible duplicate of [Website screenshots using PHP](http://stackoverflow.com/q/757675) – Pekka Dec 10 '13 at 07:04
  • @Pekka웃, really? I'm googling for two days and I still didn't find anything solid! This question is actually relevant – João Pimentel Ferreira May 10 '17 at 20:58
  • @JoãoPimentelFerreira When I google `php convert html to image` there are several other Stack Overflow questions and they seem much better at listing every possibility to do this that exists right now. I don't see how this question brings anything new to the table when dozens of identical others (with better answers) already exist? Maybe the problem here is that a "solid" solution (i.e. One that does a simple PHP function call and gets you what you want) doesn't exist unfortunately... If you have a server with root access this should definitely be possible though. – Pekka May 11 '17 at 15:14
  • 2
    Oh look, it's 2017 and googling PHP Convert HTML to image with PHP directs to here as the best result. I wish people would just answer the damn question instead of saying this, because suggesting the search term 'PHP Convert HTML to image with PHP' literally improves the ranking for this very page! –  May 15 '17 at 14:51

2 Answers2

1

You can use webthumbactiveX for this from site http://www.acasystems.com/en/web-thumb-activex/faq-php-convert-html-to-image.htm

this PHP sample script shows how to make a web thumbnail image from HTML page in the memory and output to client browser.

PHP script file: online-thumb.php

<?
// Create instance ACAWebThumb.ThumbMaker
$HTML_Converter = new COM("ACAWebThumb.ThumbMaker") or die("Create ACAWebThumb.ThumbMaker failed. Please make sure the component has been installed.");

// Get the parameters
$t_strURL = isset($_GET["url"]) ? $_GET["url"] : "http://www.google.com";
$t_iWidth = isset($_GET["width"]) ? $_GET["width"] : 320;
$t_iHeight = isset($_GET["height"]) ? $_GET["height"] : 240;
$t_iRatioType = isset($_GET["ratiotype"]) ? $_GET["ratiotype"] : 0;

// Set the URL and start the snap job.
$HTML_Converter->SetURL($t_strURL);
if ( 0 == $HTML_Converter->StartSnap() ){

 // snap successful, set the thumbnail size and get image bytes
 $HTML_Converter->SetThumbSize ($t_iWidth, $t_iHeight, $t_iRatioType);

 //get image bytes by PNG format
 $t_arrThumbImageBytes = $HTML_Converter->GetImageBytes ("png");

 // output the image bytes to client browser
 if ( count($t_arrThumbImageBytes) > 0 ){

  // set the output header as PNG image, then output the thumbnail image bytes.
  header("Content-type: image/png");
  foreach($t_arrThumbImageBytes as $byte)
    echo chr($byte);
 }

}

?>
Mithun Sen
  • 523
  • 5
  • 19
user3085676
  • 112
  • 1
  • 5
-4

you can give a button for printing that page like

<input type="button" value="Print this page" onClick="window.print()">

so the client can print at his will

omrehman
  • 107
  • 3
  • 13