2

The mupdf is a good open source pdf reader. It meets almost all of my requirements except it can't reader pdf from right-to-left. Does anybody have any idea about it?

Actually my understanding for RTL is that I can navigate to the last page first. Then go from there. Buy my question is how am I suppose to know a pdf is a RTL one?

Bagusflyer
  • 12,675
  • 21
  • 96
  • 179

2 Answers2

4

MuPDF does not support RTL. You need to start the book from the last page and make minor changes MuPDFPageAdapter getView method as follows:

public View getView(int pos, View convertView, ViewGroup parent) {

    final int position;
    if(mDirection == DIRECTION_RTL)
        position = mCore.countPages() - pos - 1;
    else
        position = pos;
    /** getView remaining code **/
}

Basically reversing the page order. Index 0 become pageCount - 1 and the last page becomes 0.

You can set the current page to the book's last page as follows:

 mDocView.setDisplayedViewIndex(mCore.countPages() - 1);

I've uploaded a working sample here: https://github.com/mardawi/MuPDF-Android-RTL

Ammar
  • 1,148
  • 9
  • 15
0

There isn't any way to know the reading direction of a PDF file. It seems like what you want is not right-to-left but back to front, or bottom to top.

KenS
  • 30,202
  • 3
  • 34
  • 51
  • What I know is I can create a pdf file in InDesign for RTL and then when I open the pdf in Acrobat Reader, it works. That means there must be a way to tell Acrobat Reader, the pdf is different so that the reader can open it correctly. Am I right? – Bagusflyer Nov 24 '13 at 03:55
  • I don't think so. You can create a PDF file, and in that PDF you can put a ViewerPreferences directive to open at a specific page, which some viewers may honour, others will not. But that's nothing to do with its reading order, you could just as easily have it open at page 2 as the last page. – KenS Nov 24 '13 at 10:23
  • @bagusflyer Have you got any answer regarding Right to left navigation ? Bcoz i am also working on mupdf lib and i want to open arabic pdf so if you found any thing then please help me – Harsh Trivedi May 13 '14 at 11:41