PDF.js
The PDF.js module integrates with the Wicket Viewer, rendering a Blob
property containing a PDF using the PDF.js library.
Usage
To use the extension, annotate an Blob property with the @PdfJsViewer annotation.
For example:
@PdfJsViewer (1)
@Property()
@PropertyLayout(fieldSetId = "content", sequence = "1")
public Blob getAttachment() { ... }
1 | indicates that the Blob returns a set of bytes that correspond to a PDF, and so should be rendered as such.
|
Optionally, you can also provide an implementation of the PdfJsViewerAdvisor SPI, which advises on the size of the viewer (and has callbacks to keep track of which page of the PDF is being viewed). The framework provides a fallback implementation that sets the height to 800px, and scaled to 75% normal size.
Configuration
Make the following changes:
-
In your domain module (containing the domain class that has a
Blob
PDF type), add in the following dependency:pom.xml<dependency> <groupId>org.apache.causeway.extensions</groupId> <artifactId>causeway-extensions-pdfjs-applib</artifactId> </dependency>
This will provide access to the @PdfJsViewer annotation.
-
And, in the webapp module, add the following dependency:
pom.xml<dependency> <groupId>org.apache.causeway.extensions</groupId> <artifactId>causeway-extensions-pdfjs-wicket-ui</artifactId> </dependency>
-
In your
AppManifest
:AppManifest.java@Configuration @Import({ CausewayModuleExtPdfjsWicketUi.class, (1) ... }) public class AppManifest { }