jblough / Android-Pdf-Viewer-Library

DEPRECATED - Pdf Viewer library for Android
657 stars 329 forks source link

How to use this library with Fragment #36

Open csharsha opened 9 years ago

csharsha commented 9 years ago

Hi, How can I use this library with Fragment. I have gone through the source code, current code only supports only Activity. Please help me to achieve the same with Fragment.

Thanks

supareek commented 9 years ago

Did you find a solution to this?

csharsha commented 9 years ago

I just tried to modify the source code for fragment, but pdf content is not displayed instead a black screen is displayed in fragment area.

destrike commented 8 years ago

Anyone solved this problem?

Kshitiz1208 commented 8 years ago

Since "this" doesnt work in a fragment we have to use "getActivity()" instead. Similarly "getFilesDir()" has to be preceded with "getActivity()". I got my code working through this.

Here is the code to use with fragment -

Intent intent = new Intent(getActivity(), PdfViewer.class); intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, getActivity().getFilesDir() + "/chapter.pdf"); startActivity(intent);

lhoracek commented 7 years ago

I'm using this inside fragment without any problems. using PDFView in my fragments layout and then calling the load from assets as described in sample in my onViewCreated method