From 023d6df95fed2daefcc3d49a7efa2fc1835361ff Mon Sep 17 00:00:00 2001 From: Sujoy Das Date: Wed, 19 Nov 2025 11:37:27 +0200 Subject: [PATCH 1/4] chore: version 6.0.0 --- .gitignore | 6 +- pom.xml | 2 +- pom.xml.versionsBackup | 73 ------- vcf-pdf-viewer-demo/pom.xml | 30 +-- vcf-pdf-viewer-demo/pom.xml.versionsBackup | 219 ------------------- vcf-pdf-viewer/pom.xml | 14 +- vcf-pdf-viewer/pom.xml.versionsBackup | 239 --------------------- 7 files changed, 28 insertions(+), 555 deletions(-) delete mode 100644 pom.xml.versionsBackup delete mode 100644 vcf-pdf-viewer-demo/pom.xml.versionsBackup delete mode 100644 vcf-pdf-viewer/pom.xml.versionsBackup diff --git a/.gitignore b/.gitignore index 63af9df..e664706 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ error-screenshots/ *.iml .idea/ .eclipse +.DS_Store # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml @@ -45,9 +46,6 @@ webpack.config.js webpack.generated.js .vscode -vcf-pdf-viewer-demo/frontend/index.html -vcf-pdf-viewer-demo/frontend/generated -vcf-pdf-viewer-demo/src/main/dev-bundle vcf-pdf-viewer-demo/vite.generated.ts vcf-pdf-viewer-demo/vite.config.ts vcf-pdf-viewer-demo/tsconfig.json @@ -55,3 +53,5 @@ vcf-pdf-viewer-demo/types.d.ts vcf-pdf-viewer-demo/pnpmfile.js vcf-pdf-viewer-demo/.npmrc vcf-pdf-viewer-demo/src/main/dev-bundle +vcf-pdf-viewer-demo/src/main/frontend/index.html +vcf-pdf-viewer-demo/src/main/frontend/generated \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3bc9d74..ba6eaf4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.vaadin.addons.componentfactory vcf-pdf-viewer-root - 5.0.1-SNAPSHOT + 6.0.0-SNAPSHOT pom vcf-pdf-viewer diff --git a/pom.xml.versionsBackup b/pom.xml.versionsBackup deleted file mode 100644 index 8c9350b..0000000 --- a/pom.xml.versionsBackup +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - - org.vaadin.addons.componentfactory - vcf-pdf-viewer-root - 2.7.3-SNAPSHOT - pom - - vcf-pdf-viewer - vcf-pdf-viewer-demo - - Pdf Viewer - Pdf Viewer component based on pdf.js library - - - 22.0.17 - 1.8 - 1.8 - UTF-8 - UTF-8 - - 2021 - - Vaadin Ltd - https://vaadin.com/ - - - - - - ${project.groupId} - vcf-pdf-viewer - ${vcf-pdf-viewer.version} - - - com.vaadin - vaadin-bom - pom - import - ${vaadin.version} - - - - - - Vaadin Directory - https://maven.vaadin.com/vaadin-addons - - - - Vaadin prereleases - https://maven.vaadin.com/vaadin-prereleases - - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - - - - - - Vaadin prereleases - https://maven.vaadin.com/vaadin-prereleases - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - false - - - diff --git a/vcf-pdf-viewer-demo/pom.xml b/vcf-pdf-viewer-demo/pom.xml index 479883a..f3b6c42 100644 --- a/vcf-pdf-viewer-demo/pom.xml +++ b/vcf-pdf-viewer-demo/pom.xml @@ -6,7 +6,7 @@ org.vaadin.addons.componentfactory vcf-pdf-viewer-demo - 5.0.1-SNAPSHOT + 6.0.0-SNAPSHOT Pdf Viewer Demo war @@ -18,10 +18,10 @@ - 24.8.0 + 25.0.0-beta5 9.0.1 - 17 - 17 + 21 + 21 UTF-8 UTF-8 false @@ -65,7 +65,9 @@ vaadin-snapshots https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - false + + false + @@ -105,9 +107,9 @@ - org.vaadin.addons.componentfactory - vcf-pdf-viewer - ${project.version} + org.vaadin.addons.componentfactory + vcf-pdf-viewer + ${project.version} @@ -120,13 +122,13 @@ org.slf4j slf4j-simple - + - javax.servlet - javax.servlet-api - 3.1.0 - - + javax.servlet + javax.servlet-api + 3.1.0 + + diff --git a/vcf-pdf-viewer-demo/pom.xml.versionsBackup b/vcf-pdf-viewer-demo/pom.xml.versionsBackup deleted file mode 100644 index d875609..0000000 --- a/vcf-pdf-viewer-demo/pom.xml.versionsBackup +++ /dev/null @@ -1,219 +0,0 @@ - - - 4.0.0 - - org.vaadin.addons.componentfactory - vcf-pdf-viewer-demo - 2.7.3-SNAPSHOT - - Pdf Viewer Demo - war - - 2020 - - Vaadin Ltd - https://vaadin.com/ - - - - 22.0.17 - 9.0.1 - 1.8 - 1.8 - UTF-8 - UTF-8 - false - - - - - com.vaadin - vaadin-bom - pom - import - ${vaadin.version} - - - - - - - - Vaadin Directory - https://maven.vaadin.com/vaadin-addons - - - - Vaadin prereleases - https://maven.vaadin.com/vaadin-prereleases - - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - - - - - - Vaadin prereleases - https://maven.vaadin.com/vaadin-prereleases - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - false - - - - - com.vaadin - - vaadin-core - - - - - - com.vaadin.webjar - * - - - org.webjars.bowergithub.insites - * - - - org.webjars.bowergithub.polymer - * - - - org.webjars.bowergithub.polymerelements - * - - - org.webjars.bowergithub.vaadin - * - - - org.webjars.bowergithub.webcomponents - * - - - - - - org.vaadin.addons.componentfactory - vcf-pdf-viewer - ${project.version} - - - - com.vaadin - flow-component-demo-helpers - ${flow.version} - - - - org.slf4j - slf4j-simple - - - - javax.servlet - javax.servlet-api - 3.1.0 - - - - - - - - - src/main/java - false - - - src/main/resources - false - - - - - - org.eclipse.jetty - jetty-maven-plugin - 9.4.15.v20190215 - - -1 - ${project.artifactId} - 8081 - - - - - com.vaadin - vaadin-maven-plugin - ${vaadin.version} - - - - prepare-frontend - - - false - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - - true - - - - - - - - - - production - - true - - - - - com.vaadin - flow-server-production-mode - - - - - - - com.vaadin - vaadin-maven-plugin - ${vaadin.version} - - - - prepare-frontend - build-frontend - - - - - - - - - - diff --git a/vcf-pdf-viewer/pom.xml b/vcf-pdf-viewer/pom.xml index c4603cf..3afc0ea 100644 --- a/vcf-pdf-viewer/pom.xml +++ b/vcf-pdf-viewer/pom.xml @@ -6,7 +6,7 @@ org.vaadin.addons.componentfactory vcf-pdf-viewer - 5.0.1-SNAPSHOT + 6.0.0-SNAPSHOT jar Pdf Viewer @@ -19,9 +19,9 @@ - 24.8.0 - 17 - 17 + 25.0.0-beta5 + 21 + 21 UTF-8 UTF-8 @@ -63,7 +63,9 @@ vaadin-snapshots https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - false + + false + @@ -109,7 +111,7 @@ org.codehaus.mojo license-maven-plugin 2.0.0 - + apache_v2 diff --git a/vcf-pdf-viewer/pom.xml.versionsBackup b/vcf-pdf-viewer/pom.xml.versionsBackup deleted file mode 100644 index e633fb8..0000000 --- a/vcf-pdf-viewer/pom.xml.versionsBackup +++ /dev/null @@ -1,239 +0,0 @@ - - - 4.0.0 - - org.vaadin.addons.componentfactory - vcf-pdf-viewer - 2.7.3-SNAPSHOT - jar - - Pdf Viewer - Pdf Viewer component - - 2021 - - Vaadin Ltd - https://vaadin.com/ - - - - 22.0.17 - 1.8 - 1.8 - UTF-8 - UTF-8 - - - - - - com.vaadin - vaadin-bom - pom - import - ${vaadin.version} - - - - - - Vaadin Directory - https://maven.vaadin.com/vaadin-addons - - - - Vaadin prereleases - https://maven.vaadin.com/vaadin-prereleases - - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - - - - - - Vaadin prereleases - http://maven.vaadin.com/vaadin-prereleases - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - false - - - - - com.vaadin - - vaadin-core - - - - - - com.vaadin.webjar - * - - - org.webjars.bowergithub.insites - * - - - org.webjars.bowergithub.polymer - * - - - org.webjars.bowergithub.polymerelements - * - - - org.webjars.bowergithub.vaadin - * - - - org.webjars.bowergithub.webcomponents - * - - - - - - - - - org.codehaus.mojo - license-maven-plugin - 2.0.0 - - - apache_v2 - - **/main/**/*.java - **/main/**/*.js - - true - true - - - - - check-file-header - - process-sources - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - 8 - - - - attach-javadoc - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - true - - false - true - - - 1 - - - - - - - - - directory - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.1.0 - - false - - assembly/assembly.xml - - - - - - single - - install - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - - attach-javadocs - verify - - jar - - - - - true - -Xdoclint:none - - - - - - - From 97db154773426d976c1b987a8be230df88f96ff1 Mon Sep 17 00:00:00 2001 From: Sujoy Das Date: Wed, 19 Nov 2025 12:07:26 +0200 Subject: [PATCH 2/4] chore: update plugin versions --- vcf-pdf-viewer-demo/pom.xml | 28 ++++++++++++++++++++++++---- vcf-pdf-viewer/pom.xml | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/vcf-pdf-viewer-demo/pom.xml b/vcf-pdf-viewer-demo/pom.xml index f3b6c42..2982cf6 100644 --- a/vcf-pdf-viewer-demo/pom.xml +++ b/vcf-pdf-viewer-demo/pom.xml @@ -148,7 +148,7 @@ org.eclipse.jetty jetty-maven-plugin - 11.0.13 + 11.0.26 ${project.artifactId} 8081 @@ -173,7 +173,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.7.0 true @@ -181,12 +181,32 @@ org.apache.maven.plugins maven-war-plugin - 3.3.1 + 3.5.0 org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.14.1 + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-maven + + enforce + + + + + 3.8 + + + + + diff --git a/vcf-pdf-viewer/pom.xml b/vcf-pdf-viewer/pom.xml index 3afc0ea..de70217 100644 --- a/vcf-pdf-viewer/pom.xml +++ b/vcf-pdf-viewer/pom.xml @@ -110,7 +110,7 @@ org.codehaus.mojo license-maven-plugin - 2.0.0 + 2.7.0 apache_v2 @@ -133,7 +133,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.12.0 8 @@ -149,7 +149,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.1 attach-sources @@ -162,7 +162,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + 3.5.0 true @@ -176,6 +176,26 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-maven + + enforce + + + + + 3.8 + + + + + + @@ -186,7 +206,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.1.0 + 3.7.1 false @@ -205,7 +225,7 @@ org.apache.maven.plugins maven-source-plugin - 3.0.1 + 3.3.1 attach-sources @@ -219,7 +239,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + 3.12.0 attach-javadocs @@ -231,7 +251,7 @@ true - -Xdoclint:none + none From 43af0e15f2f7c45ef1f3eda5b5863ed1119c4daf Mon Sep 17 00:00:00 2001 From: Sujoy Das Date: Wed, 19 Nov 2025 16:18:31 +0200 Subject: [PATCH 3/4] chore: fix versions of vcf-pdf-viewer web component and jetty version for v25 --- .gitignore | 2 +- vcf-pdf-viewer-demo/pom.xml | 29 ++++--------------- .../componentfactory/pdfviewer/PdfViewer.java | 2 +- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index e664706..4d7d293 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,6 @@ vcf-pdf-viewer-demo/tsconfig.json vcf-pdf-viewer-demo/types.d.ts vcf-pdf-viewer-demo/pnpmfile.js vcf-pdf-viewer-demo/.npmrc -vcf-pdf-viewer-demo/src/main/dev-bundle +vcf-pdf-viewer-demo/src/main/bundles vcf-pdf-viewer-demo/src/main/frontend/index.html vcf-pdf-viewer-demo/src/main/frontend/generated \ No newline at end of file diff --git a/vcf-pdf-viewer-demo/pom.xml b/vcf-pdf-viewer-demo/pom.xml index 2982cf6..8223e94 100644 --- a/vcf-pdf-viewer-demo/pom.xml +++ b/vcf-pdf-viewer-demo/pom.xml @@ -19,12 +19,10 @@ 25.0.0-beta5 - 9.0.1 21 21 UTF-8 UTF-8 - false @@ -38,7 +36,6 @@ - Vaadin Directory @@ -112,23 +109,10 @@ ${project.version} - - com.vaadin - flow-component-demo-helpers - ${flow.version} - - org.slf4j slf4j-simple - - - javax.servlet - javax.servlet-api - 3.1.0 - - @@ -146,9 +130,9 @@ - org.eclipse.jetty - jetty-maven-plugin - 11.0.26 + org.eclipse.jetty.ee11 + jetty-ee11-maven-plugin + 12.1.4 ${project.artifactId} 8081 @@ -164,9 +148,6 @@ prepare-frontend - - false - @@ -182,6 +163,9 @@ org.apache.maven.plugins maven-war-plugin 3.5.0 + + false + org.apache.maven.plugins @@ -246,5 +230,4 @@ - diff --git a/vcf-pdf-viewer/src/main/java/com/vaadin/componentfactory/pdfviewer/PdfViewer.java b/vcf-pdf-viewer/src/main/java/com/vaadin/componentfactory/pdfviewer/PdfViewer.java index c5d0267..7ea2d40 100644 --- a/vcf-pdf-viewer/src/main/java/com/vaadin/componentfactory/pdfviewer/PdfViewer.java +++ b/vcf-pdf-viewer/src/main/java/com/vaadin/componentfactory/pdfviewer/PdfViewer.java @@ -39,7 +39,7 @@ import org.apache.commons.lang3.StringUtils; @Tag("vcf-pdf-viewer") -@NpmPackage(value = "@vaadin-component-factory/vcf-pdf-viewer", version = "3.1.0") +@NpmPackage(value = "@vaadin-component-factory/vcf-pdf-viewer", version = "4.0.0") @NpmPackage(value = "print-js", version = "1.6.0") @JsModule("@vaadin-component-factory/vcf-pdf-viewer/vcf-pdf-viewer.js") @JsModule("./src/pdf-print.js") From 855dd14a121adfeb8d8d07813245ea49761d920f Mon Sep 17 00:00:00 2001 From: Sujoy Das Date: Wed, 19 Nov 2025 16:37:46 +0200 Subject: [PATCH 4/4] chore: replace stream resource with download handler in demo views --- .../pdfviewer/AdjustZoomPdfViewerExample.java | 24 +++++------ .../CustomAutoFitZoomLabelsExample.java | 25 ++++++------ .../pdfviewer/CustomTitleExample.java | 19 +++++---- .../RenderingInteractiveFormsExample.java | 23 +++++------ .../pdfviewer/SelectPagePdfViewerExample.java | 37 +++++++++-------- .../pdfviewer/SourceChangeExample.java | 40 +++++++++---------- .../pdfviewer/ThumbnailsListenerExample.java | 27 ++++++------- .../ThumbnailsViewerOpenExample.java | 23 +++++------ .../pdfviewer/WithPrintOptionExample.java | 23 +++++------ .../pdfviewer/WithRotateOptionsExample.java | 25 ++++++------ .../pdfviewer/WithoutDownloadExample.java | 23 +++++------ .../pdfviewer/WithoutZoomDropdownExample.java | 23 +++++------ 12 files changed, 151 insertions(+), 161 deletions(-) diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/AdjustZoomPdfViewerExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/AdjustZoomPdfViewerExample.java index eefcd73..5ad9629 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/AdjustZoomPdfViewerExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/AdjustZoomPdfViewerExample.java @@ -2,19 +2,19 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "zoom", layout = MainLayout.class) public class AdjustZoomPdfViewerExample extends Div { - - public AdjustZoomPdfViewerExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setZoom("page-fit"); - add(pdfViewer); - } - + + public AdjustZoomPdfViewerExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setZoom("page-fit"); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomAutoFitZoomLabelsExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomAutoFitZoomLabelsExample.java index d58cde6..fc0232f 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomAutoFitZoomLabelsExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomAutoFitZoomLabelsExample.java @@ -2,20 +2,19 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "custom-auto-fit-labels", layout = MainLayout.class) public class CustomAutoFitZoomLabelsExample extends Div { - - public CustomAutoFitZoomLabelsExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setAutoZoomOptionLabel("automatic-zoom"); - pdfViewer.setPageFitZoomOptionLabel("page-fit"); - add(pdfViewer); - } - + + public CustomAutoFitZoomLabelsExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setAutoZoomOptionLabel("automatic-zoom"); + pdfViewer.setPageFitZoomOptionLabel("page-fit"); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomTitleExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomTitleExample.java index b49e1f4..6af8aea 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomTitleExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/CustomTitleExample.java @@ -2,18 +2,17 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "custom-title", layout = MainLayout.class) public class CustomTitleExample extends Div { - - public CustomTitleExample() { - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setCustomTitle("I'm a custom title"); - add(pdfViewer); - } + + public CustomTitleExample() { + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setCustomTitle("I'm a custom title"); + add(pdfViewer); + } } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/RenderingInteractiveFormsExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/RenderingInteractiveFormsExample.java index f16b1d7..0efe610 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/RenderingInteractiveFormsExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/RenderingInteractiveFormsExample.java @@ -2,19 +2,18 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "rendering-interactive-forms", layout = MainLayout.class) public class RenderingInteractiveFormsExample extends Div { - - public RenderingInteractiveFormsExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("Pdf Form Example", () -> getClass().getResourceAsStream("/pdf/pdf-form-example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setRenderInteractiveForms(false); - add(pdfViewer); - } - + + public RenderingInteractiveFormsExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/pdf-form-example.pdf")); + pdfViewer.setRenderInteractiveForms(false); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SelectPagePdfViewerExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SelectPagePdfViewerExample.java index a3db385..e964495 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SelectPagePdfViewerExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SelectPagePdfViewerExample.java @@ -5,26 +5,25 @@ import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "select-page", layout = MainLayout.class) public class SelectPagePdfViewerExample extends Div { - - public SelectPagePdfViewerExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setPage(4); - add(pdfViewer); - - HorizontalLayout layout = new HorizontalLayout(); - layout.setMargin(true); - layout.add(new Button("Click to know current page", e -> { - Notification.show("Current Page: " + pdfViewer.getCurrentPage()); - })); - add(layout); - } - + + public SelectPagePdfViewerExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setPage(4); + add(pdfViewer); + + HorizontalLayout layout = new HorizontalLayout(); + layout.setMargin(true); + layout.add(new Button("Click to know current page", e -> { + Notification.show("Current Page: " + pdfViewer.getCurrentPage()); + })); + add(layout); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SourceChangeExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SourceChangeExample.java index 4a8425d..3ea2cd8 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SourceChangeExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/SourceChangeExample.java @@ -3,28 +3,28 @@ import com.vaadin.flow.component.combobox.ComboBox; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "source-change", layout = MainLayout.class) public class SourceChangeExample extends Div { - - public SourceChangeExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - - ComboBox filesComboBox = new ComboBox<>("Select PDF"); - filesComboBox.setWidth("300px"); - filesComboBox.setPlaceholder("Select a file"); - filesComboBox.setItems("bitcoin.pdf", "example.pdf", "example-invoice.pdf"); - filesComboBox.addValueChangeListener(e -> { - String filename = e.getValue(); - StreamResource resource = new StreamResource(filename, - () -> getClass().getResourceAsStream("/pdf/" + filename)); - pdfViewer.setSrc(resource); - }); - add(filesComboBox, pdfViewer); - } - + public SourceChangeExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + + ComboBox filesComboBox = new ComboBox<>("Select PDF"); + filesComboBox.setWidth("300px"); + filesComboBox.setPlaceholder("Select a file"); + filesComboBox.setItems("bitcoin.pdf", "example.pdf", "example-invoice.pdf"); + filesComboBox.addValueChangeListener(e -> { + String filename = e.getValue(); + var filePath = "/pdf/" + filename; + var downloadHandler = DownloadHandler.forClassResource(getClass(), filePath); + pdfViewer.setSrc(downloadHandler); + }); + + add(filesComboBox, pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsListenerExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsListenerExample.java index 5a436c3..f0a771a 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsListenerExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsListenerExample.java @@ -3,21 +3,20 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "thumbnails-listener", layout = MainLayout.class) public class ThumbnailsListenerExample extends Div { - - public ThumbnailsListenerExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.addThumbnailClickedListener(e -> { - Notification.show("Selected page on thumbnail click: " + e.getSelectedPage()); - }); - add(pdfViewer); - } - + + public ThumbnailsListenerExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.addThumbnailClickedListener(e -> { + Notification.show("Selected page on thumbnail click: " + e.getSelectedPage()); + }); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsViewerOpenExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsViewerOpenExample.java index 418569f..dcaf9b2 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsViewerOpenExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/ThumbnailsViewerOpenExample.java @@ -2,19 +2,18 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "thumbnails-open", layout = MainLayout.class) public class ThumbnailsViewerOpenExample extends Div { - - public ThumbnailsViewerOpenExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.openThumbnailsView(); - add(pdfViewer); - } - + + public ThumbnailsViewerOpenExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.openThumbnailsView(); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithPrintOptionExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithPrintOptionExample.java index 5161576..b0fc2d8 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithPrintOptionExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithPrintOptionExample.java @@ -2,19 +2,18 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "with-print", layout = MainLayout.class) public class WithPrintOptionExample extends Div { - - public WithPrintOptionExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setAddPrintButton(true); - add(pdfViewer); - } - + + public WithPrintOptionExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setAddPrintButton(true); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithRotateOptionsExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithRotateOptionsExample.java index 58550b7..60a4ce0 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithRotateOptionsExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithRotateOptionsExample.java @@ -2,20 +2,19 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "with-rotate-options", layout = MainLayout.class) public class WithRotateOptionsExample extends Div { - - public WithRotateOptionsExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setAddRotateClockwiseButton(true); - pdfViewer.setAddRotateCounterClockwiseButton(true); - add(pdfViewer); - } - + + public WithRotateOptionsExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setAddRotateClockwiseButton(true); + pdfViewer.setAddRotateCounterClockwiseButton(true); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutDownloadExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutDownloadExample.java index 96b98eb..e8c2a57 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutDownloadExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutDownloadExample.java @@ -2,19 +2,18 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "without-download", layout = MainLayout.class) public class WithoutDownloadExample extends Div { - - public WithoutDownloadExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.setAddDownloadButton(false); - add(pdfViewer); - } - + + public WithoutDownloadExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.setAddDownloadButton(false); + add(pdfViewer); + } + } diff --git a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutZoomDropdownExample.java b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutZoomDropdownExample.java index 23729a2..1c68c7c 100644 --- a/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutZoomDropdownExample.java +++ b/vcf-pdf-viewer-demo/src/main/java/com/vaadin/componentfactory/pdfviewer/WithoutZoomDropdownExample.java @@ -2,19 +2,18 @@ import com.vaadin.flow.component.html.Div; import com.vaadin.flow.router.Route; -import com.vaadin.flow.server.StreamResource; +import com.vaadin.flow.server.streams.DownloadHandler; @Route(value = "without-zoom-dropdown", layout = MainLayout.class) public class WithoutZoomDropdownExample extends Div { - - public WithoutZoomDropdownExample() { - - PdfViewer pdfViewer = new PdfViewer(); - pdfViewer.setSizeFull(); - StreamResource resource = new StreamResource("example.pdf", () -> getClass().getResourceAsStream("/pdf/example.pdf")); - pdfViewer.setSrc(resource); - pdfViewer.hideZoom(true); - add(pdfViewer); - } - + + public WithoutZoomDropdownExample() { + + PdfViewer pdfViewer = new PdfViewer(); + pdfViewer.setSizeFull(); + pdfViewer.setSrc(DownloadHandler.forClassResource(getClass(), "/pdf/example.pdf")); + pdfViewer.hideZoom(true); + add(pdfViewer); + } + }