'Embedded pdf document is not displayed using Edge

I have implemenetd my own Embedded Pdf viewer usinf vaadin 22 extending components and it is working in each browser excepted Edge. This is my class for "EmbeddedPdfDocument":

@Tag("object")
public class EmbeddedPdfDocument extends Component implements HasSize {

    public EmbeddedPdfDocument(StreamResource resource) {
        this();
        getElement().setAttribute("data", resource);
    }

    public EmbeddedPdfDocument(String url) {
        this();
        getElement().setAttribute("data", url);
    }

    protected EmbeddedPdfDocument() {
        getElement().setAttribute("type", "application/pdf");
        setSizeFull();
    }
}

Using this utility class I create a stream resource out of a Object called FileRecord which contains the filename, filetype and the file as byte[]:

public static StreamResource getStream(final FileRecord record) {
        InputStreamFactory factory = new InputStreamFactory() {
            @Override
            public InputStream createInputStream() {
                return new ByteArrayInputStream(record.getFile());
            }
        };

        StreamResource resource = new StreamResource(record.getFilename(), factory);
        resource.setContentType(record.getFiletyp());
        return resource;
    }

This is the relevant method in my FileViewer for the Embedded-PDF:

private void createPdfViewer() {
        this.removeAll();

        //
        // This is working:
        //
        EmbeddedPdfDocument pdf = new EmbeddedPdfDocument(StreamResourceHandler.getStream(record));
        pdf.setSizeFull();
        this.add(pdf);
}

The embedded PDF is displayed in a Dialog. As already mentioned, in Sfari, Firefox or Chrome it is working, in Edge no PDF is displayed.

Hopefully someone can give me a hint, Florian



Solution 1:[1]

I found a workaround. Instead of creating an own component I can use the following PDFViewer for Vaadin: https://vaadin.com/directory/component/pdf-viewer/links

Thanks Florian

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Florian