Display PDF in browser


Using vaadin 7.1

I’m trying to use the Embedded component to display a pdf file inside the browsser, but the code for getting the actual content (the stream) is never called. An empty layout is added to my layout with the specified width, height and caption, but the content isnt. My code so far:

final StreamResource res = new StreamResource(new StreamSource() {

public InputStream getStream() {
//this method is never called
FileInputStream newsStream = null;
try {
newsStream = new FileInputStream(filepath);

          catch (FileNotFoundException e) { }
          return newsStream;

}, filename);


Embedded object = new Embedded(filename, res);
[/code]What’s wrong with this code do you know of any other options to display a PDF?

Try using a BrowserFrame component instead of the Embedded, that will produce an iframe.

Thanks, it solves the problem.