For some weird reason if I put the browser in a new project it works great but the exact same code in my main project and all it does is show a blank screen (loading the same pdf). All I can think of is that there may be a dependency that is conflicting. Any suggestions would be appreciated. Below is the code:
public class PdfView extends VerticalLayout {
public PdfView() {
StreamResource streamResource = new StreamResource(
"test.pdf", () -> getClass().getResourceAsStream("/pdf/Test.pdf"));
add(new Button("test", click -> openPdfDialog(streamResource)));
setHeightFull();
}
private void openPdfDialog(StreamResource streamResource) {
PdfBrowserViewer viewer = new PdfBrowserViewer(streamResource);
viewer.setHeight("100%");
viewer.setWidth("100%");
Dialog dialog = new Dialog(viewer);
dialog.setHeight("80%");
dialog.setWidth("80%");
dialog.open();
}
}