Folks here will be better able to help you if you TellTheDetails(←click) of exactly what problems you're having. An SSCCE(←click) is also very helpful.
Since you say you can't use regex, that suggests this is a homework assignment. It will also help if you include any other constraints, restrictions, or requirements, so that we don't go around in circles offering suggestions only to have you come back and say, "I can't do that because..."
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com