pdffillerjs / pdffiller

Take an existing PDF Form and data and PDF Filler will create a new PDF with all given fields populated.
MIT License
286 stars 113 forks source link

mapForm2PDF does not work #46

Closed hmtri1011 closed 7 years ago

hmtri1011 commented 7 years ago

My code :

const mapTest = {
    "name": "First Name"
}

const userObject = {
    "name": "MTae"
};

pdfFiller.mapForm2PDF(userObject, mapTest, function (err, mappedFields) {
    if (err) throw err;
    console.log('abc');
    console.log(mappedFields);
});

And the output is nothing!

johntayl commented 7 years ago

I'll update the README with proper documentation. mapForm2PDF has been changed and no longer requires a callback.

This should be the format:

const mapTest = {
    "name": "First Name"
}

const userObject = [
    {
        "title" : "name",
        "fieldfieldType": "Text",
        "fieldValue": "MTae"
    }
];

const mappedFields = pdfFiller.mapForm2PDF(userObject, mapTest);

Which will result in:

{
    "First Name": "MTae"
}
hmtri1011 commented 7 years ago

Hello johntayl. At FillForm method, can I have a stream of filled pdf file?

I means in this method :

 pdfFiller.fillForm('http://res.cloudinary.com/xxx/form.pdf',destPDF, data, (err) => {
                        if (err) throw err;
                        console.log("In callback (we're done).");
                    });

Can i handle the filled pdf form