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?
6 Answers
No. You cannot control 3rd party application unless it gives this possibility.

- 27,428
- 2
- 75
- 95
-
Agreed. The third party app would need to have a proprietary field in the intent filter used to designate this. But it's not in the general standard. You'd have to look for a specific app on their device to open the pdf and open it to the correct page. – Brayden May 30 '12 at 20:11
-
Thanks, Andrejs and Brayden. Are there any PDF Viewer apps that include such an intent? (My app is for my use only, so if there is such a PDF Viewer I could get it.) – prepbgg May 31 '12 at 17:15
-
There is a few of open source pdf viewers, like [andpdf](http://sourceforge.net/projects/andpdf/) or [apv](http://code.google.com/p/apv/). You could modify the sources to your needs :) – Andrejs Cainikovs May 31 '12 at 17:19
-
That's probably a bit beyond my capabilities! But thanks for the suggestion. – prepbgg May 31 '12 at 19:18
Yes there is a way to open a specific page in a pdf file
- Inside Main Activity
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), pdfActivity.class);
intent.putExtra("pageno", 5); // add this to pass the page number
startActivity(intent);
}
});
- Inside Pdf Activity
pdfView.fromAsset("SAMPLE_FILE.pdf")
.defaultPage(getIntent().getIntExtra("pageno",0)) // this is used to scroll to the page required
.enableAnnotationRendering(true)
.scrollHandle(new DefaultScrollHandle(this))
.load();
If you don't want it to pass through intent
pdfView.fromAsset("SAMPLE_FILE.pdf")
.defaultPage(65) // Write the number of the page
.enableAnnotationRendering(true)
.scrollHandle(new DefaultScrollHandle(this))
.load();

- 61
- 7
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();
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.

- 712
- 7
- 13
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.

- 3,564
- 10
- 39
- 51
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">

- 8,127
- 1
- 27
- 17
-
This may be correct for different context but the question is tagged android and pdf-viewer so this answer is irrelevant and not helpful. – Alex May 09 '18 at 21:06