Hi,
How do u input text is it in the file already?
You can send me script that u have we will try to modify that. Although I think that I have worked on similar task in the past.
Generally I usually use JavaScript for this kind of automation. I will send you detail explanation how to use that Script file and how to made some changes in the code if you want to do that. I assume that you already have experience with this kind of work. And if you are not do not worry you only need to upload javascript in Adobe programs and I run and for that u need a few seconds and couple of mouse clicks, after that script will run and u can do something more creative..
I have an experience of many years of work in JavaScript associated with Adobe app, Photoshop, Illustrator, InDesign, Acrobate, Python, Perl ... I am a very dedicated and diligent, so you can expect top quality.
Best regards,
Bojan