Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding text, images, and signatures to a PDF doesn't work #55

Open
armaanrustami opened this issue Mar 7, 2024 · 1 comment
Open

Adding text, images, and signatures to a PDF doesn't work #55

armaanrustami opened this issue Mar 7, 2024 · 1 comment

Comments

@armaanrustami
Copy link

I tried to use the PDF Editor but it seems that Adding text, images, and signatures to a PDF doesn't work

@armaanrustami
Copy link
Author

Solved the issue with following changes in Shape.js :

`
function SavePdf() {
$('#loadingModal').modal('show');
let filename = 'image'.concat(currentPage).concat('.png');

shapes2 = [];

for (var i = 0; i < shapes.length; i++) {
    tempShape = {
        x: shapes[i].x,
        y: shapes[i].y,
        textWidth: shapes[i].textWidth,
        fontHeight: shapes[i].fontHeight,
        page: shapes[i].page,
        f: shapes[i].f,
        text: shapes[i].text,
        fontText: shapes[i].fontText,
        fontSize: shapes[i].fontSize,
        fontColor: shapes[i].fontColor,
        fontWeight: shapes[i].fontWeight,
        fontStyle: shapes[i].fontStyle,
        ratio: shapes[i].ratio,
        imfile: '',
        imName: shapes[i].imName,
        Itype: shapes[i].Itype,
        fieldType: shapes[i].fieldType
    };
    shapes2.push(tempShape);
}
wholedata = JSON.stringify(
    { 
        'shapes': shapes2, 
        'filename': filename, 
        'aspectRatio': ratio, 
        'documentId': documentId 
    });
const jsonObj = JSON.parse(wholedata);

jsonObj.shapes = jsonObj.shapes.map(shape => {
    for (const key in shape) {
        if (typeof shape[key] === 'number') {
            shape[key] = shape[key].toString();
        }
    }
    return shape;
});

const modifiedWholedata = JSON.stringify(jsonObj);


$.ajax({
    type: 'POST',
    url: `${apiBaseUrl}shape/add`,
    data: modifiedWholedata,
    contentType: 'application/json; charset=utf-8',
    dataType: 'json',
    success: function () {
        $("#savingModal").fadeTo(2000, 500).slideUp(500, function () {
            $("#savingModal").slideUp(500);
        });
    },
    error: function (xhr, textStatus, error) {
        alertModal('Error: ', xhr, textStatus, error);
    }
})
.done(function () { $('#loadingModal').modal('hide'); });

}
function convertIntToStr(obj) {
if (typeof obj === 'number') {
return obj.toString();
} else if (typeof obj === 'object') {
for (const key in obj) {
obj[key] = convertIntToStr(obj[key]);
}
}
return obj;
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant