Building an activity around the PdfFragment
You might want to customize the user interface of your app beyond what is possible with the predefined UI of the PdfActivity. The greatest flexibility can be achieved by embedding the PdfFragment into a custom AppCompatActivity(opens in a new tab). This guide provides the foundation for using the fragment in a custom environment in conjunction with existing Nutrient widgets that are also used by the PdfActivity.
ℹ️ Note: This article describes how to manually build a custom activity that uses the
PdfFragmentand other framework widgets. The other, simpler solutions are to either extend the existingPdfActivityor load a document into the defaultPdfActivity. You can also use thePdfUiFragmentto display the document with the same UI thePdfActivityuses. To see how, refer to the guide on how to use a fragment.
Embedding the fragment
Our PdfFragment guide shows the basics of setting up the PdfFragment by providing a license and configuration. A runnable code example can be found inside our Catalog app: The FragmentExample showcases how to use the PdfFragment in a custom AppCompatActivity(opens in a new tab).
Providing search
Nutrient has two predefined search widgets that are also used by the PdfActivity:
PdfSearchViewInlineis a small search widget that, when expanded, sits inside the main action bar. It provides an input field, a results label showing the number of found results, and controls for navigating back and forth inside the results. This widget is useful on smaller devices, where a list of all results would overlay the viewed document.PdfSearchViewModularis an expandable panel that sits above the document area. It shows a full scrollable list of all results, including preview snippets. Tapping a result will close the search view and navigate to the page containing the result.
ℹ️ Note: As a third option, you can manually build a custom search widget using our extensive search API.
Providing toolbars
You can use all the Nutrient toolbars as standalone views in your custom activities. Have a look at the using toolbars within fragment guide for more information.
Form editing UI
PdfActivity includes the form editing UI out of the box. Take a look at the using the form editing UI within fragment guide if you want to integrate the form editing UI into your custom activity.