I've made a script, activated by pushing a button, to export or copy field values from one pdf to another. Everything works fine with Acrobat Pro, but it doesn't work with Acrobat Reader DC. I'v read in other posts, that it should be possible and I really can't see anything logical, that it shouldn't be possible: I know, it's called "Reader". But this reader can change field values, properties and so on in one file. And finally, the READER can SAVE CHANGES. So why shouldn't it could change values in other pdf files !? I think, I simply made a fault in my script, so I need some help, please ! Or is it really impossible !? The relevant part of my script only needs two lines, I thought. It is like this:
newDoc = app.openDoc("target.pdf");
newDoc.getField("name").value = this.getField("source_field").value;
Of course, the target pdf has the action
this.disclosed = true;
in document java Scripts. As I told: it works with Acrobat Pro.
When opening other files it's never a good idea to use the "this" keyword, as it's hard to predict what it will point to.
So change your code to:
var oldDoc = this;
var newDoc = app.openDoc("target.pdf");
newDoc.getField("name").value = oldDoc.getField("source_field").value;
If that still doesn't work please specify exactly what happens. Are there error messages in the JS Console?
Also, what version of Reader are you using?
There's no JS Console in the Reader, isn't it ? I tested with my Acrobat Pro without any error. But at work, I only have the Reader. And with this Reader nothing happens. I'm using Acrobat Reader DC, Version 2018.011.20038
I've change to try67's code.
There's no JS Console in the Reader, isn't it ?
There is one, but it's hidden.
- Install this free tool to add a button that show the Console in Reader: https://abracadabrapdf.net/download/JSDebugger_button.js.zip
(Sorry Thom, I cannot find the original link…)
ok, thanks for this information !
obviously there are some properties that have to be changed. the console sends an error. It is in german, I try to translate correctly to english: "NotAllowedError: Safety properties prevent the access to this feature or method".
Does anybody know, what kind of feature or method this could be and what do I have to change ?
Can you post the full code?