Skip to content

Commit e337a79

Browse files
fix: type initials and signature looks blurry on download pdf
1 parent 779a84c commit e337a79

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/OpenSign/src/components/pdf/SignPad.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useRef, useState, useEffect } from "react";
22
import SignatureCanvas from "react-signature-canvas";
3-
43
function SignPad({
54
isSignPad,
65
isStamp,
@@ -100,6 +99,12 @@ function SignPad({
10099
if (isTab === "type") {
101100
setIsSignImg("");
102101
onSaveSign(null, false, textWidth, textHeight);
102+
onSaveSign(
103+
null,
104+
false,
105+
textWidth > 150 ? 150 : textWidth,
106+
textHeight > 35 ? 35 : textHeight
107+
);
103108
} else {
104109
setIsSignImg("");
105110
canvasRef.current.clear();
@@ -215,7 +220,7 @@ function SignPad({
215220
//creating span for getting text content width
216221
const span = document.createElement("span");
217222
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
219224
span.style.color = color ? color : penColor;
220225
span.style.display = "hidden";
221226
document.body.appendChild(span); // Replace 'container' with the ID of the container element
@@ -225,7 +230,8 @@ function SignPad({
225230
// Draw the text content on the canvas
226231
const ctx = canvasElement.getContext("2d");
227232
const pixelRatio = window.devicePixelRatio || 1;
228-
const width = span.offsetWidth;
233+
const addExtraWidth = isInitial ? 0 : 50;
234+
const width = span.offsetWidth + addExtraWidth;
229235
const height = span.offsetHeight;
230236
setTextWidth(width);
231237
setTextHeight(height);

0 commit comments

Comments
 (0)