Skip to content

Commit 4262e0e

Browse files
fix: text input font size isssue in mobile view
1 parent 7d48742 commit 4262e0e

File tree

5 files changed

+45
-37
lines changed

5 files changed

+45
-37
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,8 @@ function PlaceholderType(props) {
520520
? props.pos.options?.fontSize + "px"
521521
: "12px",
522522
color: props.pos.options?.fontColor || "black",
523-
fontFamily: "Arial, sans-serif"
523+
fontFamily: "Arial, sans-serif",
524+
overflow: "hidden"
524525
}}
525526
>
526527
<span>{type}</span>
@@ -607,7 +608,8 @@ function PlaceholderType(props) {
607608
? props.pos.options?.fontSize + "px"
608609
: "12px",
609610
color: props.pos.options?.fontColor || "black",
610-
fontFamily: "Arial, sans-serif"
611+
fontFamily: "Arial, sans-serif",
612+
overflow: "hidden"
611613
}}
612614
>
613615
<span>{type}</span>
@@ -740,7 +742,8 @@ function PlaceholderType(props) {
740742
? props.pos.options?.fontSize + "px"
741743
: "12px",
742744
color: props.pos.options?.fontColor || "black",
743-
fontFamily: "Arial, sans-serif"
745+
fontFamily: "Arial, sans-serif",
746+
overflow: "hidden"
744747
}}
745748
>
746749
<span>{type}</span>

apps/OpenSign/src/constant/Utils.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,15 +1249,30 @@ export const changeImageWH = async (base64Image) => {
12491249
});
12501250
};
12511251

