From 6c16d00031e6645fefe6598cc7dc0d248ec89322 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Thu, 4 Apr 2024 15:26:41 +0530 Subject: [PATCH] feat: attach digital sign to completion certificate --- apps/OpenSign/src/components/pdf/PdfHeader.js | 474 +++++------------- apps/OpenSign/src/components/pdf/PrevNext.js | 45 +- apps/OpenSign/src/pages/PdfRequestFiles.js | 16 +- apps/OpenSign/src/pages/SignyourselfPdf.js | 11 +- apps/OpenSign/src/styles/signature.css | 51 -- .../cloud/parsefunction/DocumentBeforesave.js | 4 +- .../parsefunction/pdf/GenerateCertificate.js | 244 +++++++++ .../cloud/parsefunction/pdf/PDF.min.js | 184 ++++--- .../cloud/parsefunction/sendMailv3.js | 30 +- apps/OpenSignServer/logo.png | Bin 0 -> 88554 bytes 10 files changed, 535 insertions(+), 524 deletions(-) create mode 100644 apps/OpenSignServer/cloud/parsefunction/pdf/GenerateCertificate.js create mode 100644 apps/OpenSignServer/logo.png diff --git a/apps/OpenSign/src/components/pdf/PdfHeader.js b/apps/OpenSign/src/components/pdf/PdfHeader.js index 771770ced..f006a8efc 100644 --- a/apps/OpenSign/src/components/pdf/PdfHeader.js +++ b/apps/OpenSign/src/components/pdf/PdfHeader.js @@ -1,7 +1,5 @@ import React from "react"; import PrevNext from "./PrevNext"; -import { PDFDownloadLink } from "@react-pdf/renderer"; -import Certificate from "./Certificate"; import printModule from "print-js"; import { getBase64FromUrl } from "../../constant/Utils"; import { saveAs } from "file-saver"; @@ -13,14 +11,11 @@ import { themeColor } from "../../constant/const"; function Header({ isPdfRequestFiles, isPlaceholder, - recipient, setIsDecline, pageNumber, - isAlreadySign, allPages, changePage, pdfUrl, - documentStatus, embedWidgetsData, pdfDetails, signerPos, @@ -94,109 +89,15 @@ function Header({ // Replace spaces with underscore return pdfName.replace(/ /g, "_"); }; - //certificate generate and download component in mobile view - const CertificateDropDown = () => { - //after generate download certifcate pdf - const handleDownload = (pdfBlob, fileName) => { - if (pdfBlob) { - const url = window.URL.createObjectURL(pdfBlob); - // Create a temporary anchor element - const link = document.createElement("a"); - link.href = url; - link.download = fileName; - // Append the anchor to the body - document.body.appendChild(link); - // Programmatically click the anchor to trigger the download - link.click(); - // Remove the anchor from the body - document.body.removeChild(link); - // Release the object URL to free up resources - window.URL.revokeObjectURL(url); - } - }; - return ( - e.preventDefault()} - style={{ textDecoration: "none", zIndex: "35" }} - document={} - > - {({ blob, loading }) => ( - <> - {loading ? ( -
- - Certificate -
- ) : ( -
- handleDownload( - blob, - `completion certificate-${ - pdfDetails[0] && pdfDetails[0].Name - }.pdf` - ) - } - > - - Certificate -
- )} - - )} -
- ); - }; - const CertificateComponent = () => { - return ( - } - fileName={`completion certificate-${ - pdfDetails[0] && pdfDetails[0].Name - }.pdf`} - > - {({ loading }) => ( - - )} - - ); + //handle download signed pdf + const handleDownloadCertificate = () => { + if (pdfDetails?.length > 0 && pdfDetails[0]?.CertificateUrl) { + const certificateUrl = pdfDetails[0] && pdfDetails[0]?.CertificateUrl; + saveAs(certificateUrl, `Certificate_signed_by_OpenSign™.pdf`); + } }; + return (
{isMobile && isShowHeader ? ( @@ -210,11 +111,7 @@ function Header({ }} >
-
{ - navigate(-1); - }} - > +
navigate(-1)}>
- - {recipient && pdfDetails[0] && pdfDetails.length > 0 ? ( - - + {isCompleted && ( + handleDownloadCertificate()} + > +
+ + Certificate +
- ) : isPdfRequestFiles && - alreadySign && - isCompleted.isCertificate ? ( - - + )} + {isSignYourself && ( + setIsEmail(true)} + > +
+ + Mail +
- ) : ( - isSignYourself && ( - <> - - - - setIsEmail(true)} - > -
- - Mail -
-
- - ) )} - {" "}