thread-pond / signature-pad

A jQuery plugin for assisting in the creation of an HTML5 canvas based signature pad. Records the drawn signature in JSON for later regeneration.
BSD 3-Clause "New" or "Revised" License
730 stars 290 forks source link

Submit the online signature to mail #174

Closed flovro closed 8 years ago

flovro commented 8 years ago

Hi!

I'm using this plugin to add the signature for a form. I'm using the multi-signature. Everything works great. I want when I press submit buttom to got the signature in the email (as attachment). Using the "plan text" mail format I got the json code of the image, but when I tried to display on the HTML mail I got no code.

How to do?

Many thanks

thomasjbradley commented 8 years ago

I think you'd have to grab the signature’s image, as a PNG, either using the getSignatureImage() function or use something like the Signature to Image PHP convertor.

After you have a PNG image you can attach that to the mail message.

flovro commented 8 years ago

this is how it's look the message body part:

if (!empty($_POST["output2"])) {
                 $caregiver_signature = test_input($_POST["output2"]);
                 $msg .= "Caregiver Signature: <img src='$caregiver_signature'<br/>";
                 $msg .="\r";
             } 

the getSignatureImage() can be used just inside the javascript?

thanks

thomasjbradley commented 8 years ago

Yeah, it can be used in Javascript. Or you can use this PHP convertor to generate the image: https://github.com/thomasjbradley/signature-to-image

flovro commented 8 years ago

yes but on the email is not working that signature to image... maybe use like

$json = $_POST['output2']; // From Signature Pad
$img = sigJsonToImage($json);
$sign = imagepng($img, 'signature.png');
$message .= "Signature: "'.$sign.'"

PS: I'm new to PHP :) I tried the above method and on email I got something like "Signature: 1" what do you think?

I also got this issue: Warning: Invalid argument supplied for foreach() in /nfs/c09/h01/mnt/209663/domains/aphria.com/html/signature-to-image.php on line 58

thomasjbradley commented 8 years ago

On the last line of the code above, we can’t just include an image like you've done. We need to add the image to the email as an attachment. Maybe look into some PHP code to help you add attachments to emails for PHP.

For the error, my thought is that maybe the $json variable is empty?

flovro commented 8 years ago

$json variable is not empty. :(

flovro commented 8 years ago

How to save on the server the signature? for example www.sitename.com/signatures/client_name.jpg ? and when I have multiple signatures?

Many thanks

thomasjbradley commented 8 years ago

The code you posted above, will do exactly that:

$sign = imagepng($img, 'signature.png');

It should save a file named signature.png.

flovro commented 8 years ago

and where it will save the image? on the server?

thomasjbradley commented 8 years ago

Yep, to the path you specify as the second argument. Where is says signtare.png—that’s the path it will save to.

flovro commented 8 years ago

Hi Thomas! Saving the image to the server I got this

Warning: Invalid argument supplied for foreach() in /server_path/html/signature-to-image.php on line 58

Warning: imagepng() expects parameter 1 to be resource, null given in /server_path/html/register-validation.php on line 188

What to do?

thomasjbradley commented 8 years ago

I don’t know exactly what that code is doing. I would try doing print($json) and see what gets output first. Should look like this, but really long: [{"lx":20,"ly":34,"mx":20,"my":34},{"lx":21,"ly":33,"mx":20,"my":34}…

flovro commented 8 years ago

Hi Thomas! If I will give you the access to ftp will you glad to help me?  thanks PS: I really need this Cu stima, Florin Sbarcea

On Tuesday, March 8, 2016 5:55 PM, Thomas J Bradley <notifications@github.com> wrote:

I don’t know exactly what that code is doing. I would try doing print($json) and see what gets output first. Should look like this, but really long: [{"lx":20,"ly":34,"mx":20,"my":34},{"lx":21,"ly":33,"mx":20,"my":34}…— Reply to this email directly or view it on GitHub.

thomasjbradley commented 8 years ago

I can take a quick look when I get a chance.

flovro commented 8 years ago

Hi Thomas!

I managed how to save an image to the server via this code:

//Patient Signature
   if (!empty($_POST['output'])) {
       $patient_signature = $_POST['output']; // From Signature Pad
       require_once 'signature-to-image.php';
       $img1 = sigJsonToImage($patient_signature);
       $sign1 = imagepng($img1, $_SERVER['DOCUMENT_ROOT'].'/signatures/'.$firstname.'_'.$lastname.'_signature.png');
   }

When I'm trying to save the second image on the server it;s not saving even I have the right base64 code from $_post[output2]

How to save the output2 on the server, same for output3

Many thanks

thomasjbradley commented 8 years ago

That code should work okay, by just changing $_POST['output2'] etc. Did you change the <input name="output2"> in the HTML also?

flovro commented 8 years ago

yes I have changed that also on the html

flovro commented 8 years ago
if (!empty($_POST['output3'])) {
       $caregiver_patient_signature = $_POST['output3']; // From Signature Pad
      require_once 'signature-to-image.php';
          $img3 = sigJsonToImage($caregiver_patient_signature);
       $sign3 = imagepng($img3, $_SERVER['DOCUMENT_ROOT'].'/signatures/'.$caregiver_patient_name.'_signature_car_pat.png');
   }
flovro commented 8 years ago

and also I got the json(base64 code) for the second and third image but not saving on the server

thomasjbradley commented 8 years ago

There aren't any errors showing in the PHP?

flovro commented 8 years ago

no error

thomasjbradley commented 8 years ago

Maybe try moving the require_once up higher in the code and deleting it from each of the if-statements.

flovro commented 8 years ago

I did that and same only first image it's saving on the server. To be a server issue? also after submiting the form, only after 7 minutes I'm getting the email with the first image as attachement and as link.

flovro commented 8 years ago

Also I have increased the width and the height of the canvas. How to move a little bit down that light grey border? Or to remove that light grey border

thomasjbradley commented 8 years ago

Try debugging the if-statements to see if they are running. One simple way would be to write something like echo 'in 2nd if'; at the top of each of them.

thomasjbradley commented 8 years ago

Border: https://github.com/thomasjbradley/signature-pad/blob/gh-pages/documentation.md#options-reference

lineColour, lineWidth, lineTop

flovro commented 8 years ago

ok will do that :)

flovro commented 8 years ago

if-statements are working, I got for each if their echo. What to do?