Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,26 @@

fillForm: function( sourceFile, destinationFile, fieldValues, callback) {
this.fillFormWithFlatten( sourceFile, destinationFile, fieldValues, true, callback);
},

stampForm: function( sourceFile, stampFile, destinationFile, tempFDFPath, callback ) {
//Generate the data from the field values.
var args = [sourceFile, "stamp", stampFile, "output", destinationFile];

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

if ( error ) {
console.log('exec error: ' + error);
return callback(error);
}

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

stampPDF: function ( sourceFile, stampFile, destinationFile, callback) {
this.stampForm( sourceFile, stampFile, destinationFile, undefined,callback);
}

};
Expand Down
20 changes: 20 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ var dest2PDF = "test/test_complete2.pdf",
dest1PDF = "test/test_complete1.pdf",
source1PDF = "test/test1.pdf";

var pirfForm = "test/output.pdf",
stampForm = "test/download.pdf",
destStamp = "test/stamped.pdf";


/**
* Unit tests
Expand Down Expand Up @@ -320,4 +324,20 @@ describe('pdfFiller Tests', function(){
});
});

describe('stampForm()', function(){


it('should create a stamped pdf', function(done) {
this.timeout(15000);
pdfFiller.stampForm( pirfForm, stampForm, destStamp, undefined, function() {
done();

});
});


});



});
Binary file modified test/test_complete2.pdf
Binary file not shown.
Binary file modified test/test_complete3.pdf
Binary file not shown.