The API allows you to add additional display content to the JPedal Swing PDF viewer (for example your own Annotations or a watermark). You can also have a different set of objects for display and printing.
The method org.jpedal.PdfDecoder.drawAdditionalObjectsOverPage(…) makes this possible. This function is best explained with example code, so here is a draw example for Swing Viewer. This is a good starting point for experimenting with this feature. If you wish to print across a page range, this needs to be set up on a document basis. For this reason, PDF printing is handled separately. The method org.jpedal.PdfDecoder.printAdditionalObjectsOverPage(…) makes this possible. Here is a documented print example.
The method org.jpedal.PdfDecoder.flushAdditionalObjectsOnPage() removes Swing objects from the display. Here is a documented code example.
You can also add custom objects in Swing which implement the interface org.jpedal.external.JPedalCustomDrawObject to allow you to create your own additional objects to be rendered. It also includes methods to control visibility and a separate method for printing. An inner class example is here.
Note: In certain cases, a PDF file can have a clip set on it, in which case some custom objects may not be visible. We suggest setting the clip to null before any additional objects are drawn.
You can either create separate objects for each page or create objects for all pages. This is done by using printAdditionalObjectsOverAllPages() method. See an example here.