Adding support for viewing layers with different content in PDFViewCtrl

Q: One of our requirements is to be able to have multiple layers in the
book/pdf that can be switched on and off. I know there is some
functionality like that in PDF, but I wonder if this is supported with
PDFTron (show / hide items, buttons, etc.)

We are developing Android/iOS mobile apps.
------------
A: There are couple of way you could add 'layers' functionality to your
app:

a) You can use standard PDF layers (a.k.a Optional Content Groups or OCG,
see Google Groups).

This may be a good option is layers are static. This method also works very
well for layers that are fairly complex (e.g. maps with street, names, and
other overlays). Another advantage over b) is that this is just standard
PDF, so layers will show/work in Acrobat Reader etc.

As a starting point you may want to take a look at PDFLayers sample
(http://www.pdftron.com/pdfnet/samplecode.html#PDFLayers)

The sample shows how to switch different layers ‘on’ and ‘off’ when
rasterizing PDF pages via PDFDraw, however the same technique would work
with PDF viewer. You can update OCG/Layer state with
PDFViewCtrl.SetOCGContext(ctx), then redraw the page with
pdfviewctrl.Update).
  
b) Another option is that you draw your own content (widgets) on top of
PDFViewCtrl.
In this case you are essentially implementing custom annotations, so you
can take a look at PDFViewCtrl 'Tools' source for inspiration and template
code. You could use this technique to add items, buttons, etc. Another way
is to add views directly to PDFViewCtrl (through addView()). Depending on
what exactly do you want to achieve (keep the items in the same position
while scrolling, etc), you would need to extend PDFViewCtrl to be able to
override the gesture events, or use the Tool interface to get the events.
The following are some relevant posts:
https://groups.google.com/d/msg/pdfnet-sdk/s99GQwKiRLc/0XSO6OHuVrUJ ,
https://groups.google.com/d/msg/pdfnet-sdk/uZZ0gZ3lvNk/3s-lesli_YoJ