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.

vaadin 14 - Exemplo para abrir PDF

Carlos Silva
2 years ago Apr 02, 2020 1:45pm
Rubén Espinoza
2 years ago Apr 05, 2020 11:16pm
Carlos Silva
2 years ago Apr 08, 2020 1:32am

Obrigado, Ruben. Tentei o que me indicou mas só recebia erro. Resolvi depois de muito pesquisar. E compartilho aqui para ajudar aos amigos que precisarem:

    Button downloadButton = new Button("Mostrar");
    Anchor anchor = new Anchor();
    anchor.add(downloadButton);
    anchor.setHref(new StreamResource("file.pdf", () -> new ByteArrayInputStream(methodFazJasperPDF())));
    anchor.setTarget("_blank");
    add(anchor);
	
	//---------------------
	
	public byte[] methodFazJasperPDF(){
	
	     ---------
	     ´´´´´´´´
	     byte[] bytes = JasperExportManager.exportReportToPdf(impressao);
		 return bytes;
    }
	
	Abraços.
Carlos Silva
2 years ago May 17, 2020 1:37am
Rubén Espinoza
2 years ago May 29, 2020 5:58pm