fix: widgets are not embeding in pdf using API

This commit is contained in:
prafull-opensignlabs
2024-03-19 13:11:23 +05:30
parent ea660384c3
commit de3bc37fa5
4 changed files with 12 additions and 17 deletions
@@ -165,29 +165,26 @@ export default async function createDocumentwithCoordinate(request, response) {
'Signers',
contact?.map(x => x.contactPtr)
);
let updatePlaceholders = contact.map((signer, index) => {
let updatePlaceholders = contact.map((signer) => {
const placeHolder = [];
for (const widget of signer.widgets) {
const pageNumber = widget.page;
const page = placeHolder.find(page => page.pageNumber === pageNumber);
const signOpt = { name: 'signature', status: required };
const widgetData = {
xPosition: widget.x,
yPosition: widget.y,
isStamp: widget.type === 'stamp',
key: randomId(),
isDrag: false,
firstXPos: widget.x,
firstYPos: widget.y,
yBottom: 0,
scale: 1,
isMobile: false,
zIndex: 1,
type: widget.type,
widgetValue: '',
options: widget.type === 'signature' ? signOpt : widget.options,
Width: widget.w,
Height: widget.h,
xPosition: widget.x,
yPosition: widget.y,
};
if (page) {
@@ -123,7 +123,7 @@ export default async function createTemplate(request, response) {
}
return response.json({
objectId: res.id,
url: baseUrl.origin + '/load/signmicroapp/template/' + res.id,
url: baseUrl.origin + '/template/' + res.id,
});
} else {
return response.status(405).json({ error: 'Invalid API Token!' });
@@ -129,23 +129,20 @@ export default async function createTemplatewithCoordinate(request, response) {
for (const widget of signer.widgets) {
const pageNumber = widget.page;
const page = placeHolder.find(page => page.pageNumber === pageNumber);
const signOpt = { name: 'signature', status: required };
const widgetData = {
xPosition: widget.x,
yPosition: widget.y,
isStamp: widget.type === 'stamp',
key: randomId(),
isDrag: false,
firstXPos: widget.x,
firstYPos: widget.y,
yBottom: 0,
scale: 1,
isMobile: false,
zIndex: 1,
type: widget.type,
widgetValue: '',
options: widget.type === 'signature' ? signOpt : widget.options,
Width: widget.w,
Height: widget.h,
xPosition: widget.x,
yPosition: widget.y,
};
if (page) {
@@ -14,6 +14,7 @@ export default async function draftDocument(request, response) {
const SendinOrder = request.body.sendInOrder || false;
// console.log('fileData ', fileData);
const protocol = customAPIurl();
const baseUrl = new URL(process.env.SERVER_URL);
try {
const reqToken = request.headers['x-api-token'];
@@ -135,7 +136,7 @@ export default async function draftDocument(request, response) {
}
return response.json({
objectId: res.id,
url: protocol + '/load/signmicroapp/placeholdersign/' + res.id,
url: `${baseUrl.origin}/placeholdersign/${res.id}`,
});
} else {
if (request.posthog) {