From e337a79e2eefeffe1f48458e3ba23d096332e916 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Thu, 1 Aug 2024 13:32:18 +0530 Subject: [PATCH 1/4] fix: type initials and signature looks blurry on download pdf --- apps/OpenSign/src/components/pdf/SignPad.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.js index 627d7a857..64db3b88f 100644 --- a/apps/OpenSign/src/components/pdf/SignPad.js +++ b/apps/OpenSign/src/components/pdf/SignPad.js @@ -1,6 +1,5 @@ import React, { useRef, useState, useEffect } from "react"; import SignatureCanvas from "react-signature-canvas"; - function SignPad({ isSignPad, isStamp, @@ -100,6 +99,12 @@ function SignPad({ if (isTab === "type") { setIsSignImg(""); onSaveSign(null, false, textWidth, textHeight); + onSaveSign( + null, + false, + textWidth > 150 ? 150 : textWidth, + textHeight > 35 ? 35 : textHeight + ); } else { setIsSignImg(""); canvasRef.current.clear(); @@ -215,7 +220,7 @@ function SignPad({ //creating span for getting text content width const span = document.createElement("span"); span.textContent = textContent; - span.style.font = `20px ${fontfamily}`; // here put your text size and font family + span.style.font = `40px ${fontfamily}`; // here put your text size and font family span.style.color = color ? color : penColor; span.style.display = "hidden"; document.body.appendChild(span); // Replace 'container' with the ID of the container element @@ -225,7 +230,8 @@ function SignPad({ // Draw the text content on the canvas const ctx = canvasElement.getContext("2d"); const pixelRatio = window.devicePixelRatio || 1; - const width = span.offsetWidth; + const addExtraWidth = isInitial ? 0 : 50; + const width = span.offsetWidth + addExtraWidth; const height = span.offsetHeight; setTextWidth(width); setTextHeight(height); From 912efeb5fdf47e5e225719ddb9e71bdba666a3a4 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Thu, 1 Aug 2024 15:50:48 +0530 Subject: [PATCH 2/4] refactor-code --- apps/OpenSign/src/components/pdf/SignPad.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.js index 64db3b88f..815448e4a 100644 --- a/apps/OpenSign/src/components/pdf/SignPad.js +++ b/apps/OpenSign/src/components/pdf/SignPad.js @@ -98,7 +98,6 @@ function SignPad({ } else { if (isTab === "type") { setIsSignImg(""); - onSaveSign(null, false, textWidth, textHeight); onSaveSign( null, false, @@ -216,11 +215,11 @@ function SignPad({ : fontSelect ? fontSelect : "Fasthand"; - + const fontSizeValue = isInitial ? "60px" : "40px"; //creating span for getting text content width const span = document.createElement("span"); span.textContent = textContent; - span.style.font = `40px ${fontfamily}`; // here put your text size and font family + span.style.font = `${fontSizeValue} ${fontfamily}`; // here put your text size and font family span.style.color = color ? color : penColor; span.style.display = "hidden"; document.body.appendChild(span); // Replace 'container' with the ID of the container element @@ -230,7 +229,7 @@ function SignPad({ // Draw the text content on the canvas const ctx = canvasElement.getContext("2d"); const pixelRatio = window.devicePixelRatio || 1; - const addExtraWidth = isInitial ? 0 : 50; + const addExtraWidth = isInitial ? 20 : 50; const width = span.offsetWidth + addExtraWidth; const height = span.offsetHeight; setTextWidth(width); From 42cbe94af83cb39973c37772a4d53dbff4186ac4 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Thu, 1 Aug 2024 16:50:48 +0530 Subject: [PATCH 3/4] fix: initial type signature issue --- apps/OpenSign/src/components/pdf/SignPad.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.js index 815448e4a..21bc746fb 100644 --- a/apps/OpenSign/src/components/pdf/SignPad.js +++ b/apps/OpenSign/src/components/pdf/SignPad.js @@ -215,7 +215,7 @@ function SignPad({ : fontSelect ? fontSelect : "Fasthand"; - const fontSizeValue = isInitial ? "60px" : "40px"; + const fontSizeValue = isInitial ? "20px" : "40px"; //creating span for getting text content width const span = document.createElement("span"); span.textContent = textContent; @@ -229,7 +229,7 @@ function SignPad({ // Draw the text content on the canvas const ctx = canvasElement.getContext("2d"); const pixelRatio = window.devicePixelRatio || 1; - const addExtraWidth = isInitial ? 20 : 50; + const addExtraWidth = isInitial ? 10 : 50; const width = span.offsetWidth + addExtraWidth; const height = span.offsetHeight; setTextWidth(width); From 10e0153018a03899eddf09e5d09a382c15d764bc Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Thu, 1 Aug 2024 17:56:44 +0530 Subject: [PATCH 4/4] fix: initial type signature bulry issue --- apps/OpenSign/src/components/pdf/SignPad.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.js index 21bc746fb..e362ca23f 100644 --- a/apps/OpenSign/src/components/pdf/SignPad.js +++ b/apps/OpenSign/src/components/pdf/SignPad.js @@ -101,8 +101,8 @@ function SignPad({ onSaveSign( null, false, - textWidth > 150 ? 150 : textWidth, - textHeight > 35 ? 35 : textHeight + !isInitial && textWidth > 150 ? 150 : textWidth, + !isInitial && textHeight > 35 ? 35 : textHeight ); } else { setIsSignImg(""); @@ -215,7 +215,7 @@ function SignPad({ : fontSelect ? fontSelect : "Fasthand"; - const fontSizeValue = isInitial ? "20px" : "40px"; + const fontSizeValue = "40px"; //creating span for getting text content width const span = document.createElement("span"); span.textContent = textContent;