Great! For all others that have this problem, I copy paste the code that works (because now it works) below. Thanks to Gilad this code below is working.
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
f.readonly = true;
}
app.execMenuItem("SaveAs")
One other question , I did not realise. So now I have this button at my form, the save as button. Perfect. But when people save the form, and it is non editable etc. And they open it again, they see the "save as" button. But since at that moment the PDF is non editable, how can I make it in such a way that after saving the "save as" button is removed from the PDF?