This is a guide on how to leverage the PDFTron Android SDK to embed a fast and user-friendly form builder into your Android application.
PDF provides a robust set of interactive form features, allowing users to fill information within a document electronically and sign digitally -- online or offline. The completed PDF form can then be easily shared with others with all its content legible and secure.
However, filling PDF forms in the real world is often frustrating. Many vendors produce scanned or malformed PDFs that destroy the fillable fields and force users to print and sign the document by hand -- a waste of time and trees.
At PDFTron, we want to help your users by making PDF form building as painless and straightforward as possible. With PDFTron SDK, you can convert an existing electronic document to a PDF form as well as turn a scanned image into a PDF form. Your users can then quickly and intuitively add their fields to the document and take full advantage of interactive form filling features.
You will first need to integrate the PDFTron Android SDK.
Next, you will need to add the viewer to your application.
When that's done, run the application from Android Studio and the form toolbar will be enabled by default. The form toolbar can be found in the overflow menu of the option toolbar:
|Text widget||Signature widget||List box widget|
|Checkbox widget||Radio button widget||Combo box widget|
You can change which tools will be displayed in the toolbar as follows:
// Disable list box and combo box widgets val toolModes = arrayOf( ToolManager.ToolMode.FORM_COMBO_BOX_CREATE, ToolManager.ToolMode.FORM_LIST_BOX_CREATE ) val tmBuilder = ToolManagerBuilder.from() .disableToolModes(toolModes) // Add ToolManagerBuilder to your ViewerConfig val config = ViewerConfig.Builder() // ... .toolManagerBuilder(tmBuilder) .build()
The toolbar style can be changed as follows:
<style name="YourAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <item name="colorPrimary">@color/app_color_primary_day</item> <item name="colorPrimaryDark">@color/app_color_primary_dark_day</item> <item name="colorAccent">@color/app_color_accent</item> <item name="form_toolbar">@style/CustomFormToolbarStyle</item> </style> <style name="CustomFormToolbarStyle" parent="FormToolbarStyle"> <item name="colorBackground">@android:color/black</item> </style>
See guide here: appearance styling.
If you are interested in creating form fields programmatically, see guide here: create new form fields via API.
We're ultimately just scratching the surface of what can be done with PDFTron SDK's hundreds of unique features to extend the above form toolbar. For example: integrating a feature that would snap widgets to a grid would make it a lot easier for users to align fields.
If you hit any stuck points, want to share how this solution worked out for you, or are just curious about the other capabilities of our SDKs -- don't hesitate to get in touch.