1
1
import React , { useRef , useState , useEffect } from "react" ;
2
2
import SignatureCanvas from "react-signature-canvas" ;
3
-
4
3
function SignPad ( {
5
4
isSignPad,
6
5
isStamp,
@@ -100,6 +99,12 @@ function SignPad({
100
99
if ( isTab === "type" ) {
101
100
setIsSignImg ( "" ) ;
102
101
onSaveSign ( null , false , textWidth , textHeight ) ;
102
+ onSaveSign (
103
+ null ,
104
+ false ,
105
+ textWidth > 150 ? 150 : textWidth ,
106
+ textHeight > 35 ? 35 : textHeight
107
+ ) ;
103
108
} else {
104
109
setIsSignImg ( "" ) ;
105
110
canvasRef . current . clear ( ) ;
@@ -215,7 +220,7 @@ function SignPad({
215
220
//creating span for getting text content width
216
221
const span = document . createElement ( "span" ) ;
217
222
span . textContent = textContent ;
218
- span . style . font = `20px ${ fontfamily } ` ; // here put your text size and font family
223
+ span . style . font = `40px ${ fontfamily } ` ; // here put your text size and font family
219
224
span . style . color = color ? color : penColor ;
220
225
span . style . display = "hidden" ;
221
226
document . body . appendChild ( span ) ; // Replace 'container' with the ID of the container element
@@ -225,7 +230,8 @@ function SignPad({
225
230
// Draw the text content on the canvas
226
231
const ctx = canvasElement . getContext ( "2d" ) ;
227
232
const pixelRatio = window . devicePixelRatio || 1 ;
228
- const width = span . offsetWidth ;
233
+ const addExtraWidth = isInitial ? 0 : 50 ;
234
+ const width = span . offsetWidth + addExtraWidth ;
229
235
const height = span . offsetHeight ;
230
236
setTextWidth ( width ) ;
231
237
setTextHeight ( height ) ;
0 commit comments