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
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 );
}
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With