TrueCH
TrueCH

Reputation: 501

View to display PDFPage

I'm implementing some kind of magazine viewer (to browse pages like in android gallery), which content is taken from pdf file; pages must be zoomable. At first, I've tried to work with separate pictures from that pdf. I borrowed ImageViewTouch and ImageViewTouchViewPager. It works well, but I couldn't keep more than 3-4 big pics in memory (OutOfMemory error) , so that implementation is not suitable for me. (I need 5 big pictures in memory plus memory for about 50 little pictures to show table of contents)

So I've decided to work with pdf file. I've tried to display pdf with PdfViewer.jar, but this implementation with PDFViewerActivity is missing pictures or text when you try to zoom in or zoom out.

Can you advice me how to display my pdf like in android gallery? Or, at least, tell me, please, if you know views, which can display PDFPage with zooming option?

Edited: I do not need to open side app to view pdf. I need to dosplay it in my app.

Upvotes: 1

Views: 239

Answers (1)

Ankur Aggarwal
Ankur Aggarwal

Reputation: 2220

You can give this a try:

public static void openPdf(Context context, String filename) {
File targetFile = new File(filename);
Uri targetUri = Uri.fromFile(targetFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(targetUri, "application/pdf");
try {
    context.startActivity(intent);
} catch (ActivityNotFoundException act ) {
    Toast.makeText(context, "Please install a pdf reader to view help",Toast.LENGTH_LONG).show();
}

}

Upvotes: 1

Related Questions