How PHP generates a part of a Web page. jpg

Source: Internet
Author: User
Now there is a need to put a part of the Web page (user panel, pretty complex) to generate pictures, how to implement with PHP

Reply content:

Now there is a need to put a part of the Web page (user panel, pretty complex) to generate pictures, how to implement with PHP

You can try using PHP with other tools, such as this: http://cutycapt.sourceforge.net/

This has to be client-side with the server is a client thing to save is PHP thing
Use ActiveX or Java applets or JavaScript to see for yourself.
An example of JavaScript http://html2canvas.hertzen.com/index ....
The bookmarklet of the petals has implemented JavaScript functionality.

can be implemented using canvas tags, but that's not a picture, just a label.

If you implement a real-world image, you need to generate images using PHP's GD library or Imagick on the server side. The scenario upstairs is not feasible because of the client behavior in essence.

With Pantomjs, the equivalent of a WebKit browser without a view, you can render the Web page on the server side.

1 iecapt but need to win the server, the specific need for Google
2 use Wkhtmltopdf to save the URL page as a PDF and convert it to PDF 2 jpg under Linux
3 Imagegrabwindow Manual with Demo

The bold guess landlord this may be in some specific valuable operation of the backup.

It is easy to think that using PHP to parse the HTML code directly, and then use regular GD to generate images, unfortunately, PHP does not parse the HTML code, or there is no more sophisticated parsing of HTML extensions. So the key to the problem is parsing the HTML code.

Personal opinion, you can consider this idea: first mark the need for a specific Div-id block, using PHP to find a way to get this piece of code, there are a lot of methods, and then put this piece of code, one by one in accordance with CSS rules parsing, because it is their own use, you can only support the drawing of the CSS style useful, And then on the map GD draw out can, everything as far as possible on Jane.

Of course, there is a soil approach that may be most effective. Just a User panel page, you can manually put this page, and then use the Paint tool to remove the variable, save as a picture of GD in the future to create a base plate. And then slightly change your program, in the user panel generated some information, you can change part of the way to write to the GD picture, write only need to specify the pixel location to write information. This method is completely passed through the HTML parsing, perhaps a relatively quick approach. The disadvantage is that there is no reusability.

PHP Common Code Farm, welcome to shoot bricks.

while (1) {    printf (' hello,world! ');}
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.