Integrating Vaadin Add-on
You can use any third-party Vaadin add-ons located in the Vaadin Directory or elsewhere. The example below demonstrates the integration of the Pdf Viewer add-on.
To include the Vaadin add-on in your application, add the Vaadin Add-ons maven repository and the add-on dependency to the project’s build.gradle
:
build.gradle
repositories {
maven {
url 'https://maven.vaadin.com/vaadin-addons'
}
}
dependencies {
implementation 'org.vaadin.addons.componentfactory:vcf-pdf-viewer:3.0.0'
}
After that, you can use the add-on components programmatically, for example:
@Autowired
private Resources resources;
@Subscribe
public void onInit(final InitEvent event) {
PdfViewer pdfViewer = new PdfViewer();
pdfViewer.setSizeFull();
StreamResource resource = new StreamResource("example.pdf", () ->
resources.getResourceAsStream("META-INF/resources/pdf/example.pdf"));
pdfViewer.setSrc(resource);
getContent().add(pdfViewer);
}
Figure 1. PdfViewer displays a PDF file from resources
Was this page helpful?
Thank you for your feedback