Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Radaee Pdf reader sdk

I am developing PDF reader application. I am using Radaee PDF reader sdk. I am trying this sdk to open a PDF from the asset in android. I need some help for this. I am using some code like:

    m_vFiles = new PDFGridView(this, null);
    m_vFiles.PDFSetRootPath("/mnt");
    m_vFiles.setOnItemClickListener(this);
    setContentView(m_vFiles);

But it is taking the path of sd card and showing all the pdf file.

One user has used this sdk. https://chat.stackoverflow.com/users/1503155/lazy-ninja

like image 869
Biplab De Avatar asked Jun 12 '14 06:06

Biplab De


2 Answers

To open a pdf from assets using RadaeePDF, you can do the following into your activity:

private PDFReader m_vPDF = null;
private Document doc = new Document();
private PDFAssetStream stream = new PDFAssetStream();

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    Global.Init(this);

    m_vPDF = new PDFReader(this);
    doc.Close();
    stream.open(getAssets(), "test.pdf");

    int ret = doc.OpenStream(stream, null);
        //int ret = doc.Open("/sdcard/test1.pdf", null);
        switch( ret )
        {
            case -1://need input password
                finish();
                break;
            case -2://unknown encryption
                finish();
                break;
            case -3://damaged or invalid format
                finish();
                break;
            case -10://access denied or invalid file path
                finish();
                break;
            case 0://succeeded, and continue
                break;
            default://unknown error
                finish();
                break;
        }

    m_vPDF.open(doc);

    setContentView( m_vPDF );
}
like image 62
Nermeen Avatar answered Oct 09 '22 02:10

Nermeen


There is another way to open a pdf from any external path

        m_doc.Close();          
        int ret = m_doc.Open( book_path[string path of pdf], null );
        switch( ret )
            {
                case -1://need input password
                    finish();
                    break;
                case -2://unknown encryption
                    finish();
                    break;
                case -3://damaged or invalid format
                    finish();
                    break;
                case -10://access denied or invalid file path
                    finish();
                    break;
                case 0://succeeded, and continue
                    break;
                default://unknown error
                    finish();
                    break;
            }

        m_doc.SetCache( Global.tmp_path + "/temp.dat" );//set temporary cache for editing

        System.out.println(">>>>>>>>path"+m_doc.GetPageCount());
        m_reader.PDFOpen(m_doc, false, this);
like image 4
Biplab De Avatar answered Oct 09 '22 04:10

Biplab De