Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

android - Using muPDF with curl/flip effect

I'm using muPDF for reading PDFs in my application. I don't like its default animation (Switching horizontally). In other side i found this brilliant library for curl effect on images, and this project for flip-flap effect on layouts.

In curl sample project, in CurlActivity, all of data are images and set in PageProvider like this:

private class PageProvider implements CurlView.PageProvider {

    // Bitmap resources.
    private int[] mBitmapIds = { R.drawable.image1, R.drawable.image2,
            R.drawable.image3, R.drawable.image4};

And use it like this:

private CurlView mCurlView;
mCurlView = (CurlView) findViewById(R.id.curl);
mCurlView.setPageProvider(new PageProvider());

And CurlView extends from GLSurfaceView and implements View.OnTouchListener, CurlRenderer.Observer

But in muPDF if i'm not mistaken, data are in core object. core is instance of MuPDFCore. And using it like this:

MuPDFReaderView mDocView;
MuPDFView pageView = (MuPDFView) mDocView.getDisplayedView();
mDocView.setAdapter(new MuPDFPageAdapter(this, this, core));

MuPDFReaderView extends ReaderView and ReaderView extends AdapterView<Adapter> and implements GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener, Runnable.

My question is where how can I using curl effect in muPDF? Where should I get pages one by one and converting them to bitmaps? and then changing aspects of the Adapter in muPDF to CurlView.

In flip-flap sample project, in FlipHorizontalLayoutActivity (I like this effect too), we have these:

private FlipViewController flipView;
flipView = new FlipViewController(this, FlipViewController.HORIZONTAL);
flipView.setAdapter(new TravelAdapter(this));
setContentView(flipView);

And FlipViewController extends AdapterView<Adapter>, and data set in TravelAdapter that extends BaseAdapter.

No one has done this before? Or can help me to do that?!

EDIT:

I found another good open source PDF reader with curl effect called fbreaderJ. its developer says "An additional module that allows to open PDF files in FBReader. Based on radaee pdf library."

I got confused! cause radaeepdf is closed source and downloadable project is just for demo and inserted username and password is for this package. People want to change whole fbreader project such as package name.

Another issue for make me confused is where is this additional module source code?!

Anyway, if someone wants to help me, fbreader has done it very well.

EDIT:

I talked to Robin Watts, who developed muPDF (or one of developers), and he said:

Have you read platform/android/ClassStructure.txt ? MuPDF is primarily a C library. The standard api is therefore a C one. Rather than exposing that api exactly as is to Java (which would be the nicest solution, and something that I've done some work on, but have not completed due to lack of time), we've implemented MuPDFCore to wrap up just the bits we needed. MuPDFCore handles opening a PDF file, and getting bitmaps from it to be used in views. or rather, MuPDFCore returns 'views', not 'bitmaps'. If you need bitmaps, then you're going to need to make changes in MuPDFCore.

There are too many errors when changing a little part of MuPDFReaderView class. I get confused! These are related to each other.

Please answer more precisely.

EDIT:

And bounty has expired.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If the muPDF does not support rendering to a bitmap, you have no other choice than rendering to a regular view and take a screen dump to a bitmap like this:

View content = findViewById(R.id.yourPdfView);
Bitmap bitmap = content.getDrawingCache();

Then use this bitmap as input to your other library.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...