Please give a brief summary of your issue: Custom Stamp as bar button - #5 by jack.knight Trying to do the exact same thing on Android. I need to know where to add the annotation to have it show in the annotation bar.
Please describe your issue and provide steps to reproduce it:
So far we do this:
val toolManagerBuilder = ToolManagerBuilder
.from()
.addCustomizedTool(CustomStamp.MODE, CustomStamp::class.java)
val builder = ViewerConfig.Builder()
.toolManagerBuilder(toolManagerBuilder)
.addToolbarBuilder(DefaultToolbars.defaultViewToolbar)
.addToolbarBuilder(DefaultToolbars.defaultAnnotateToolbar)
.addToolbarBuilder(DefaultToolbars.defaultDrawToolbar)
and the CustomStampClass is here:
class CustomStamp(ctrl: PDFViewCtrl) : BaseTool(ctrl) {
override fun getToolMode(): ToolManager.ToolModeBase {
return MODE
}
override fun getCreateAnnotType(): Int {
return Annot.e_Stamp
}
override fun canDrawLoupe(): Boolean {
return super.mDrawingLoupe
}
override fun getLoupeType(): Int {
return LOUPE_TYPE_MEASURE
}
companion object {
var MODE: ToolManager.ToolModeBase = ToolManager.ToolMode.addNewMode(Annot.e_Stamp)
}
}
I need to find a way to set the annotation icon and add it to the annotation toolbar. With the above code, the annotation bar is showing up, but it is not showing any additional tools.
To add your custom stamp tool to the annotation toolbar you will need to create a CustomAnnotationToolbar with the tools you want to see.
From what we can tell from your sample code you are extending the BaseTool class. To create a custom stamp tool you will need to extend the Stamper class instead, otherwise all features of the Stamp tool would not be available. Please see this example of a custom stamp tool.
At what point do I call “setupAnnotationToolbar”, and where do I get the ToolManager to call this function? We are using a custom PdfViewCtrlTabHostFragment, but when I try to call this method in the initViews, we do not have the Fragment Activity yet, so I cannot create a ToolManager using ToolManager.build(this.currentPdfViewCtrlFragment).