Skip to content

Commit

Permalink
Adding new method fillFormWithOptions to avoid modification of fillFo…
Browse files Browse the repository at this point in the history
…rmWithFlatten
  • Loading branch information
anperez78 committed Oct 7, 2016
1 parent 3f0388f commit 7e45c63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
});
},

fillFormWithFlatten: function( sourceFile, destinationFile, fieldValues, shouldFlatten, tempFDFPath, callback ) {
fillFormWithOptions: function( sourceFile, destinationFile, fieldValues, shouldFlatten, tempFDFPath, callback ) {

//Generate the data from the field values.
var tempFDFFile = "data" + (new Date().getTime()) + ".fdf",
Expand Down Expand Up @@ -134,8 +134,12 @@
} );
},

fillFormWithFlatten: function( sourceFile, destinationFile, fieldValues, shouldFlatten, callback ) {
this.fillFormWithOptions( sourceFile, destinationFile, fieldValues, shouldFlatten, undefined, callback);
},

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

};
Expand Down
6 changes: 3 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('pdfFiller Tests', function(){

it('should create an completely filled PDF that is read-only', function(done) {
this.timeout(15000);
pdfFiller.fillFormWithFlatten( source2PDF, dest2PDF, _data, true, undefined, function(err) {
pdfFiller.fillFormWithFlatten( source2PDF, dest2PDF, _data, true, function(err) {
pdfFiller.generateFieldJson(dest2PDF, null, function(err, fdfData) {
fdfData.length.should.equal(0);
done();
Expand All @@ -53,7 +53,7 @@ describe('pdfFiller Tests', function(){

it('should create an completely filled PDF that is read-only and with an specific temporary folder for FDF files', function(done) {
this.timeout(15000);
pdfFiller.fillFormWithFlatten( source2PDF, dest2PDF, _data, true, './', function(err) {
pdfFiller.fillFormWithOptions( source2PDF, dest2PDF, _data, true, './', function(err) {
pdfFiller.generateFieldJson(dest2PDF, null, function(err, fdfData) {
fdfData.length.should.equal(0);
done();
Expand All @@ -68,7 +68,7 @@ describe('pdfFiller Tests', function(){
var _data2 = {
"first_name": "Jerry",
};
pdfFiller.fillFormWithFlatten( source3PDF, dest3PDF, _data2, false, undefined, function(err) {
pdfFiller.fillFormWithFlatten( source3PDF, dest3PDF, _data2, false, function(err) {
pdfFiller.generateFieldJson(dest3PDF, null, function(err, fdfData) {
fdfData.length.should.not.equal(0);
done();
Expand Down

0 comments on commit 7e45c63

Please sign in to comment.