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

Test files only generating Temp_Data.fdf's, no test_complete.pdf #51

Closed maximilianschmidt closed 7 years ago

maximilianschmidt commented 7 years ago

hi there,

i was just fiddling around with this module and was trying to get the test.pdf from /test/ filled out by running the first sample code from the readme. all im getting as a result is a random-named *.fdf file (eg. temp_data1487871079565h1snj9fzwkpgfgdcgnwmi.fdf).

when i try to run the script with my own pdf and pass custom data a test_complete.pdf is created but its size is 0kb. no error messages whatsoever and no success callback either.

heres my index.js

var pdfFiller   = require('pdffiller');

var sourcePDF = "test.pdf";
var destinationPDF =  "test_complete.pdf";
var data = {
    "last_name" : "John",
    "first_name" : "Doe",
    "date" : "Jan 1, 2013",
    "football" : "Off",
    "baseball" : "Yes",
    "basketball" : "Off",
    "hockey" : "Yes",
    "nascar" : "Off"
};

pdfFiller.fillForm( sourcePDF, destinationPDF, data, function(err) {
    if (err) throw err;
    console.log("In callback (we're done).");
});

and my package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pdffiller": "0.0.10",
    "pdftk": "0.0.0-rc.0"
  }
}

am i missing something here? im pretty new to node, so please bear with me if i missed something obvious. still learning :)

cheers!

/edit

i suspect it has something to do with line 120 in the pdffillers index.js

execFile( "pdftk", args, function (error, stdout, stderr) {

    if ( error ) {
        console.log('exec error: ' + error);
        return callback(error);
    }
    //Delete the temporary fdf file.
    fs.unlink( tempFDF, function( err ) {

        if ( err ) {
            return callback(err);
        }
        // console.log( 'Sucessfully deleted temp file ' + tempFDF );
        return callback();
    });
} );

edit: boiled it down to the pdftk command not working for me. if i manually type pdftk test.pdf fill_form temp.fdf output complete.pdf in the terminal the same thing happens, just an 0kb complete.pdf is generated and the terminal seems to be doing nothing until i ctrl+c.

maximilianschmidt commented 7 years ago

ok, nevermind. apparently its a bug with pdftk and mac os x sierra

florianbepunkt commented 7 years ago

@maximilianschmidt just encountered the same problem, although not on osx sierra. have you found a solution to this?

maximilianschmidt commented 7 years ago

yes, please see this link: http://stackoverflow.com/questions/39750883/pdftk-hanging-on-macos-sierra

seems to be a special version of pdftk fixing this problem.