How can I convert text and images on a webpage into an image?

Source: Internet
Author: User
In my current website, there is a page for users to browse and edit the contract content, adding text and images. Finally, you need to output the entire contract content (including text and user-uploaded images) on the page to the image format. May I ask: ① can it be implemented and how can it be implemented? (The method I have come up with is to render the image on the server and then call it to the front-end. The specific implementation process is not mentioned. & gt; & lt;) ② if it can be implemented, are there any restrictions on the formats of images uploaded by users? (PNGJPG) Thank you very much. In my current website, there is a page for users to browse/edit the contract content, adding text and images. Finally, you need to output the entire contract content (including text and user-uploaded images) on the page to the image format.
Excuse me:
① Can it be implemented and how can it be implemented? (The method I have come up with is to render the image on the server and call it to the front-end. The specific implementation process cannot be described.> <)
② If it can be implemented, is there any restriction on the format of the image uploaded by the user? (PNG/JPG)

Thank you very much. Reply content: First, answer the following question:

① Can it be implemented and how can it be implemented?

A: Yes, and it is a front-end implementation. The details are as follows:

② If it can be implemented, is there any restriction on the format of the image uploaded by the user? (PNG/JPG)

A:No restrictions

The following is a detailed description:

Front-end Html2canvas. jsYou can convert html CanvasFinal output Base64Code Image

The usage is very simple.
Note: This example uses JqueryLibrary.

Use the following code:
  1. The first parameter is the region to be captured.
  2. The second parameter is generated.

Html2canvas ($ ('. droppable '), {onrendered: function (canvas) {var data = canvas. toDataURL ("image/png"); // The generated format // data is the generated base64 code }});
Http://wkhtmltopdf.org
You can convert images and pdf files to the gd library. You can enable the gd2 library.
Call imagettftext ().
Note that UTF-8 is required for text content encoding.

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.