Android Question PDFium - Pdfview2 -Some issues -related to Library, as well as general



First, thanks to @DonManfred for the wonderful library, explained by him in this thread.
It is a very feature rich library. I have to explore it fully.

I used the example program from his dropbox folder and tested it out.
Works very well.

I have attached my modified example.
Here is the screenshot.

I wanted to make sure there are no problems in viewing non-English language PDFs also.
I have used a smaller PDF file to be within the attachment size limits.

There was no way to go directly to a desired page.
I added code to set the page number directly.
Now you can touch the page number label to invoke number input.

My questions now are,

The PDF file is first copied to DirInternal folder and used from there.
I could not use the file from DirAssets directly.
The viewer window is blank if "PDFView1.fromUri(File.DirInternal, "sample.pdf" is changed to PDFView1.fromUri(File.DirAssets,"sample.pdf"
In my music player projects, I am able to use the file from DirAssets.
What causes this difference in behavior?

After the file is copied to DirInternal folder, does it become accessible to the user?
Can it be copied to another folder in the phone, by the user ?

1b. I am completely ignorant about the physical locations in the phone corresponding to DirAssets, DirInternal, DirDefaultExternal, DirRootExternal, DirInternalCache, etc. I searched and could not find the answer I am looking for. If it is already answered, please lead me to the link.
Otherwise, I will open a new thread.

Let us say we are in page 20. I press the back key, The screen goes out of view.
I can come back to foreground in two ways.

Case a)
I go to recent apps screen and touch the app.
Now, I see that the Page Navigation buttons below the screen bottom border.

Case b)
I touch the app icon shortcut on the screen.
Now the navigation buttons are in the right position.

The horizontal and vertical anchoring are set appropriately for all those buttons. Why then, this problem.

I wanted to come back to the last read page on PAUSE and RESUME.
I stored the current page info in a variable in Activity_Pause and used it for going back to that page in Activity_Resume.
Still, on resume, it goes to the first page only.

To analyse it, I set the breakpoint in Resume. When I execute the statements one by one, it goes to the correct page.
When run without breakpoint, it doesn't.

I have observed similar behaviour while testing some other unrelated example also. I ignored it at that time.
Now that it is happening again, I thought it is time to clarify.



  • Pdfium Example-Modified by
    384.7 KB · Views: 260


Licensed User
Longtime User
I could not use the file from DirAssets directly.
No, it does not work with Assets. You need to copy it to File.DirInternal or any other path you have access to first. No way.
I wanted to come back to the last read page on PAUSE and RESUME.
You need to remember the last page visited when going into pause and use your remembered value of resume.

It has nothing to do with the Library. This is how android works.

Upvote 0