MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / embedDocId

Function embedDocId

apps/OpenSign/src/constant/Utils.js:1505–1537  ·  view source on GitHub ↗
(pdfOriginalWH, pdfDoc, documentId)

Source from the content-addressed store, hash-verified

1503
1504//function for embed document id
1505export const embedDocId = async (pdfOriginalWH, pdfDoc, documentId) => {
1506 const appName = "OpenSign™";
1507 // `fontBytes` is used to embed custom font in pdf
1508 const fontBytes = await fileasbytes(
1509 "https://cdn.opensignlabs.com/webfonts/times.ttf"
1510 );
1511 pdfDoc.registerFontkit(fontkit);
1512 const font = await pdfDoc.embedFont(fontBytes, { subset: true });
1513 //pdfOriginalWH contained all pdf's pages width and height
1514 for (let i = 0; i < pdfOriginalWH?.length; i++) {
1515 const fontSize = 10;
1516 const textContent = documentId && `${appName} DocumentId: ${documentId} `;
1517 const pages = pdfDoc.getPages();
1518 const page = pages[i];
1519 const getSize = pdfOriginalWH[i];
1520 try {
1521 const getObj = compensateRotation(
1522 page.getRotation().angle,
1523 10,
1524 5,
1525 1,
1526 getSize,
1527 fontSize,
1528 rgb(0.5, 0.5, 0.5),
1529 font,
1530 page
1531 );
1532 page.drawText(textContent, getObj);
1533 } catch (err) {
1534 console.log("Err in embed docId on page", i + 1, err?.message);
1535 }
1536 }
1537};
1538
1539// function for convert input text value in image
1540export function convertTextToImg(fontStyle, text, color, widgetDims) {

Callers 2

embedWidgetsDataFunction · 0.90
embedWidgetsDataFunction · 0.90

Calls 2

fileasbytesFunction · 0.85
compensateRotationFunction · 0.85

Tested by

no test coverage detected