Skip to content

Commit ab3dde1

Browse files
remove times.ttf file to cdn file
1 parent d798e02 commit ab3dde1

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed
-340 KB
Binary file not shown.

apps/OpenSign/src/constant/Utils.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,9 @@ export const addInitialData = (signerPos, setXyPostion, value, userId) => {
10331033
//function for embed document id
10341034
export const embedDocId = async (pdfDoc, documentId, allPages) => {
10351035
// `fontBytes` is used to embed custom font in pdf
1036-
const fontBytes = await fileasbytes("/font/times.ttf");
1036+
const fontBytes = await fileasbytes(
1037+
"https://cdn.opensignlabs.com/webfonts/times.ttf"
1038+
);
10371039
pdfDoc.registerFontkit(fontkit);
10381040
const font = await pdfDoc.embedFont(fontBytes, { subset: true });
10391041
for (let i = 0; i < allPages; i++) {
@@ -1212,8 +1214,8 @@ export const fetchImageBase64 = async (imageUrl) => {
12121214
};
12131215
//function for select image and upload image
12141216
export const changeImageWH = async (base64Image) => {
1215-
const newWidth = 300;
1216-
const newHeight = 120;
1217+
const newWidth = 100;
1218+
const newHeight = 40;
12171219
return new Promise((resolve, reject) => {
12181220
const img = new Image();
12191221
img.src = base64Image;
@@ -1251,7 +1253,9 @@ export const multiSignEmbed = async (
12511253
containerWH
12521254
) => {
12531255
// `fontBytes` is used to embed custom font in pdf
1254-
const fontBytes = await fileasbytes("/font/times.ttf");
1256+
const fontBytes = await fileasbytes(
1257+
"https://cdn.opensignlabs.com/webfonts/times.ttf"
1258+
);
12551259
pdfDoc.registerFontkit(fontkit);
12561260
const font = await pdfDoc.embedFont(fontBytes, { subset: true });
12571261
for (let item of widgets) {
@@ -1404,7 +1408,7 @@ export const multiSignEmbed = async (
14041408
width: checkboxSize,
14051409
height: checkboxSize
14061410
};
1407-
checkboxObj = getWidgetPosition(page, checkboxObj, 1);
1411+
checkboxObj = getImagePosition(page, checkboxObj, 1);
14081412
checkbox.addToPage(page, checkboxObj);
14091413

14101414
//applied which checkbox should be checked
@@ -1529,10 +1533,10 @@ export const multiSignEmbed = async (
15291533
width: widgetWidth,
15301534
height: widgetHeight
15311535
};
1532-
dropdown.defaultUpdateAppearances(font);
1533-
const dropdownOption = getWidgetPosition(page, dropdownObj, 1);
1534-
const dropdownSelected = { ...dropdownOption, font: font };
1535-
dropdown.addToPage(page, dropdownSelected);
1536+
1537+
const dropdownOption = getImagePosition(page, dropdownObj, 1);
1538+
// page.drawImage(img, imageOptions);
1539+
dropdown.addToPage(page, dropdownOption);
15361540
dropdown.enableReadOnly();
15371541
} else if (position.type === radioButtonWidget) {
15381542
const radioRandomId = "radio" + randomId();
@@ -1573,7 +1577,7 @@ export const multiSignEmbed = async (
15731577
height: radioSize
15741578
};
15751579

1576-
radioObj = getWidgetPosition(page, radioObj, 1);
1580+
radioObj = getImagePosition(page, radioObj, 1);
15771581
radioGroup.addOptionToPage(item, page, radioObj);
15781582
});
15791583
}
@@ -1591,7 +1595,7 @@ export const multiSignEmbed = async (
15911595
height: widgetHeight
15921596
};
15931597

1594-
const imageOptions = getWidgetPosition(page, signature, 1);
1598+
const imageOptions = getImagePosition(page, signature, 1);
15951599
page.drawImage(img, imageOptions);
15961600
}
15971601
});
@@ -2194,8 +2198,8 @@ function compensateRotation(
21942198
}
21952199
}
21962200

2197-
// `getWidgetPosition` is used to calulcate position of image type widget like x, y, width, height for pdf-lib
2198-
function getWidgetPosition(page, image, sizeRatio) {
2201+
// `getImagePosition` is used to calulcate position of image type widget like x, y, width, height for pdf-lib
2202+
function getImagePosition(page, image, sizeRatio) {
21992203
let pageWidth;
22002204
// pageHeight;
22012205
if ([90, 270].includes(page.getRotation().angle)) {

0 commit comments

Comments
 (0)