Can I manipulate the content of the document through code?

Can I manipulate the content of the document through code?

I need to show the data of the user logged into my system in the document, is there a way to add it through code? How can I add text to the document through programming?