Embedded doesn't work in 8.1.0

Embedded doesn’t work in 8.1.0


do you have a small example app where this shows?


I just simplly add one Embedded object to my page, and write the code as following:

​embedded = new Embedded(“test”);
mpiPreview.setExpandRatio(embedded, 1);
embedded.setSource(new StreamResource(new StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
return media.getMediaStream();
}, media.getName()));

After I run the above code, I found the Embedded indeed was added to my page, becasue the caption “test” is shown in the page, but there is no any content.
And the callback function

public InputStream getStream() {
return media.getMediaStream();

will never be called.

Correct me if I am wrong in any place, thank you very much.


I’m not sure where your example goes wrong, but I tested with a SVG file and this code:

        StreamResource.StreamSource streamSource = (StreamResource.StreamSource) () -> {

            FileInputStream fis = null;
            try {
                fis = new FileInputStream("path/to/file/kiwi.svg");
            } catch (Exception e) {
                System.out.println("error:" + e.getMessage());
            return fis;
        StreamResource streamResource = new StreamResource(streamSource,"kiwi.svg");

        Embedded object = new Embedded("My SVG", streamResource);

and it seems to work ok for me. Using 8.1.0.


I tried with 8.1.1, it still doesn’t work.

when I put one image into the Embeded, it works. But if it is pdf, it doesn’t work at all.

That sounds like there is no PDF pluging installed with the browser.

thanks for your reply.
​But I am sure there is pdf plugin, because I could open the pdf with my browser.

That is strange, since you said image is working but PDF is not. Have you tested more than one browser? Which browser you have been using?

Actually I have tried Chrome, Firefox, Edge, IE11, They all doesn’t work on PDF.
I believe it works in Vaadin7.0 with the same code in another Project.