Integrate the new Viewer UI
If you are newly adding the document viewer into your app, you can follow this guide to add the viewer with the new UI. If you are looking to migrate from the your viewer in your app to use the new UI, you can follow this ui migration guide.
Integrate via Fragment
To use the new drop-in viewer fragment, create a PdfViewCtrlTabHostFragment2 using the new ViewerBuilder2 class.
// Add a viewer fragment to the layout container in the specified
// activity, and returns the added fragment
public PdfViewCtrlTabHostFragment2 AddViewerFragment(int fragmentContainer,
AppCompatActivity activity, Android.Net.Uri fileUri, String password)
{
// Create the viewer fragment
PdfViewCtrlTabHostFragment2 fragment = (PdfViewCtrlTabHostFragment2)ViewerBuilder2.WithUri(fileUri, password).Build(activity);
// Add the fragment to the layout fragment container
activity.SupportFragmentManager.BeginTransaction()
.Replace(fragmentContainer, fragment)
.Commit();
return fragment;
}Integrate via Activity
A new builder class DocumentActivity.IntentBuilder has been added to help you more easily customize the activity document viewer. You can also use this new builder to specify the viewer to use the new UI as follows:
Building a custom annotation toolbar
Buttons in the annotation toolbar can be customized using the AnnotationToolbarBuilder API. The buttons on the annotation toolbar are contained in two groups: the scrollable region (left) and the sticky region (right). The scrollable region can contain any number of buttons and scrolling is used to access buttons that are off-screen. Buttons in the sticky region will always show on the screen and will not be scrollable.
For example, built-in PDF tool buttons can be added to a viewer as follows:
Afterwards, you can supply this AnnotationToolbarBuilder to the viewer using the ViewerConfig class.
If you would like to add a button with custom functionality, you can add a generic button as so:
Then you can listen for annotation toolbar button events by adding a PdfViewCtrlTabHostFragment2.TabHostListener:
Last updated
Was this helpful?