Android版PDF阅读器API阅读器、Android、PDF、API

2023-09-06 03:42:38 作者:她的雀斑

可能重复:   的code 实例来实现PDF阅读器

Possible Duplicate: Example of code to implement a PDF reader

有一个免费的PDF阅读器,我可以用我的应用程序?

我要寻找一个PDF阅读器,可以搜索,高亮文本,查看用户想要的页面,并没有改变PDF文件的内容。就像Adobe Reader的,但对于Android可以实现为一个应用程序。

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.

您可以联系我到一个同样的问题或源$ C ​​$ C。

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

编辑:

我已经发现了这个问题,Pdf浏览器的API /库Android应用示例code?,但我认为他在寻找一个器。这个问题为Android PDF阅读器库,我读了,查看PDF格式应该是本身以及用于该解决方案是使用外部应用

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.

如果我使用外部应用程序,我希望外部应用程序接受PDF文件路径,页面查看和关键字搜索编程,但我认为,外部应用程序不会让我这样做。

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.

推荐答案

使用下面$ C $下阅读PDF使用PDFViewer.jar库,它会解决你的问题。

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

First.java

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

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.

 
精彩推荐