<split id="split" height="100%">
<vbox padding="false">
<hbox id="buttonsPanel3" classNames="buttons-panel">
<button action="leaveApplicationDocDataGrid.create"/>
<button action="leaveApplicationDocDataGrid.edit"/>
<button action="leaveApplicationDocDataGrid.remove"/>
</hbox>
<dataGrid id="leaveApplicationDocDataGrid" dataContainer="leaveApplicationDocDc" width="100%"
height="100%"
minHeight="10em" selectionMode="MULTI">
<actions>
<action id="create" type="list_create">
<properties>
<property name="openMode" value="DIALOG"/>
</properties>
</action>
<action id="edit" type="list_edit">
<properties>
<property name="openMode" value="DIALOG"/>
</properties>
</action>
<action id="remove" type="list_remove"/>
</actions>
<columns>
<column property="description"/>
</columns>
</dataGrid>
</vbox>
<vbox id="filedisplay" height="100%">
</vbox>
</split>
@Subscribe("requirementDocDataGrid")
public void onRequirementDocDataGridItemClick(final ItemClickEvent<RequirementDoc> event) {
RequirementDoc selectedReqDoc = event.getItem();
// ProjectDoc has a property 'docImag' of type byte[]
byte[] pdfContent = selectedReqDoc.getDocImage();
PdfViewer pdfViewer = new PdfViewer();
StreamResource resource = new StreamResource(selectedReqDoc.getName(),
() -> new ByteArrayInputStream(pdfContent));
pdfViewer.setSrc(resource);
// Set the height to "100%" to occupy the full available vertical space
pdfViewer.setHeight("100%");
// Clear existing components in the filedisplay layout
filedisplay.removeAll();
// Add the PDF Viewer to the layout
filedisplay.add(pdfViewer);
// Set the height of the filedisplay VBox explicitly
filedisplay.setHeight("100%");
// Explicitly set margin and padding to zero
pdfViewer.getElement().getStyle().set("margin", "0").set("padding", "0");
filedisplay.getElement().getStyle().set("margin", "0").set("padding", "0");
}
I’ve already implemented this for loading any pdf from the database. But when I have a report generated by a service bean, is there any way to have a pdf version of that report which can be viewed in a screen apart from direct download?