Good afternoon Alejandro I couldn't understand where the data that "feeds"

Good afternoon Alejandro

I couldn’t understand where the data that “feeds” the report.pdf is coming from. Could you explain?

This add-on is for visualizing an existing PDF. The file is [in the project]
(https://github.com/alejandro-du/pdf-browser/tree/master/src/main/resources).

You can generate PDFs in Java with libraries such as iText or Apache PDFBox.

Alejandro, good morning!! Thanks for the answers!!!

Alejandro, I have an application made in Vaadin 14.4.8, in this application I have a session for reports, in this report session I select the range of days, for example from 05/01/2021 to 05/30/2021 and I have a button for generate a report with the sales made in this interval mentioned above. So far everything is working normally. What I would like to do is another button that takes this report that is being displayed in the application and generates a pdf file for download. For that I tried to create the report with JasperReports + iReport 5.6.0…but I didn’t find anything for Jasper in Vaadin 14, only Vaadin 8…in this case, what can you patch that I can do?

my project: https://github.com/fjdesenvolvimento/Vaadin-Application-Sales

attached some images of my current report
18597365.png

You can use any Java library (like JasperReports indeed) to generate the PDF and then pass the bytes to the pdf-browser component. For that you need to create a StremResource. See the commented code at https://github.com/alejandro-du/pdf-browser/blob/master/src/test/java/org/vaadin/alejandro/DemoView.java

Alejandro, so using Jasper would look like this:

public class GeneratePDF {

public void generatePDF() {

VerticalLayout layout = new VerticalLayout();

StreamResource streamResource = new StreamResource(
"report.pdf", () -> getClass().getResourceAsStream("/report1.jrxml")); // file in src/main/resources/

PdfBrowserViewer viewer = new PdfBrowserViewer(streamResource);
viewer.setHeight("100%");
layout.add(viewer);
}

}