Skip to content

Commit 375dc86

Browse files
Merge pull request #998 from OpenSignLabs/input_text_darkmode
fix: type initials and signature looks blurry on download pdf
2 parents d2f187f + 10e0153 commit 375dc86

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 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,
@@ -99,7 +98,12 @@ function SignPad({
9998
} else {
10099
if (isTab === "type") {
101100
setIsSignImg("");
102-
onSaveSign(null, false, textWidth, textHeight);
101+
onSaveSign(
102+
null,
103+
false,
104+
!isInitial && textWidth > 150 ? 150 : textWidth,
105+
!isInitial && textHeight > 35 ? 35 : textHeight
106+
);
103107
} else {
104108
setIsSignImg("");
105109
canvasRef.current.clear();
@@ -211,11 +215,11 @@ function SignPad({
211215
: fontSelect
212216
? fontSelect
213217
: "Fasthand";
214-
218+
const fontSizeValue = "40px";
215219
//creating span for getting text content width
216220
const span = document.createElement("span");
217221
span.textContent = textContent;
218-
span.style.font = `20px ${fontfamily}`; // here put your text size and font family
222+
span.style.font = `${fontSizeValue} ${fontfamily}`; // here put your text size and font family
219223
span.style.color = color ? color : penColor;
220224
span.style.display = "hidden";
221225
document.body.appendChild(span); // Replace 'container' with the ID of the container element
@@ -225,7 +229,8 @@ function SignPad({
225229
// Draw the text content on the canvas
226230
const ctx = canvasElement.getContext("2d");
227231
const pixelRatio = window.devicePixelRatio || 1;
228-
const width = span.offsetWidth;
232+
const addExtraWidth = isInitial ? 10 : 50;
233+
const width = span.offsetWidth + addExtraWidth;
229234
const height = span.offsetHeight;
230235
setTextWidth(width);
231236
setTextHeight(height);

0 commit comments

Comments
 (0)