Copy link to clipboard
Copied
Hi Guys,
I've created a pdf with the following javascript:
/* Remove all Buttons */
// iterate over all fields
for (i = 0; i < this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
this.removeField("Reset");
this.removeField("Save as");
this.removeField("Print");
this.flattenPages();
app.execMenuItem("SaveAs");
{
}
}
The script is working fine, the only problem is that other users cannot get this to work due to there Anti Virus software. It will delete the script as a safety precaution.
Is there another way to have the same result but without using the script?
Copy link to clipboard
Copied
No.
In any case the loop is useless, you should just use:
this.removeField("Reset");
this.removeField("Save as");
this.removeField("Print");
this.flattenPages();
app.execMenuItem("SaveAs");
Beware that flattenPages() will not work in Acrobat Reader.
Copy link to clipboard
Copied
Moreover, it is not impossible that the anti-virus detects your script as malicious simply because it contains unnecessary and incomprehensible code…
Copy link to clipboard
Copied
Thank you for the feedback!
Copy link to clipboard
Copied
I doubt it has anything to do with how your code works. It's more likely an issue it has with embedded code in general, but you can test it by removing one line at a time and seeing if it still reports it as a virus. Either way, the solution needs to be to report this issue to the makes of the AV software and ask them to fix it.
Copy link to clipboard
Copied
Without using a script you could hide certain buttons. But you need a script to flatten.
Antivirus engines are likely to block anything with any JavaScript at all.