I want to build a view in which a can display PDF, Word, plain/text documents in Vaadin. Is there a way to do this ? Thanks.
How to view PDF document in VAADIN
13.3k views Asked by deltascience At
2
There are 2 answers
0
On
you can try below code to open a file(on any url) in a iframe.
Window window = new Window();
window.setWidth("90%");
window.setHeight("90%");
BrowserFrame e = new BrowserFrame("PDF File", new ExternalResource("http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf"));
e.setWidth("100%");
e.setHeight("100%");
window.setContent(e);
window.center();
window.setModal(true);
UI.getCurrent().addWindow(window);
You could use the sample contained in Vaadin documentation
https://vaadin.com/book/-/page/advanced.printing.html (see 11.6.3. Printing PDF)
Other useful example:
http://dev.vaadin.com/svn/doc/book-examples/trunk/src/com/vaadin/book/examples/advanced/PrintingExample.java