@@ -76,7 +76,7 @@ function SignYourSelf() {
76
76
const [ signKey , setSignKey ] = useState ( ) ;
77
77
const [ imgWH , setImgWH ] = useState ( { } ) ;
78
78
const [ pdfNewWidth , setPdfNewWidth ] = useState ( ) ;
79
- const [ pdfOriginalWH , setPdfOriginalWH ] = useState ( ) ;
79
+ const [ pdfOriginalWH , setPdfOriginalWH ] = useState ( [ ] ) ;
80
80
const [ successEmail , setSuccessEmail ] = useState ( false ) ;
81
81
const imageRef = useRef ( null ) ;
82
82
const [ myInitial , setMyInitial ] = useState ( "" ) ;
@@ -458,7 +458,10 @@ function SignYourSelf() {
458
458
const widgetTypeExist = [ "name" , "company" , "job title" , "email" ] . includes (
459
459
dragTypeValue
460
460
) ;
461
- const containerScale = containerWH ?. width / pdfOriginalWH ?. width || 1 ;
461
+ const getPdfPageWidth = pdfOriginalWH . find (
462
+ ( data ) => data . pageNumber === pageNumber
463
+ ) ;
464
+ const containerScale = containerWH ?. width / getPdfPageWidth ?. width || 1 ;
462
465
//adding and updating drop position in array when user drop signature button in div
463
466
if ( item === "onclick" ) {
464
467
const getWidth = widgetTypeExist
@@ -695,7 +698,6 @@ function SignYourSelf() {
695
698
const pdfBytes = await multiSignEmbed (
696
699
xyPostion ,
697
700
pdfDoc ,
698
- pdfOriginalWH ,
699
701
isSignYourSelfFlow ,
700
702
scale
701
703
) ;
@@ -809,13 +811,14 @@ function SignYourSelf() {
809
811
setDragKey ( key ) ;
810
812
setIsDragging ( true ) ;
811
813
} ;
812
-
813
- // console.log("xy", pdfOriginalWH);
814
814
//function for set and update x and y postion after drag and drop signature tab
815
815
const handleStop = ( event , dragElement ) => {
816
816
if ( isDragging && dragElement ) {
817
817
event . preventDefault ( ) ;
818
- const containerScale = containerWH . width / pdfOriginalWH . width ;
818
+ const getPdfPageWidth = pdfOriginalWH . find (
819
+ ( data ) => data . pageNumber === pageNumber
820
+ ) ;
821
+ const containerScale = containerWH . width / getPdfPageWidth ?. width || 1 ;
819
822
if ( dragKey >= 0 ) {
820
823
const filterDropPos = xyPostion . filter (
821
824
( data ) => data . pageNumber === pageNumber
@@ -848,13 +851,16 @@ function SignYourSelf() {
848
851
setIsDragging ( false ) ;
849
852
} , 200 ) ;
850
853
} ;
851
-
852
854
//function for get pdf page details
853
855
const pageDetails = async ( pdf ) => {
854
- const firstPage = await pdf . getPage ( 1 ) ;
855
- const scale = 1 ;
856
- const { width, height } = firstPage . getViewport ( { scale } ) ;
857
- setPdfOriginalWH ( { width : width , height : height } ) ;
856
+ let pdfWHObj = [ ] ;
857
+ for ( let index = 0 ; index < allPages ; index ++ ) {
858
+ const firstPage = await pdf . getPage ( index + 1 ) ;
859
+ const scale = 1 ;
860
+ const { width, height } = firstPage . getViewport ( { scale } ) ;
861
+ pdfWHObj . push ( { pageNumber : index + 1 , width, height } ) ;
862
+ }
863
+ setPdfOriginalWH ( pdfWHObj ) ;
858
864
setPdfLoadFail ( {
859
865
status : true
860
866
} ) ;
@@ -1166,7 +1172,7 @@ function SignYourSelf() {
1166
1172
{ isUiLoading && (
1167
1173
< div className = "absolute h-[100vh] w-full z-[999] flex flex-col justify-center items-center bg-[#e6f2f2] bg-opacity-80" >
1168
1174
< Loader />
1169
- < span className = "text-[ 13px] text-base-content" >
1175
+ < span style = { { fontSize : " 13px" , fontWeight : "bold" } } >
1170
1176
This might take some time
1171
1177
</ span >
1172
1178
</ div >
@@ -1218,7 +1224,6 @@ function SignYourSelf() {
1218
1224
< PdfZoom
1219
1225
setScale = { setScale }
1220
1226
scale = { scale }
1221
- pdfOriginalWH = { pdfOriginalWH }
1222
1227
containerWH = { containerWH }
1223
1228
setZoomPercent = { setZoomPercent }
1224
1229
zoomPercent = { zoomPercent }
0 commit comments