Embedded PDF

Regarding
to this
, what’s wrong with my code?

in a component:


Window w = new Window();
w.setSizeFull();
w.getLayout().setSizeFull();
final StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
  public InputStream getStream() {
    return new ByteArrayInputStream(pdfByteArray);
  }
}, "report.pdf", getApplication());
Embedded c = new Embedded("", resource);
c.setSizeFull();
w.addComponent(c);
getWindow().addWindow(w);

The popup just shows blank, although something is coming to the browser as some AcroRd process starts.

With this code pdf shows ok, but the popup blockers can nag so I wouldn’t want to use this:


public void setPdf(final byte[] pdf) {
        final StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
            public InputStream getStream() {
                return new ByteArrayInputStream(pdf);
            }
        }, "raportti.pdf", getApplication());
        getWindow().open(resource, "_new");
}

Toolkit version 5.40 (not yet had the time to migrate to 6.x in this project)

Thanks!

Hi Ville!

I quickly tested with the Embedded and here is what found:

http://uilder.virtuallypreinstalled.com/run/Embedded_PDF/

I’m sorry for the minimal layouting here, but this is just for the idea… :slight_smile:

Don’t know if this is suitable for your purposes, but at least it seems to work.

Oh yeah,

it was the Embedded.TYPE_BROWSER that saved the game!

Thanks Sami, can always count on you :bashful: