Make a js editor and submit it to the PHP backend to generate an image. Because of the special requirements of the customer, if the Editor contains the following DIV, ask how to precisely display the coordinates in the generated image {code ...} in fact, the segmentfault text occupies less than 400 pixels in width. If the text is left, then... I am working on a js editor and submit it to the PHP backend to generate an image. Due to the special requirements of the customer, if the Editor contains the following DIV, I would like to ask how to precisely display coordinates in the generated image.
segmentfault
In fact, the segmentfault text occupies less than 400 pixels in width. If the text is left, it can be accurately obtained and generated based on the relative positioning of the DIV. However, if the text is centered or right, The DIV is used to locate the text, the location generated in php gd is incorrect. So how can I locate the text of the recipient?
Reply content:
I am working on a js editor and submit it to the PHP backend to generate an image. Due to the special requirements of the customer, if the Editor contains the following DIV, I would like to ask how to precisely display coordinates in the generated image.
segmentfault
In fact, the segmentfault text occupies less than 400 pixels in width. If the text is left, it can be accurately obtained and generated based on the relative positioning of the DIV. However, if the text is centered or right, The DIV is used to locate the text, the location generated in php gd is incorrect. So how can I locate the text of the recipient?
Just two days ago,
You need to put a piece of p on the page,
Html2canvas found online
Js sends the data to the backend php to generate an image, which can be used (chrome, firefox ),
But not compatible with browsers earlier than ie9 !!!
Miserable
GD can locate the text or center the text. You can refer to the imagettfbbox function on the right. However, according to my impression, the results of this function are often inaccurate (especially for some special fonts ), we recommend that you use the imagick extension to generate images.