Merge pull request #22 from ElTimuro/doc-132-doc-133-placement-fixes

Doc-132-doc-133-placement-fixes
This commit is contained in:
Timur Ercan
2023-03-07 17:37:32 +01:00
committed by GitHub
9 changed files with 25 additions and 31 deletions

View File

@ -53,18 +53,15 @@ export default function EditableField(props: FieldPropsType) {
e.stopPropagation(); e.stopPropagation();
}} }}
> >
{/* width: 192 height 96 */}
<div <div
hidden={props.hidden} hidden={props.hidden}
ref={nodeRef} ref={nodeRef}
className="cursor-move opacity-80 p-2 m-auto w-48 h-24 flex-row-reverse text-lg font-bold text-center absolute top-0 left-0 select-none" className="cursor-move opacity-80 p-2 m-auto w-48 h-16 flex-row-reverse text-lg font-bold text-center absolute top-0 left-0 select-none"
style={{ style={{
background: stc(props.field.Recipient.email), background: stc(props.field.Recipient.email),
}} }}
> >
<div className="mb-2 pointer-events-none">
<Logo className="w-16 mx-auto"></Logo>
</div>
{/* width: 192 height 96 */}
<div className="m-auto overflow-hidden flex-row-reverse text-lg font-bold text-center"> <div className="m-auto overflow-hidden flex-row-reverse text-lg font-bold text-center">
{field.type} {field.type}
{field.type === "SIGNATURE" ? ( {field.type === "SIGNATURE" ? (

View File

@ -48,6 +48,9 @@ export default function PDFEditor(props: any) {
<> <>
<div> <div>
<PDFViewer <PDFViewer
style={{
cursor: `url("https://place-hold.it/110x64/37f095/FFFFFF&text=${selectedFieldType}") 55 32, auto`,
}}
readonly={false} readonly={false}
document={props.document} document={props.document}
fields={fields} fields={fields}

View File

@ -45,6 +45,8 @@ export default function PDFSigner(props: any) {
return; return;
} }
if (!dialogResult) return;
const signature = { const signature = {
fieldId: dialogField.id, fieldId: dialogField.id,
type: dialogResult.type, type: dialogResult.type,

View File

@ -60,8 +60,7 @@ export default function PDFViewer(props) {
key={short.generate().toString()} key={short.generate().toString()}
style={{ style={{
position: "relative", position: "relative",
cursor: ...props.style,
'url("https://place-hold.it/110x64/37f095/FFFFFF&text=Signature"), auto',
}} }}
className="mx-auto w-fit" className="mx-auto w-fit"
> >

View File

@ -43,26 +43,26 @@ export default function SignableField(props: FieldPropsType) {
if (!field?.signature) props.onClick(props.field); if (!field?.signature) props.onClick(props.field);
}} }}
ref={nodeRef} ref={nodeRef}
className="cursor-pointer opacity-80 p-2 m-auto w-auto flex-row-reverse text-lg font-bold text-center absolute top-0 left-0 select-none hover:brightness-50" className="cursor-pointer opacity-80 m-auto w-48 h-16 flex-row-reverse text-lg font-bold text-center absolute top-0 left-0 select-none hover:brightness-50"
style={{ style={{
background: stc(props.field.Recipient.email), background: stc(props.field.Recipient.email),
}} }}
> >
<div <div hidden={field?.signature} className="font-medium my-4">
hidden={field?.signature}
className="m-auto w-auto flex-row-reverse font-medium text-center px-12 py-2"
>
{field.type === "SIGNATURE" ? "SIGN HERE" : ""} {field.type === "SIGNATURE" ? "SIGN HERE" : ""}
</div> </div>
<div <div
hidden={!field?.signature} hidden={!field?.signature}
className="font-qwigley text-5xl m-auto w-auto flex-row-reverse font-medium text-center" className="font-qwigley text-5xl m-auto w-auto flex-row-reverse font-medium text-center"
> >
{field?.signature?.type === "type" {field?.signature?.type === "type" ? (
? field?.signature.typedSignature <div className="my-4">{field?.signature.typedSignature}</div>
: ""} ) : (
""
)}
{field?.signature?.type === "draw" ? ( {field?.signature?.type === "draw" ? (
<img className="w-50 h-20" src={field?.signature?.signatureImage} /> <img className="w-48 h-16" src={field?.signature?.signatureImage} />
) : ( ) : (
"" ""
)} )}

View File

@ -117,7 +117,6 @@ const RecipientsPage: NextPageWithLayout = (props: any) => {
color="primary" color="primary"
icon={PaperAirplaneIcon} icon={PaperAirplaneIcon}
onClick={() => { onClick={() => {
setLoading(true);
setOpen(true); setOpen(true);
}} }}
disabled={ disabled={
@ -361,12 +360,7 @@ const RecipientsPage: NextPageWithLayout = (props: any) => {
</div> </div>
</div> </div>
<Transition.Root show={open} as={Fragment}> <Transition.Root show={open} as={Fragment}>
<Dialog <Dialog as="div" className="relative z-10" onClose={setOpen}>
as="div"
className="relative z-10"
initialFocus={cancelButtonRef}
onClose={setOpen}
>
<Transition.Child <Transition.Child
as={Fragment} as={Fragment}
enter="ease-out duration-300" enter="ease-out duration-300"
@ -417,16 +411,13 @@ const RecipientsPage: NextPageWithLayout = (props: any) => {
</div> </div>
</div> </div>
<div className="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3"> <div className="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3">
<Button <Button color="secondary" onClick={() => setOpen(false)}>
color="secondary"
onClick={() => setOpen(false)}
ref={cancelButtonRef}
>
Cancel Cancel
</Button> </Button>
<Button <Button
onClick={() => { onClick={() => {
setOpen(false); setOpen(false);
setLoading(true);
sendSigningRequests(props.document).finally(() => { sendSigningRequests(props.document).finally(() => {
setLoading(false); setLoading(false);
}); });

View File

@ -8,7 +8,7 @@ export const createField = (
customText = "" customText = ""
): any => { ): any => {
var rect = e.target.getBoundingClientRect(); var rect = e.target.getBoundingClientRect();
const fieldSize = { width: 192, height: 96 }; const fieldSize = { width: 192, height: 64 };
var newFieldX = e.clientX - rect.left - fieldSize.width / 2; //x position within the element. var newFieldX = e.clientX - rect.left - fieldSize.width / 2; //x position within the element.
var newFieldY = e.clientY - rect.top - fieldSize.height / 2; //y position within the element. var newFieldY = e.clientY - rect.top - fieldSize.height / 2; //y position within the element.
if (newFieldX < 0) newFieldX = 0; if (newFieldX < 0) newFieldX = 0;

View File

@ -12,7 +12,7 @@ export async function insertImageInPDF(
const pages = pdfDoc.getPages(); const pages = pdfDoc.getPages();
const pdfPage = pages[page]; const pdfPage = pages[page];
const pngImage = await pdfDoc.embedPng(image); const pngImage = await pdfDoc.embedPng(image);
const drawSize = { width: 213, height: 50 }; const drawSize = { width: 192, height: 64 };
pdfPage.drawImage(pngImage, { pdfPage.drawImage(pngImage, {
x: positionX, x: positionX,

View File

@ -24,10 +24,12 @@ export async function insertTextInPDF(
const textSize = useHandwritingFont ? 50 : 15; const textSize = useHandwritingFont ? 50 : 15;
const textWidth = customFont.widthOfTextAtSize(text, textSize); const textWidth = customFont.widthOfTextAtSize(text, textSize);
const textHeight = customFont.heightAtSize(textSize); const textHeight = customFont.heightAtSize(textSize);
const fieldSize = { width: 192, height: 64 };
const invertedYPosition = pdfPage.getHeight() - positionY - fieldSize.height;
pdfPage.drawText(text, { pdfPage.drawText(text, {
x: positionX, x: positionX,
y: pdfPage.getHeight() - positionY - textHeight / 2, y: invertedYPosition,
size: textSize, size: textSize,
font: useHandwritingFont ? customFont : helveticaFont, font: useHandwritingFont ? customFont : helveticaFont,
color: rgb(0, 0, 0), color: rgb(0, 0, 0),