Embedded component (InputStreamReader)

Hello,

how may I display the following InputStreamReader (PDF from JasperServer) in a Vaadin Embedded component?
I use Vaadin 7.

HttpGet getreport = new HttpGet("http://localhost:8090/jasperserver/rest_v2/reports/reports/GKV/VordruckanzeigenV50.pdf?parmZeitPunkt=20141&Vordruck=KV451a&Nachkomma=0");
          HttpResponse putResponse = httpClient.execute(getreport);

          BufferedReader rd = new BufferedReader(new InputStreamReader(putResponse.getEntity().getContent()));

Thanks for your help !

First of all, the Embedded wants a resource to display. You need to define a StreamSource that provides an InputStream, as in
this example
. How you handle the streams is not really Vaadin-related, so I won’t go into that.

Once you have the StreamResource, you can embed the PDF as shown in
this example
.

[code]
// A resource reference to some object
Resource res = new StreamResource(new MyStreamSource(
…whatever parameters you need to generate it…
),
“output.pdf”);

// Display the object
Embedded object = new Embedded(“My PDF (requires browser plugin)”, res);
object.setType(Embedded.TYPE_OBJECT);
object.setMimeType(“application/pdf”);
object.setWidth(“400px”);
object.setHeight(“300px”);
layout.addComponent(object);
[/code]Note that displaying embedded PDF requires a browser plugin.

Thanks Marko,

i solved the problem.
First I download the PDF-File with the Web-service and then save the report.
Then i displaying the report into the embedded component.

I did not get a another solution.

HttpGet getreport = new HttpGet("http://localhost:8090/jasperserver/rest_v2/reports/reports/GKV/VordruckanzeigenV50.pdf?parmZeitPunkt=20141&Vordruck=KV451a&Nachkomma=0");
          HttpResponse putResponse = httpClient.execute(getreport);

          final InputStream input = putResponse.getEntity().getContent();
          
          OutputStream os = new FileOutputStream(rootverzeichniss + "/WEB-INF/user/test.pdf");
          
          byte[] buffer = new byte[1024]
;
          int bytesRead;
          //read from is to buffer
          while((bytesRead = input.read(buffer)) !=-1){
              os.write(buffer, 0, bytesRead);
          }
          input.close();
          //flush OutputStream to write any buffered data to file
          os.flush();
          os.close();
          
         
          StreamSource source = new StreamSource()
          {
           /**
             *
             */
            private static final long serialVersionUID = 1L;

            public InputStream getStream()
           {
             try {
                return new FileInputStream(rootverzeichniss + "/WEB-INF/user/test.pdf");
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return null;
            }  
           }
         };
         Resource res = new StreamResource(source, "test.pdf");
         embedded_1.setType(Embedded.TYPE_BROWSER);
         embedded_1.setSource(res);
         embedded_1.setMimeType("application/pdf");