Programmatically Open pdf in new tab

Hi Guys,

how can i open a embeddedpdf in a new tab, after reading some data from a NAS?
i cant seem to get the below working.

Anchor anchor = new Anchor();
getPaginationBar().add(anchor);
anchor.setTarget("_blank");
StreamResource streamResource = readFromNAS(filname);
anchor.setHref(openPdfResource);

UI.getCurrent().getPage().executeJs("$0.click()", anchor);

i finally got it working due to some error reading files from NAS.

How do i change the icon on the tabs. It is currently showing springboot icon

18113122.png