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:
- The first parameter is the region to be captured.
- 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.