Created
March 20, 2024 08:59
-
-
Save bjoerntx/c94d40055ef19d5436f0b043b6f21d1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HttpClient } from '@angular/common/http'; | |
import { Component, OnInit, HostListener } from '@angular/core'; | |
declare const TXDocumentViewer: any; | |
interface DocumentData { | |
document?: string; | |
name?: string; | |
} | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrl: './app.component.css', | |
}) | |
export class AppComponent implements OnInit { | |
public documentData: DocumentData = {}; | |
constructor(private http: HttpClient) { } | |
@HostListener('window:documentViewerLoaded', ['$event']) | |
onDocumentViewerLoaded() { | |
TXDocumentViewer.signatures.setSubmitCallback(function (data: string) { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:application/pdf;;base64,' + data); | |
element.setAttribute('download', "results.pdf"); | |
document.body.appendChild(element); | |
element.click(); | |
}) | |
var signatureSettings = { | |
showSignatureBar: true, | |
redirectUrlAfterSignature: 'https://localhost:7275/document/sign', | |
ownerName: 'Paul', | |
signerName: 'Jacob', | |
signerInitials: 'PK', | |
signatureBoxes: [{ name: 'txsign', signingRequired: true, style: 0 }] | |
}; | |
TXDocumentViewer.loadDocument(this.documentData.document, this.documentData.name, signatureSettings); | |
} | |
ngOnInit() { | |
this.getDocument(); | |
} | |
getDocument() { | |
this.http.get<DocumentData>('/document/load').subscribe( | |
(result) => { | |
this.documentData = result; | |
} | |
); | |
} | |
title = 'myangularbackend.client'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment