Muhammad Salman Farooq
Muhammad Salman Farooq

Reputation: 1325

Displaying a text file in browser in vaadin

I am developing an application in Java Vaadin framework. I have a text (.txt) file which I want to open in web browser. So what can be the ways in Vaadin to display the text file in browser similar to the browser's PDF viewer. Thanks!

Upvotes: 3

Views: 1965

Answers (1)

Marthin
Marthin

Reputation: 6543

You could have a look at the rich label http://demo.vaadin.com/sampler/#LabelRich You simply use it by doing:

Label richText = new Label("yourtext");
richText.setContentMode(Label.CONTENT_XHTML);

The key here is the Lable content mode. You can find more of them at https://vaadin.com/api/com/vaadin/ui/Label.html if you want other types of layouts

And to get your text file content into the Label you could use any of the strategies shown at this link or just read in the Java API

Upvotes: 3

Related Questions