Display PDF in browser

Hey!

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() {

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

          }
          catch (FileNotFoundException e) { }
          return newsStream;
    }

}, filename);

res.setMIMEType(“application/pdf”);

Embedded object = new Embedded(filename, res);
object.setType(Embedded.TYPE_OBJECT);
object.setWidth(“400px”);
object.setHeight(“300px”);
layout.addComponent(object);
[/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.