问题
We have a custom product designing tool at "http://dev.ejuicysolutions.com/custom_shirt_designer/". When user will be finished with formatting with text etc... they will click on print button, where they can print but we need to extend functionality from print to "Save Image, as shown in Canvas" and then email that image. Email can be done but the main problem we are facing is that image is being saved on server but all other formatting like text are not being saved along with. Either script is just placing text etc using styles... on above the canvas... Any idea, how it can be achieved?
Thanks in advance!
回答1:
If i understand this right, you need to export the canvas content to an image, in the state it is when the user finished his work? There is an export function inside the canvas. canvas.toDataURL(). That way you get a base64 image, default is png format.
回答2:
Looks like the text is just HTML added on top of the canvas, so it wont get encoded with .toDataURL()
If you are using HTML emails you could save the CSS / HTML and then re-apply it on top of the png (set png as background image)
Or alternativly use canvas text instead of HTML, then it will be part of the .png
来源:https://stackoverflow.com/questions/15990696/canvas-to-save-image-and-email