xfa.form.form1.pageSet.Page1.medium.stock= "A2"; But this is not working. please help me out.
That's the right object for choosing the page size at Design time. What event are you doing this on? Although you can change it in the form model, the form's page size is already determined from the template by the time you have a form to script against, so although you can change it via script after the fact in XFA, I don't believe it will have any impact. Even putting it on the layout ready event does not work.