mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 03:01:59 +10:00
🚧 place signatures and text signatures
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
export { coloredConsole } from "./coloredConsole";
|
||||
export { default as classNames } from "./classNames";
|
||||
export { NEXT_PUBLIC_WEBAPP_URL } from "./constants";
|
||||
export { localStorage } from "./webstorage";
|
||||
|
||||
24
packages/lib/webstorage.ts
Normal file
24
packages/lib/webstorage.ts
Normal file
@ -0,0 +1,24 @@
|
||||
// TODO: In case of an embed if localStorage is not available(third party), use localStorage of parent(first party) that contains the iframe.
|
||||
export const localStorage = {
|
||||
getItem(key: string) {
|
||||
try {
|
||||
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
||||
return window.localStorage.getItem(key);
|
||||
} catch (e) {
|
||||
// In case storage is restricted. Possible reasons
|
||||
// 1. Third Party Context in Chrome Incognito mode.
|
||||
return null;
|
||||
}
|
||||
},
|
||||
setItem(key: string, value: string) {
|
||||
try {
|
||||
// eslint-disable-next-line @calcom/eslint/avoid-web-storage
|
||||
window.localStorage.setItem(key, value);
|
||||
} catch (e) {
|
||||
// In case storage is restricted. Possible reasons
|
||||
// 1. Third Party Context in Chrome Incognito mode.
|
||||
// 2. Storage limit reached
|
||||
return;
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -1,4 +1,4 @@
|
||||
import { degrees, PDFDocument, PDFImage, rgb, StandardFonts } from "pdf-lib";
|
||||
import { PDFDocument } from "pdf-lib";
|
||||
|
||||
export async function insertImageInPDF(
|
||||
pdfAsBase64: string,
|
||||
@ -12,12 +12,13 @@ export async function insertImageInPDF(
|
||||
const pages = pdfDoc.getPages();
|
||||
const pdfPage = pages[page];
|
||||
const pngImage = await pdfDoc.embedPng(image);
|
||||
const drawSize = { width: 213, height: 50 };
|
||||
|
||||
pdfPage.drawImage(pngImage, {
|
||||
x: positionX,
|
||||
y: positionY,
|
||||
width: pngImage.width,
|
||||
height: pngImage.height,
|
||||
x: pdfPage.getWidth() - positionX - drawSize.width,
|
||||
y: pdfPage.getHeight() - positionY - drawSize.height,
|
||||
width: drawSize.width,
|
||||
height: drawSize.height,
|
||||
});
|
||||
|
||||
const pdfAsUint8Array = await pdfDoc.save();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { degrees, PDFDocument, rgb, StandardFonts } from "pdf-lib";
|
||||
import { PDFDocument, rgb, StandardFonts } from "pdf-lib";
|
||||
|
||||
export async function insertTextInPDF(
|
||||
pdfAsBase64: string,
|
||||
@ -13,10 +13,12 @@ export async function insertTextInPDF(
|
||||
const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica);
|
||||
|
||||
const pages = pdfDoc.getPages();
|
||||
const firstPage = pages[page];
|
||||
firstPage.drawText(text, {
|
||||
x: positionX,
|
||||
y: positionY,
|
||||
const pdfPage = pages[page];
|
||||
const lineHeightEsimate = 25;
|
||||
|
||||
pdfPage.drawText(text, {
|
||||
x: pdfPage.getWidth() - positionX,
|
||||
y: pdfPage.getHeight() - positionY - lineHeightEsimate,
|
||||
size: 25,
|
||||
font: helveticaFont,
|
||||
color: rgb(0, 0, 0),
|
||||
|
||||
Reference in New Issue
Block a user