Building an activity around the PdfFragmen
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
. 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
PdfFragment
and other framework widgets. The other, simpler solutions are to either extend the existingPdfActivity
or load a document into the defaultPdfActivity
. You can also use thePdfUiFragment
to display the document with the same UI thePdfActivity
uses. 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
.
Providing search
Nutrient has two predefined search widgets that are also used by the PdfActivity
:
-
PdfSearchViewInline
is 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. -
PdfSearchViewModular
is 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.