Skip to content

Commit a18aee0

Browse files
fix: landscape mode pdf after embed widget's position
1 parent 89f67bf commit a18aee0

File tree

9 files changed

+178
-300
lines changed

9 files changed

+178
-300
lines changed

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

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -565,26 +565,23 @@ function Placeholder(props) {
565565
const xPos = (pos, signYourself) => {
566566
const containerScale = props.containerWH.width / props.pdfOriginalWH.width;
567567
const resizePos = pos.xPosition;
568-
console.log("go here", resizePos, containerScale, props.scale);
569568
if (signYourself) {
570569
return resizePos * containerScale * props.scale;
571570
} else {
572571
//checking both condition mobile and desktop view
573-
// if (pos.isMobile && pos.scale) {
574-
// if (props.scale > 1) {
575-
// return resizePos * pos.scale * containerScale * props.scale;
576-
// } else {
577-
// return resizePos * pos.scale * containerScale;
578-
// }
579-
// } else {
580-
// if (pos.scale === containerScale) {
581-
// return resizePos * pos.scale * props.scale;
582-
// } else {
583-
// return resizePos * pos.scale * containerScale * props.scale;
584-
// }
585-
// }
586-
console.log("go here", resizePos, containerScale, props.scale);
587-
return resizePos * containerScale * props.scale;
572+
if (pos.isMobile && pos.scale) {
573+
if (props.scale > 1) {
574+
return resizePos * pos.scale * containerScale * props.scale;
575+
} else {
576+
return resizePos * pos.scale * containerScale;
577+
}
578+
} else {
579+
// if (pos.scale === containerScale) {
580+
// return resizePos * pos.scale * props.scale;
581+
// } else {
582+
return resizePos * containerScale * props.scale;
583+
// }
584+
}
588585
}
589586
};
590587
const yPos = (pos, signYourself) => {
@@ -594,23 +591,24 @@ function Placeholder(props) {
594591
if (signYourself) {
595592
return resizePos * containerScale * props.scale;
596593
} else {
597-
// checking both condition mobile and desktop view
598-
// if (pos.isMobile && pos.scale) {
599-
// if (props.scale > 1) {
600-
// return resizePos * pos.scale * containerScale * props.scale;
601-
// } else {
602-
// return resizePos * pos.scale * containerScale;
603-
// }
604-
// } else if (pos.scale === containerScale) {
594+
//checking both condition mobile and desktop view
595+
if (pos.isMobile && pos.scale) {
596+
if (props.scale > 1) {
597+
return resizePos * pos.scale * containerScale * props.scale;
598+
} else {
599+
return resizePos * pos.scale * containerScale;
600+
}
601+
}
602+
// else if (pos.scale === containerScale) {
605603
// if (props.scale > 1) {
606604
// return resizePos * pos.scale * props.scale;
607605
// } else {
608606
// return resizePos * pos.scale;
609607
// }
610-
// } else {
611-
// return resizePos * containerScale;
612608
// }
613-
return resizePos * containerScale * props.scale;
609+
else {
610+
return resizePos * containerScale * props.scale;
611+
}
614612
}
615613
};
616614

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,9 @@ function PlaceholderType(props) {
704704
return (
705705
<div key={ind} className="flex items-center text-center gap-0.5">
706706
<input
707-
className={`${ind === 0 ? "mt-0" : "mt-[5px]"} ${
708-
props?.pos?.Width
709-
? `w-[${props?.pos?.Width}px] h-[${props?.pos?.Width}px]`
710-
: "w-[15px] h-[15px]"
711-
} flex justify-center op-radio`}
707+
className={`${
708+
ind === 0 ? "mt-0" : "mt-[5px]"
709+
} ${"w-[15px] h-[15px]"} flex justify-center op-radio`}
712710
type="radio"
713711
disabled={
714712
props.isNeedSign &&

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

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function RenderPdf({
2424
pdfDetails,
2525
xyPostion,
2626
pdfUrl,
27-
numPages,
2827
pageDetails,
2928
pdfRequest,
3029
signerObjectId,
@@ -398,22 +397,20 @@ function RenderPdf({
398397
: pdfDetails[0].URL
399398
}
400399
>
401-
{Array.from(new Array(numPages), (el, index) => (
402-
<Page
403-
onLoadSuccess={({ height }) => {
404-
setPdfRenderHeight && setPdfRenderHeight(height);
405-
setIsLoadPdf(true);
406-
}}
407-
key={index}
408-
pageNumber={pageNumber}
409-
width={containerWH.width}
410-
renderAnnotationLayer={false}
411-
renderTextLayer={false}
412-
onGetAnnotationsError={(error) => {
413-
console.log("annotation error", error);
414-
}}
415-
/>
416-
))}
400+
<Page
401+
onLoadSuccess={({ height }) => {
402+
setPdfRenderHeight && setPdfRenderHeight(height);
403+
setIsLoadPdf(true);
404+
}}
405+
key={index}
406+
pageNumber={pageNumber}
407+
width={containerWH.width}
408+
renderAnnotationLayer={false}
409+
renderTextLayer={false}
410+
onGetAnnotationsError={(error) => {
411+
console.log("annotation error", error);
412+
}}
413+
/>
417414
</Document>
418415
</div>
419416
</div>
@@ -592,24 +589,22 @@ function RenderPdf({
592589
: pdfDetails[0].URL
593590
}
594591
>
595-
{Array.from(new Array(numPages), (el, index) => (
596-
<Page
597-
onLoadSuccess={({ height }) => {
598-
setPdfRenderHeight && setPdfRenderHeight(height);
599-
setIsLoadPdf(true);
600-
}}
601-
key={index}
602-
width={containerWH.width}
603-
scale={scale || 1}
604-
className={"-z-[1]"} // when user zoom-in in tablet widgets move backward that's why pass -z-[1]
605-
pageNumber={pageNumber}
606-
renderAnnotationLayer={false}
607-
renderTextLayer={false}
608-
onGetAnnotationsError={(error) => {
609-
console.log("annotation error", error);
610-
}}
611-
/>
612-
))}
592+
<Page
593+
onLoadSuccess={({ height }) => {
594+
setPdfRenderHeight && setPdfRenderHeight(height);
595+
setIsLoadPdf(true);
596+
}}
597+
key={index}
598+
width={containerWH.width}
599+
scale={scale || 1}
600+
className={"-z-[1]"} // when user zoom-in in tablet widgets move backward that's why pass -z-[1]
601+
pageNumber={pageNumber}
602+
renderAnnotationLayer={false}
603+
renderTextLayer={false}
604+
onGetAnnotationsError={(error) => {
605+
console.log("annotation error", error);
606+
}}
607+
/>
613608
</Document>
614609
</div>
615610
</RSC>

0 commit comments

Comments
 (0)