You could write a Template that does this and use that as a Custom View in the details screen.
In Alfresco 2.1 the Template API can be used to convert most document mimetypes to text format - we use it to display pop-up AJAX info panels in the 2.1 UI. So for 2.1 it will be easier to generate previews for custom views.