Print Template Set Legend Columns Via Javascript API

I have a web application that displays map, based on dynamic layers, and provides basic functionality like zoom\pan, print(pdf export option) etc. Application uses javascript api. Now there is a requirement to show legend in the printed map pdf and also to add custom text and custom image\picture . So i added empty legend, text and picture elements in the templates of A3 , A4 mxds and published them as service. The templates have no data assigned so empty legend.

1.Am able to dynamically assign text values via the following lines of code for template

2.Am not able to assign legend column numbers from code. For example setting no. of columns in legend to 3 or 4 etc or showing legend in horizontal instead of vertical etc. Is this possible to achieve this via code\api? If yes then how?

3.Am not able to assign Path(UNC etc) for the picture element from the code. I need this as in my case multiple images will be on a folder on server and user wants to select one of them to be shown on the printed page when using print option. So need to set the path dynamically. Is this possible to achieve this via code\api? If yes then how?