RTF or .doc files

I am building an app which which reads the information (codes and pictures) from a file and builds .RTF or .doc files with some formatting and adding pictures. What would be the best strategy to build these .rtf or .doc files?

Thank you!

Harrie