Customizing link activation in Android PDF viewer control


We are developing Android app with your toolkit and are dealing with interactive PDFs with annotations.

The type of annotation is e_link (in PDFNet ‘Annot.e_Link’).

When the user clicks on an annotation in the PDF, you open the browser with the URI of the annotation.

We want that when the URI activation opens WebView and not a browser ( which happens in your sample app) .

Is this possible?

A: Yes, this is possible. In Tools.jar, we use the following code in order to open the URI in the browser:

public void onPostSingleTapConfirmed() {

mNextToolMode = ToolManager.e_pan;

if ( mLink != null ) {

Action a;

try {


a = mLink.getAction();

if ( a != null ) {

int at = a.getType();

if ( at == Action.e_URI ) {

Obj o = a.getSDFObj();

o = o.findObj(“URI”);

if ( o != null ) {

String uri = o.getAsPDFText();

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));




else if ( at == Action.e_GoTo ) {



mPDFView.invalidate(); //draw away the highlight.



catch (Exception e1) {


finally {





The code to open the browser is

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));


You should be able to modify this to achieve your goal once you have the source code of Tools.jar.

Update: Starting with version 6.1.0 of the Android PDFNet SDK, the Tools library is now shipped as an Android Library, and its source code can be found in the samples folder. The package does not include the Tools.jar anymore, and you now have the flexibility to include the source directly into your project or create a separate library for your projects.