5

Possible Duplicate:
Example of code to implement a PDF reader

Is there a Free PDF Viewer that I can use for my Application?

I am looking for a PDF Viewer that can search, highlight text, view the page that user wants, and without altering the contents of the PDF file. Just like Adobe Reader but for Android that can be implemented to a Application.

You can link me to a same question or source code.

EDIT:

I have found this question "Pdf viewer api/library for android app sample code?" but I think his looking for a Reader. this question "pdf viewer library for android" I read that to view pdf it should be Natively and the solution for that is to use External Applications.

If I use external application, I want the external application accepts PDF Filepath, Page to view, and Keyword for search programmatically but i think external application wont let me do that.

3
  • 1
    When you ran a search for this on the Internet, what did you find? Commented Jan 12, 2013 at 1:12
  • You might want to use an intent. stackoverflow.com/questions/2883355/… Commented Jan 12, 2013 at 1:31
  • you can view pdf in webview.. we have an options for that . did you tried with that ? Commented Jan 12, 2013 at 5:36

2 Answers 2

2

Use Below Code for Read PDF using PDFViewer.jar library, it will solve your problem.

First.java

public class First extends ListActivity { String[] pdflist; File[] imagelist; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); File images = Environment.getExternalStorageDirectory(); imagelist = images.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return ((name.endsWith(".pdf"))); } }); pdflist = new String[imagelist.length]; for (int i = 0; i < imagelist.length; i++) { pdflist[i] = imagelist[i].getName(); } this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, pdflist)); } protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); String path = imagelist[(int) id].getAbsolutePath(); openPdfIntent(path); } private void openPdfIntent(String path) { try { final Intent intent = new Intent(First.this, Second.class); intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } } } 

Second.java

public class Second extends PdfViewerActivity { @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); } 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; } } 

And Declared Both Activities into your manifest file.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Dipak. Do you have any link of the PDFViewer.jar? I have found some but I do not know what's the right one.
I have found the link but the Goto Page does not work. its Force closes.
0

If you want an API, I don't think there are any free ones. I recently had to build one into an app for my employer, we ended up having a choice of 3 paid libraries, the cheapest of which was around $1K/app. If you just want to launch it in an external app, you can download a free one and launch the view intent on the file.

2 Comments

I think external PDF viewer apps chooses its own PDF File (Browsing the SDcard Files). I want my Application to send the Filepath/Page to View/Keyword to the PDF Viewer that I will use but I think external apps won't let me do that?
It ought to, send it the path in the intent.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.