Flyingkiwi Flyingkiwi - 14 days ago 6
Java Question

Simple questions regarding integrating Android PDF Library

I am trying to integrate this into my app: https://github.com/jblough/Android-Pdf-Viewer-Library

I am just looking for an expansion on the readme from about step four as I new to Java and don't fully understand what is required.


  • (Step four) Do I just need to add PdfViewerActivity.java to my "src/com.example.app/"?

  • (Step five) Where to I put the default drawables and layout settings, the same same place I call the intent intent?

  • Is the path to my assets folder simply... "/assets/something.pdf"

  • What do I need to add to my manifest.xml manifest.xml?


Answer

Seeing as you have added the JAR to your build path you can just extend the class given. Assuming you import the appropriate files in your imports.

public class myPdfActivity extends PdfViewerActivity
{
    //Do something with your activity.
}

The default drawables would go in your class I've just defined above for you. When it comes to drawing the particular parts of the PDF view you the code will call something like myPdfActivity.getZoomOutImageResource() to get the zoom out image. This means you can override the method to replace it with your own custom zoom out image.

public class myPdfActivity extends PdfViewerActivity
{
     public int getPreviousPageImageResource() { return R.drawable.left_arrow; }
     public int getNextPageImageResource() { return R.drawable.right_arrow; }
     public int getZoomInImageResource() { return R.drawable.zoom_in; }
     public int getZoomOutImageResource() { return R.drawable.zoom_out; }
     public int getPdfPasswordLayoutResource() { return R.layout.pdf_file_password; }
     public int getPdfPageNumberResource() { return R.layout.dialog_pagenumber; }
     public int getPdfPasswordEditField() { return R.id.etPassword; }
     public int getPdfPasswordOkButton() { return R.id.btOK; }
     public int getPdfPasswordExitButton() { return R.id.btExit; }
     public int getPdfPageNumberEditField() { return R.id.pagenum_edit; }
}

Your manifest might need permissions to access the file system or to read files, I'm not too good with permissions so maybe someone else can give you a better answer on this one.