If you are looking for a quick start on displaying documents in your application, please first take a look at Show a document in an Activity or Show a document in a Fragment as they are easier to setup and ready to launch from any activity or fragment. Continue reading this article if you are looking to embed PDFViewCtrl
in your own layout.
PDFViewCtrl
is a ViewGroup
that can be embedded in any layout. It encapsulates a rich set of functionalities for interactive viewing of PDF documents, including multi-threaded rendering, PDF rendering settings, scrolling, zooming, page navigation, different page viewing modes, coordinates conversion, text selection, text search, etc.
In this tutorial you will display a PDF file in your activity by using PDFViewCtrl
.
AndroidManifest.xml
, make sure you enable largeHeap
in the <application>
tag. Also, add a custom theme and set the android:windowSoftInputMode:"adjustPan"
attribute in the <activity>
tag as follow:PDFTronAppTheme
for your activity in res/values/styles.xml
:You can learn more about this in the customize the viewer's theme guide.PDFViewCtrl
uses the AppCompat
theme for material colors. Make sure that the value of android:theme
in your <activity>
tag also extends the AppCompat
theme.
PDFViewCtrl
to your activity's XML layout. For example:PDFViewCtrl
after inflating the layout and call AppUtils.SetupPDFViewCtrl
.src/main/res/raw
folder, then call:Please follow the latest Android best practices and guidelines outlined here
It is extremely important that you follow the Android activity/fragment lifecycle and clean up PDFViewCtrl
and PDFDoc
properly. Make sure you have the following in lifecycle callbacks:
PDFViewCtrl
? Check out the Setup ToolManager guide.PDFViewCtrl
? Check out the viewing other document types guide.Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales