Bonjour,

Je suis entrain de develloper un formulaire qui genere un PDF.
Sur le PDF, j'aimerais faire apparaitre la signature du benificiaire. Il faut donc une zone de saisie en JAVA pour la souris ou un stylet puisse créer la signature.

J'ai trouvé un code qui permet de faire ceci :

SIGNPAD/

Ce que j'aimerais, c'est qu'il enregistre la signature en format JPEG comme il est sensé le faire mais helas, cela ne fonctionne pas.
J'ai aucune connaissance en JAVA, je developpe un peu en HTML/PHP puis de l'AutoIT.

Je viens vers vous pour essayer de me donner un coup de main.
Voici le code de l'index :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<html>
<!--
/*
 * Software is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 *
 * The Initial Developer of this code is SoftCorporation LLC.
 * Usage of this code allowed only with reference to SoftCorporation LLC
 * including a link to the web site: http://www.softcorporation.com
 * Copyright (C) 2001 SoftCorporation LLC. All Rights Reserved.
 */
-->
<head>
<title>SignPad Test Page</title>
<meta name="description" content="SignPad">
<meta name="keywords" content="Sign,e-sign,e-business,signature,Java,servlet,software,API,Applet,java language,free,download,application,">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
 
<body bgcolor="#FFFFFF" background="/images/mrblebg.gif">
 
                  <!-- BEGIN LINKEXCHANGE CODE -->
<center><iframe src="http://leader.linkexchange.com/X1613640/showiframe?" width=468 height=60 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no>
<a href="http://leader.linkexchange.com/X1613640/clickle" target="_top"></a></center>
<p align="center"><img width="468" height="60" border="0" ismap alt src="http://leader.linkexchange.com/X1613640/showle?"></iframe><br>
<a href="http://leader.linkexchange.com/X1613640/clicklogo" target="_top"><img src="http://leader.linkexchange.com/X1613640/showlogo?" border="0" ismap alt></a><br>
                  <!-- END LINKEXCHANGE CODE -->
</p>
<p align="center"><strong><big><big><big><big><big><big>SignPad</big></big></big></big></big></big></strong></p>
<p align="center"><em><big><big>e-Signature Java Applet &amp; Servlet</big></big></em></p>
 
<p align="center">
<applet CODE="SignPad" NAME="signPad" ARCHIVE="signpad.jar" WIDTH="400" HEIGHT="250">
  <param name="BACKGROUND" value="blue">
  <param name="FOREGROUND" value="white">
  Your browser doesn't support Java. Please download new version!
</applet>
</p>
<p align="center">
<!--
comment: Here we commented servlet test URL, because we don't run servlets on this web site.
  <form action="http://127.0.0.1:8080/servlet/TestServlet" method="POST" onSubmit='sign.value=signPad.getSign();'>
-->
  <form action="NoServletPage.html" method="GET" onSubmit='sign.value=signPad.getSign();'>
    <select name="saveas">
      <option value="jpeg" selected>JPEG</option>
      <option value="gif">GIF</option>
      <option value="zip">ZIP File</option>
    </select>
    <input type=button value="Clear" onclick="signPad.clear();">
    <input type=submit value="Send Signature">
    <input type=hidden name="sign" value="">
  </form>
</p>
<p align="center">&nbsp;</p>
 
<p align="left">Contents<br>
<br>
1. What is it?<br>
2. Where to get it?<br>
3. Requirements<br>
4. Release Notes<br>
5. Licensing and Legal Issues<br>
<br>
<br>
<b>1. What is it?<br>
</b><br>
SignPad is a 100% pure Java Applet &amp; Servlet to provide support for e-signature.<br>
Use mouse (or pen device) to sign and click "Send Signature".
See more info in included ReadMe.txt file.<br>
<br>
<p align="left"><br>
<b>2. Where to get it?<br>
</b><br>
The home page for the XMLLight project can be found in the SoftCorporation LLC.
web site <a href="http://www.softcorporation.com/products/signpad">http://www.softcorporation.com/products/signpad</a>.
There you also find the information on how to download the latest release as
well as all other information you might need regarding this project.<br>
<p align="center">
Click here to <a href="http://www.softcorporation.com/products/signpad/signpad.zip">download SignPad</a>.
</p>
<p align="left"><br>
<b>3. Requirements<br>
</b><br>
To use SignPad you need:<br>
<br>
o Java compatible browser on a client.<br>
o Java 1.1 or later compatible virtual machine on a server.<br>
<br>
<br>
<b>4. Release Notes</b>
<ul>
  <li>
    <p align="left">Release 1.0.0.<br>
    - initial release.<br>
  </li>
