Hi, I am using group docs with Java Spring application. When i login to the application, I have to upload the document first and then preview it and then add a signature icon and other extra fields like user id, date in the bottom of document before sending it to the recipient for Signature. The recipient will get to know where he has to sign once he opens the document. Is it possible to do it ? Can you please advise ?
Thanks for posting your inquiry.
Your desired functionality can be achieved using a combination of Text and Image signatures. The text signature will be used to add the user ID, date or any other fields, whereas, the image signature will be used to place the signature icon. The following code sample shows how to implement this scenario. Please note that this code is specific for PDF documents, however, you can implement this functionality for other document formats in the similar way (see documentation).
// Set configurations SignatureConfig signConfig = new SignatureConfig(); signConfig.setStoragePath("D:\\Storage\\"); signConfig.setOutputPath("D:\\Output\\"); String fileName = "candy.pdf"; // Instantiating the signature handler SignatureHandler<String> handler = new SignatureHandler<String>(signConfig); // Set up image signature PdfSignImageOptions signImageOptions = new PdfSignImageOptions(signConfig.getStoragePath() + "sign.png"); signImageOptions.setWidth(20); signImageOptions.setHeight(20); // you can change the margins according to your requirements signImageOptions.getMargin().setBottom(20); signImageOptions.setHorizontalAlignment(HorizontalAlignment.Left); signImageOptions.setVerticalAlignment(VerticalAlignment.Bottom); // Set up text signature Date date = new Date(); // You can set desired text here (UserID, date etc.) PdfSignTextOptions signTextOptions = new PdfSignTextOptions("John Smith, " + date.toString()); // you can change the margins according to your requirements signTextOptions.getMargin().setBottom(10); signTextOptions.setHorizontalAlignment(HorizontalAlignment.Left); signTextOptions.setVerticalAlignment(VerticalAlignment.Bottom); signTextOptions.getFont().setFontSize(5); signTextOptions.setHeight(10); // Set up save options SaveOptions saveOptions = new SaveOptions(); saveOptions.setOutputType(OutputType.String); saveOptions.setOutputFileName("signed_output"); // Add signatures to the collection SignatureOptionsCollection collection = new SignatureOptionsCollection(); collection.add(signImageOptions); collection.add(signTextOptions); // Apply signatures to document String signedPath = handler.<String> sign(fileName, collection, saveOptions);
Furthermore, you can also try our open source front end application for signing documents which is available here. You can use this application and modify it as per your requirements. Hope it helps.
Hi , Thank you for the update. I am using the front end application now to add the required texts. But I am facing an issue. The save button is always disabled in this application. I am unable to save my changes. Can you please let me know why this behaviour ? . I have a valid group docs total license and I have also set the application.LicensePath. Can you please advise ?
Thanks for coming back.
We have checked the application at our end but could not reproduce your reported issue. Please make sure that after adding the signature on the document pages, you are applying the signature by clicking on the green tick mark button (see screenshot). Once you have applied the signature, the Save button becomes enable (see screenshot). When you click the Save button, the signed document gets saved in \DocumentSamples\SignatureData\Output folder.
Hi, Thanks for the update. I understood what you said. I will try it out. I have integrated the spring signature code in my spring boot application but when i add a text signature and confirm , i get this thing “Evaluation version etc.”. Here is the image
download.png (483 Bytes)
I am assuming the issue is related to the license. I have a valid license and it’s path has been set in application.LicensePath. Can you please advise how do i set the correct license path ?
I have a spring boot application. I have the license file in F drive and I have set it like this “application.licensePath=F:\GroupDocs.Total.Java.lic”
Hi, Thank you for the support. In Addition, I printed the stack trace while loading the license for signature. Please find the error logs attached. I could not figure it out. Can you please suggest what kind of error it is ?
LicenseError.pdf (65.1 KB)
Thanks for coming back to us.
The API shows this evaluation message when the license is not applied. Therefore, please make sure that you have provided the correct path of the license file in the configurations. Also, please check that the application has access to the location where the license file is placed. Furthermore, if you have updated the license file’s path in configurations then you will have to rebuild the source code. You can easily do this by following the below points:
- Update licensePath’s value in configuration.yml (see example)
- Open Windows PowerShell or Command Prompt and navigate to the project’s root folder
- Build the source code by running the command:
mvn clean spring-boot:run
- Open application’s URL (i.e. http://localhost:8080/signature/) in the browser
Hope it helps.