1252+
//function to calculate font size of text area widgets
1253+
const calculateFontSize = (position, containerScale, signyourself) => {
1254+
const font = position?.options?.fontSize || 12;
1255+
if (!signyourself && position?.isMobile && position?.scale) {
1256+
return font / position?.scale / containerScale;
1257+
} else {
1258+
return font / containerScale;
1259+
}
1260+
};
12521261
//function for embed multiple signature using pdf-lib
12531262
export const multiSignEmbed = async (
12541263
xyPositionArray,
12551264
pdfDoc,
12561265
signyourself,
12571266
scale,
1258-
containerScale
1267+
pdfOriginalWH,
1268+
containerWH
12591269
) => {
12601270
for (let item of xyPositionArray) {
1271+
const containerScale = getContainerScale(
1272+
pdfOriginalWH,
1273+
item?.pageNumber,
1274+
containerWH
1275+
);
12611276
const typeExist = item.pos.some((data) => data?.type);
12621277
let updateItem;
12631278

@@ -1417,9 +1432,13 @@ export const multiSignEmbed = async (
14171432
}
14181433
} else if (widgetTypeExist) {
14191434
const font = await pdfDoc.embedFont("Helvetica");
1420-
const fontSize =
1421-
parseInt(position?.options?.fontSize / containerScale) ||
1422-
12 / containerScale;
1435+
const fontSize = calculateFontSize(
1436+
position,
1437+
containerScale,
1438+
signyourself
1439+
);
1440+
parseInt(fontSize);
1441+
14231442
const color = position?.options?.fontColor;
14241443
let updateColorInRgb;
14251444
if (color === "red") {

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import {
3030
contactBook,
3131
handleDownloadPdf,
3232
handleToPrint,
33-
handleDownloadCertificate,
34-
getContainerScale
33+
handleDownloadCertificate
3534
} from "../constant/Utils";
3635
import LoaderWithMsg from "../primitives/LoaderWithMsg";
3736
import HandleError from "../primitives/HandleError";
@@ -679,7 +678,7 @@ function PdfRequestFiles(props) {
679678
widgetKey,
680679
radioExist,
681680
requiredCheckbox,
682-
pageNumber; // `pageNumber` is used to check on which page user did not fill widget's data then change current pageNumber and show tour message on that page
681+
TourPageNumber; // `pageNumber` is used to check on which page user did not fill widget's data then change current pageNumber and show tour message on that page
683682

684683
for (let i = 0; i < checkUser[0].placeHolder.length; i++) {
685684
for (let j = 0; j < checkUser[0].placeHolder[i].pos.length; j++) {
@@ -727,7 +726,7 @@ function PdfRequestFiles(props) {
727726
) {
728727
showAlert = true;
729728
widgetKey = requiredCheckbox[i].key;
730-
pageNumber = updatePage;
729+
TourPageNumber = updatePage;
731730
setminRequiredCount(parseMin);
732731
}
733732
//else condition to validate minimum required checkbox
@@ -738,8 +737,7 @@ function PdfRequestFiles(props) {
738737
if (!showAlert) {
739738
showAlert = true;
740739
widgetKey = requiredCheckbox[i].key;
741-
pageNumber = updatePage;
742-
740+
TourPageNumber = updatePage;
743741
setminRequiredCount(parseMin);
744742
}
745743
}
@@ -765,7 +763,7 @@ function PdfRequestFiles(props) {
765763
if (!checkDefaultSigned && !showAlert) {
766764
showAlert = true;
767765
widgetKey = requiredRadio[i].key;
768-
pageNumber = updatePage;
766+
TourPageNumber = updatePage;
769767
setminRequiredCount(null);
770768
}
771769
}
@@ -793,7 +791,7 @@ function PdfRequestFiles(props) {
793791
if (!checkDefaultSigned && !showAlert) {
794792
showAlert = true;
795793
widgetKey = requiredWidgets[i].key;
796-
pageNumber = updatePage;
794+
TourPageNumber = updatePage;
797795
setminRequiredCount(null);
798796
}
799797
}
@@ -809,15 +807,15 @@ function PdfRequestFiles(props) {
809807
}
810808
if (checkboxExist && requiredCheckbox && showAlert) {
811809
setUnSignedWidgetId(widgetKey);
812-
setPageNumber(pageNumber);
810+
setPageNumber(TourPageNumber);
813811
setWidgetsTour(true);
814812
} else if (radioExist && showAlert) {
815813
setUnSignedWidgetId(widgetKey);
816-
setPageNumber(pageNumber);
814+
setPageNumber(TourPageNumber);
817815
setWidgetsTour(true);
818816
} else if (showAlert) {
819817
setUnSignedWidgetId(widgetKey);
820-
setPageNumber(pageNumber);
818+
setPageNumber(TourPageNumber);
821819
setWidgetsTour(true);
822820
} else {
823821
setIsUiLoading(true);
@@ -858,18 +856,14 @@ function PdfRequestFiles(props) {
858856
await embedDocId(pdfDoc, documentId, allPages);
859857
}
860858
}
861-
const containerScale = getContainerScale(
862-
pdfOriginalWH,
863-
pageNumber,
864-
containerWH
865-
);
866859
//embed multi signature in pdf
867860
const pdfBytes = await multiSignEmbed(
868861
pngUrl,
869862
pdfDoc,
870863
isSignYourSelfFlow,
871864
scale,
872-
containerScale
865+
pdfOriginalWH,
866+
containerWH
873867
);
874868
// console.log("pdfte", pdfBytes);
875869
//get ExistUserPtr object id of user class to get tenantDetails

apps/OpenSign/src/pages/PlaceHolderSign.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -854,18 +854,14 @@ function PlaceHolderSign() {
854854
ignoreEncryption: true
855855
});
856856
const isSignYourSelfFlow = false;
857-
const containerScale = getContainerScale(
858-
pdfOriginalWH,
859-
pageNumber,
860-
containerWH
861-
);
862857
try {
863858
const pdfBytes = await multiSignEmbed(
864859
placeholder,
865860
pdfDoc,
866861
isSignYourSelfFlow,
867-
containerWH,
868-
containerScale
862+
scale,
863+
pdfOriginalWH,
864+
containerWH
869865
);
870866

871867
const fileName = sanitizeFileName(pdfDetails[0].Name) + ".pdf";

apps/OpenSign/src/pages/SignyourselfPdf.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -691,18 +691,14 @@ function SignYourSelf() {
691691
if (!HeaderDocId) {
692692
await embedDocId(pdfDoc, documentId, allPages);
693693
}
694-
const containerScale = getContainerScale(
695-
pdfOriginalWH,
696-
pageNumber,
697-
containerWH
698-
);
699694
//embed multi signature in pdf
700695
const pdfBytes = await multiSignEmbed(
701696
xyPostion,
702697
pdfDoc,
703698
isSignYourSelfFlow,
704699
scale,
705-
containerScale
700+
pdfOriginalWH,
701+
containerWH
706702
);
707703
// console.log("pdf", pdfBytes);
708704
//function for call to embed signature in pdf and get digital signature pdf

0 commit comments

Comments
 (0)