</ul>
<p align="left"><br>
<br>
<b>5. Licensing and legal issues<br>
</b><br>
For legal and licensing issues, please read the <a href="LICENSE.TXT">LICENSE.TXT</a> file.<br>
<br>
Java (TM) is trademark of Sun Microsystems, Inc.
<p align="center"><a href="http://www.softcorporation.com/downlds.htm">More free
downloads</a></p>
<p align="center"><a href="mailto:support@softcorporation.com"><font face="Arial, Helvetica" size="2">E-mail
to Tech Support Group</font></a></p>
<p align="center">&nbsp;</p>
<!--
<p align="center"><a href="http://www.jars.com"><img src="/images/java_registered.gif" width="103" height="58"></a></p>
-->
<p align="center">&nbsp;</p>
<p align="center"><font color="#C0C0C0"><small>Keywords: Java, Sign, e-sign, e-business,
signature, Java, e-signature, software, API, Applet, servlet, java language, download, application</small></font></p>
 
 
</body>
</html>
Voici l'arborescence :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
D:.
|   tree.txt
|   
\---signpad
    |   index.html
    |   LICENSE.TXT
    |   NoServletPage.html
    |   ReadMe.txt
    |   signpad.jar
    |   
    \---server
        +---classes
        |   |   TestServlet.class
        |   |   
        |   +---Acme
        |   |   |   IntHashtable.class
        |   |   |   IntHashtableEntry.class
        |   |   |   IntHashtableEnumerator.class
        |   |   |   
        |   |   \---JPM
        |   |       \---Encoders
        |   |               DCT.class
        |   |               GifEncoder.class
        |   |               GifEncoderHashitem.class
        |   |               Huffman.class
        |   |               ImageEncoder.class
        |   |               JpegEncoder.class
        |   |               JpegInfo.class
        |   |               
        |   \---com
        |       \---softcorporation
        |           \---signpad
        |                   SignProducer.class
        |                   
        \---src
            |   TestServlet.java
            |   
            \---Acme
                |   IntHashtable.java
                |   
                \---JPM
                    \---Encoders
                            GifEncoder.java
                            ImageEncoder.java
                            JpegEncoder.java
Et voici le code de TestServlet.java qui je penses est la source du probleme :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Software is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 *
 * The Initial Developer of this code is SoftCorporation LLC.
 * Usage of this code allowed only with reference to SoftCorporation LLC
 * including a link to the web site: http://www.softcorporation.com
 * Copyright (C) 2001 SoftCorporation LLC. All Rights Reserved.
 */
 
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.awt.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
import Acme.JPM.Encoders.*;
import com.softcorporation.signpad.*;
 
/*
 * SignPad Servlet Demo.
 *
 * @version: $Revision:   1.0  $
 */
public class TestServlet extends HttpServlet
{
  /*
   * Handles requests made with Post method
   *
   * @param req HttpServletRequest
   * @param res HttpServletRespons
   */
  public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException
  {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
 
    String sign   = req.getParameter("sign");
    String saveas = req.getParameter("saveas");
 
    out.println("<HTML>");
    out.println("<HEAD><TITLE>SignPad Test</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("Signature received. Length is " + sign.length() + " bytes.<br><br>");
 
    try
    {
      if ("gif".equals(saveas))
      {
        File file = new File("signtest.gif");
        FileOutputStream outFile = new FileOutputStream(file);
        DataOutputStream outStream = new DataOutputStream(outFile);
 
        Image image = SignProducer.getImage(sign);
        GifEncoder encoder = new GifEncoder(image, outStream);
        encoder.encode();
 
        int i = outStream.size();
 
        outStream.flush();
        outStream.close();
        outFile.close();
 
        out.println("GIF encoded image saved in file '" + file.getCanonicalPath() +
                    "'. File size is " + i + " bytes.");
      }
      else if ("jpeg".equals(saveas))
      {
        File file = new File("signtest.jpeg");
        FileOutputStream outFile = new FileOutputStream(file);
        DataOutputStream outStream = new DataOutputStream(outFile);
 
        Image image = SignProducer.getImage(sign);
        JpegEncoder encoder = new JpegEncoder(image, 75, outStream);
        encoder.Compress();
 
        int i = outStream.size();
 
        outStream.flush();
        outStream.close();
        outFile.close();
 
        out.println("JPEG encoded image saved in file '" + file.getCanonicalPath() +
                    "'. File size is " + i + " bytes.");
      }
      else
      {
        File file = new File("signtest.zip");
        FileOutputStream outFile = new FileOutputStream(file);
        ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(outFile));
        zos.putNextEntry(new ZipEntry("sign"));
 
        byte bytes[] = new byte[sign.length()];
        for (int i = 0; i < sign.length(); i++)
        {
          bytes[i] = (byte)sign.charAt(i);
        }
        zos.write(bytes);
        zos.finish();
        zos.close();
        outFile.close();
 
        System.out.println("Sign compressed and saved in file '" + file.getCanonicalPath());
      }
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
      out.println("<pre>");
      out.println(ex.getMessage());
      out.println("</pre>");
    }
    out.println("</BODY></HTML>");
  }
 
 
}
Cordialement
Romain