@@ -463,29 +463,29 @@ export const defaultWidthHeight = (type) => {
463
463
case "stamp" :
464
464
return { width : 150 , height : 60 } ;
465
465
case "checkbox" :
466
- return { width : 15 , height : 15 } ;
466
+ return { width : 15 , height : 17 } ;
467
467
case textInputWidget :
468
- return { width : 150 , height : 25 } ;
468
+ return { width : 150 , height : 17 } ;
469
469
case "dropdown" :
470
470
return { width : 120 , height : 22 } ;
471
471
case "initials" :
472
472
return { width : 50 , height : 50 } ;
473
473
case "name" :
474
- return { width : 150 , height : 25 } ;
474
+ return { width : 150 , height : 17 } ;
475
475
case "company" :
476
- return { width : 150 , height : 25 } ;
476
+ return { width : 150 , height : 17 } ;
477
477
case "job title" :
478
- return { width : 150 , height : 25 } ;
478
+ return { width : 150 , height : 17 } ;
479
479
case "date" :
480
480
return { width : 100 , height : 20 } ;
481
481
case "image" :
482
482
return { width : 70 , height : 70 } ;
483
483
case "email" :
484
- return { width : 150 , height : 20 } ;
484
+ return { width : 150 , height : 17 } ;
485
485
case radioButtonWidget :
486
486
return { width : 5 , height : 10 } ;
487
487
case textWidget :
488
- return { width : 150 , height : 25 } ;
488
+ return { width : 150 , height : 17 } ;
489
489
default :
490
490
return { width : 150 , height : 60 } ;
491
491
}
@@ -1013,7 +1013,7 @@ export const calculateInitialWidthHeight = (widgetData) => {
1013
1013
const intialText = widgetData ;
1014
1014
const span = document . createElement ( "span" ) ;
1015
1015
span . textContent = intialText ;
1016
- span . style . font = `14px ` ; // here put your text size and font family
1016
+ span . style . font = `12px ` ; // here put your text size and font family
1017
1017
span . style . display = "hidden" ;
1018
1018
document . body . appendChild ( span ) ;
1019
1019
const width = span . offsetWidth ;
@@ -1303,16 +1303,6 @@ export const changeImageWH = async (base64Image) => {
1303
1303
} ) ;
1304
1304
} ;
1305
1305
1306
- //function to calculate font size of text area widgets
1307
- const calculateFontSize = ( position , containerScale , signyourself ) => {
1308
- const font = position ?. options ?. fontSize || 12 ;
1309
- if ( ! signyourself && position ?. isMobile && position ?. scale ) {
1310
- return font / position ?. scale / containerScale ;
1311
- } else {
1312
- return font / containerScale ;
1313
- }
1314
- } ;
1315
-
1316
1306
const getWidgetsFontColor = ( type ) => {
1317
1307
switch ( type ) {
1318
1308
case "red" :
@@ -1328,14 +1318,7 @@ const getWidgetsFontColor = (type) => {
1328
1318
}
1329
1319
} ;
1330
1320
//function for embed multiple signature using pdf-lib
1331
- export const multiSignEmbed = async (
1332
- widgets ,
1333
- pdfDoc ,
1334
- signyourself ,
1335
- scale ,
1336
- pdfOriginalWH ,
1337
- containerWH
1338
- ) => {
1321
+ export const multiSignEmbed = async ( widgets , pdfDoc , signyourself , scale ) => {
1339
1322
// `fontBytes` is used to embed custom font in pdf
1340
1323
const fontBytes = await fileasbytes (
1341
1324
"https://cdn.opensignlabs.com/webfonts/times.ttf"
@@ -1345,11 +1328,6 @@ export const multiSignEmbed = async (
1345
1328
let hasError = false ;
1346
1329
for ( let item of widgets ) {
1347
1330
if ( hasError ) break ; // Stop the outer loop if an error occurred
1348
- const containerScale = getContainerScale (
1349
- pdfOriginalWH ,
1350
- item ?. pageNumber ,
1351
- containerWH
1352
- ) ;
1353
1331
const typeExist = item . pos . some ( ( data ) => data ?. type ) ;
1354
1332
let updateItem ;
1355
1333
@@ -1436,7 +1414,17 @@ export const multiSignEmbed = async (
1436
1414
return y ;
1437
1415
}
1438
1416
} else {
1439
- return resizePos ;
1417
+ const WidgetsTypeTextExist = [
1418
+ textWidget ,
1419
+ textInputWidget ,
1420
+ "name" ,
1421
+ "company" ,
1422
+ "job title" ,
1423
+ "date" ,
1424
+ "email"
1425
+ ] . includes ( position . type ) ;
1426
+ const yPosition = WidgetsTypeTextExist ? resizePos + 6 : resizePos ;
1427
+ return yPosition ;
1440
1428
}
1441
1429
} ;
1442
1430
const color = position ?. options ?. fontColor ;
@@ -1512,11 +1500,7 @@ export const multiSignEmbed = async (
1512
1500
} ) ;
1513
1501
}
1514
1502
} else if ( widgetTypeExist ) {
1515
- const fontSize = calculateFontSize (
1516
- position ,
1517
- containerScale ,
1518
- signyourself
1519
- ) ;
1503
+ const fontSize = position ?. options ?. fontSize || 12 ;
1520
1504
parseInt ( fontSize ) ;
1521
1505
let textContent ;
1522
1506
if ( position ?. options ?. response ) {
@@ -1549,7 +1533,6 @@ export const multiSignEmbed = async (
1549
1533
lines . push ( currentLine . trim ( ) ) ;
1550
1534
return lines ;
1551
1535
} ;
1552
-
1553
1536
// Function to break text into lines based on when user go next line on press enter button
1554
1537
const breakTextIntoLines = ( textContent , width ) => {
1555
1538
const lines = [ ] ;
@@ -1570,7 +1553,6 @@ export const multiSignEmbed = async (
1570
1553
1571
1554
return lines ;
1572
1555
} ;
1573
-
1574
1556
//check if text content have `\n` string it means user press enter to go next line and handle condition
1575
1557
//else auto adjust text content according to container width
1576
1558
const lines = isNewOnEnterLineExist
@@ -1597,7 +1579,6 @@ export const multiSignEmbed = async (
1597
1579
}
1598
1580
} else if ( position . type === "dropdown" ) {
1599
1581
const fontsize = parseInt ( position ?. options ?. fontSize ) || 12 ;
1600
-
1601
1582
const dropdownRandomId = "dropdown" + randomId ( ) ;
1602
1583
const dropdown = form . createDropdown ( dropdownRandomId ) ;
1603
1584
dropdown . addOptions ( position ?. options ?. values ) ;
@@ -1696,7 +1677,6 @@ export const multiSignEmbed = async (
1696
1677
}
1697
1678
if ( ! hasError ) {
1698
1679
const pdfBytes = await pdfDoc . saveAsBase64 ( { useObjectStreams : false } ) ;
1699
- // console.log("pdf", pdfBytes);
1700
1680
return pdfBytes ;
1701
1681
} else {
1702
1682
return {
0 commit comments