Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

using StreamResource to generate a html file

Thara Mediacept
1 decade ago Apr 21, 2010 2:12pm
Joonas Lehtinen
1 decade ago Apr 21, 2010 3:19pm
Thara Mediacept
1 decade ago Apr 21, 2010 3:58pm
Valentin Yaroshinsky
1 decade ago Aug 07, 2010 8:13pm

If it is important yet, you can try:

JasperPrint print = JasperFillManager.fillReport(report, parameter, ds);
			JRHtmlExporter exporter = new JRHtmlExporter();
			final ByteArrayOutputStream output=new ByteArrayOutputStream();
			exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
			exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,output);
			exporter.exportReport();
			output.flush();
                        output.close(); 
StreamResource.StreamSource source = new StreamResource.StreamSource() {
				 
				                public InputStream getStream() {
				                   byte[] b = null;
				                    b=output.toByteArray();
				                   //throw new UnsupportedOperationException("Not supported yet.");
			                    return new ByteArrayInputStream(b);
				                }
			            };
StreamResource resource = new StreamResource(source, "TestReport.html", a);
			Embedded e = new Embedded();
			e.setMimeType("text/html");
			    e.setType(Embedded.TYPE_BROWSER);
			    e.setWidth("100%");
			    e.setHeight("400px");
			    e.setSource(resource); 
			    addComponent(e);
Dragan Krstic
5 years ago May 24, 2016 5:14pm