Knowledge Base - How to build your first PDF reader for Android - v3.5x

Download the PDF version of this guide.

How to include RadaeePDF SDK in your project

From AndroidStudio.

  • Click on “File”->”Project Structure
  • Select “Modules” from the left of the pop-up configuration windows.
  • Click on “+” on top of the module list.
  • Choose “Import Gradle Project” and click on the next button in the pop-up dialog.
  • Press “Shift”+”Enter” and locate the ViewLib folder in “/RadaeePDF-Android-3.55.4/RadaeePDF-Android/PDFSample/
  • Click on the “finish” button and “OK” button to close all pop-up dialog/window. And wait for Gradle to finish the synchronization task.
  • Click on “File”->”Project Structure” to open the project structure configuration window again.
  • Select “Dependencies” from the left of the pop-up configuration windows.
  • Select [Your_App_Name] in the module list and click “+” on top of the dependency list on the right of the window.
  • Select “3 Module dependency” in the drop down list.
  • Check “ViewLib” in the pop-up dialog and click on the “OK ” button.
  • Click on “OK” buttons to close the project structure configuration window.

How to open your first PDF file

Before you can use most APIs from Radaee Core Lib, you have to activate it with your license. To do so, call the following method before everything starts.

import com.radaee.pdf.Global;

......

Global.Init([ApplicationContext], [License_Type], “[Company_Name]”, “[Mail]”, “[Serial]”);

In any layout resource file which you want to display the PDF file content.

Prepare a view for displaying the PDF document content.

Add a “com.radaee.reader.PDFLayoutView” element to wherever you want to display the document content. As following:

<com.radaee.reader.PDFLayoutView
android:id="@+id/[element_id]"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.radaee.reader.PDFLayoutView>

In Activity/Fragment classes which uses that layout file. First you should import following packages:

import com.radaee.pdf.Document;
import com.radaee.reader.PDFLayoutView;

Create document instance:

Document document = new Document();

Open document:

int ret = document.Open(“[Document_Path]”,”[Document_Password]”)
ProcessOpenResult(ret);

* [Document_Password]: set to “” if the document is not encrypted.

Process document open result:

private void ProcessOpenResult(int ret) {
switch( ret ) {
case -1:
//Failed: need input password
break;
case -2:
//Failed: unknown encryption
break;
case -3:
//Failed: damaged or invalid format
break;
case -10:
//Failed: access denied or invalid file path
break;
case 0:
//succeeded, move on
break;
default:
//Failed: unknown error
      break;
}
}

Get PDFLayoutView instance to display the document content:

PDFLayoutView view findViewById(R.id.[your_PDFLayoutView_Element_ID]);
view.PDFOpen(document, null);

 

 

Applies To

RadaeePDF SDK for Android

Related Articles

Create Cordova project with RadaeePDF-Cordova Plugin and RadaeePDF PDF reader

Details

Created : 2021-04-13 17:17:20, Last Modified : 2021-04-13 18:20:44