groupdocs-signature / GroupDocs.Signature-for-Java-Spring

Moved to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java/tree/master/Demos/Spring
https://products.groupdocs.com/signature/java
MIT License
2 stars 2 forks source link

Accessing custom method from signatureservice is not working #40

Open atirtahirgroupdocs opened 4 years ago

atirtahirgroupdocs commented 4 years ago

This issue is raised here https://forum.groupdocs.com/t/digital-signature-application-compatibility-with-internet-explorer-using-spring-java/7898/48.

Hi,

  1. User cloned groupdocstotal-angular project and copied signature and common-components folder into my project as per the advanced scenario mentioned here
  2. To render the uploaded document, user called super.selectFile() in custom component
  3. Now, user wants to access a method called sign() in signatureservice but not sure how to achieve this

Have a look at this screenshot. image (2)

Summary: Have a look at the attached code (code.txt). User is able to successfully render the document by calling selectFile() method. User wants to modify few things in this service sign() from SignatureService.ts and call it explicitly in my Component. Have a look at this image. sign How can we do it?. Please assist.
code.txt

Pavel-Teplitsky commented 3 years ago

Hi @atirtahirgroupdocs thank you for your question.

To customize sign action try the following:

  1. Create a custom document signing action. For example:

    signDocument() {
    //this.prepareSignaturesData() is taken from parent component 
    const signatures = this.prepareSignaturesData();
    //this.credentials.password is taken from parent component
    this.password = this.credentials.password;
    const docType = FileUtil.find(this.currentFile.Name).format;
    //this.guid - is a file name or any other string data to determine which file is currently signing
    this._appService.sign(this.guid, signatures, docType, this.password).subscribe((file: any) => {
    //do something with responce
    });
    }
  2. Create custom action to send sign document API call. In the code example from step 1 it's a _this._appService.sign()_ action. For example:

    
    sign(documentGuid: string, signatures: any[], fileType: string, password: string) {
    return this._http.post(this._config.getProductsApiEndpoint() + urlToApiAction, {
      guid: hash,
      password: password,
      signaturesData: signatures,
      documentType: fileType,
    }, Api.httpOptionsJson);
    }

3. Set this action to sign button in html template like shown on the screenshot above.
![screenshot](https://user-images.githubusercontent.com/2689279/102060451-ddf6f600-3dfa-11eb-80f4-2bef5738817c.png)