corymickelson / NoPoDoFo

node pdf native bindings
GNU Affero General Public License v3.0
26 stars 6 forks source link

Why am I not able to write new text to the file? #108

Open techsin opened 4 years ago

techsin commented 4 years ago

I load the file, change the text, and save the file. I check text was updated and it has but when it's saved, it's same as before?? Assume it's in a function and imports have been done

const file = './file.pdf';
const doc = new nopodofo.Document();
await new Promise((resolve, reject) => doc.load(file, e => e ? reject(e) : resolve()));
let page = doc.getPage(0);
let field = page.getField(0);
let text = page.getFields().filter(x => x.text[0] === '$')[0];
text.text = 'myemail@gmail.com';
console.log(doc.getPage(0).getFields().map(x => x.text)); //Yes it did change
doc.write('./test.pdf', function(a, b){})