Pregunta

I have seen code here which will open a PDF file in a PDF viewer. Is it possible to modify the code to make the PDF viewer open the PDF at a specific page?

¿Fue útil?

Solución

No. You cannot control 3rd party application unless it gives this possibility.

Otros consejos

Yes You can open a Specific page in pdf file.

first of all create a global varble like

// give a defualt value

                int pageNumber=0;

                 //     secondly create   a button in search dilaoge to find exact page in activty.
                    btn.setOnClickListner(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    int position = 1;
                    String input = String.valueOf(textSearch.getText());
                    if (input != null && !input.equals("")) {
                        position = 



                  Integer.valueOf(String.valueOf(textSearch.getText()));
                    }

                    // assign globar var pageNumber to finding position
                    pageNumber = position-1;
                    textSearch.setText("");
                    alertDialog1.dismiss();
                }

// in Third Step just passed the pageNumber in defualt function.

       pdfViewr.from("Your uri String ").default(pageNumber).load();

Andrejs has recommended that I should modify an open source pdf viewer app. When I become more confident at Android programming I may attempt that. Meanwhile, I am following a different tack. I am storing images of the individual PDF pages as separate jpg files and using WebView / WebViewClient to display the individual pages. These can be zoomed and panned (as in a PDF Viewer) and it is easy to make my app move to the next or previous page when I touch the screen near the edge of the page.

for ezpdf reader:
add intent.putExtra("page", 110);

But ezpdf is quite old. So I recommend you to checkout my new opensource pdf viewer and annotator project:

https://github.com/KnIfER/PolymPic

    Intent it = new Intent(Intent.ACTION_VIEW)
        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        .putExtra("page", yourPageIndex)
        .setDataAndType(yourUri, "application/pdf");
    startActivity(it);

It's based on PDFium, which is fast and can even run pretty well on the android 4.4.

Open a PDF file to a specific page

To target an HTML link to a specific page in a PDF file, add #page=[page number] to the end of the link's URL.

For example, this HTML tag opens page 4 of a PDF file named myfile.pdf:

<A HREF="http://www.example.com/myfile.pdf#page=4">
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top