Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

PDFLayout zoom 8 years 10 months ago #10698

  • johannes.bolz
  • johannes.bolz's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
I'm trying to implement double-tap zoom using PDFLayoutView/PDFLayout. My code is as follows:
float zoom = layout.vGetZoom();
if (++zoom >= 5) {
    zoom = 1.f;
}
PDFLayout.PDFPos pdfPos = layout.vGetPos((int) x, (int) y);
layout.vZoomSet((int) x, (int) y, pdfPos, zoom);
The zoom level is set correctly. The problem is that the document zooms to completely arbitrary places, most of the times even to different pages. I'm using the latest library version 3.6.2b.

The x and y values are from the touch event.
Last edit: by johannes.bolz.
The topic has been locked.

PDFLayout zoom 8 years 10 months ago #10704

  • johannes.bolz
  • johannes.bolz's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
On further inspection, I could observe the following behaviour:
  • The zoom center computed from the touch event coordinates seems to get ignored. Instead, the view always zooms to a point on the upper left of the previous view centre.
  • On zoom out, the view jumps to a different page on multi-page documents.

This is my view hierarchy:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"  >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ViewSwitcher
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ProgressBar
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"/>
            <com.radaee.reader.PDFLayoutView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center">
            </com.radaee.reader.PDFLayoutView>
        </ViewSwitcher>
    
    ....
  </FrameLayout>
    ....
</android.support.v4.widget.DrawerLayout>
Last edit: by johannes.bolz.
The topic has been locked.

PDFLayout zoom 8 years 10 months ago #10707

  • johannes.bolz
  • johannes.bolz's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
Btw, it would be nice to have at least some documentation on basic things like implementing zoom. The API isn't self-explanatory at all.
Last edit: by johannes.bolz.
The topic has been locked.

PDFLayout zoom 8 years 10 months ago #10708

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
here a workaround for the double tap problem..
int counter = 0;

@Override
    public boolean OnPDFDoubleTapped(PDFLayout layout, float x, float y) {
		counter++;
		if(counter % 2 == 0) {
			float currZoom = layout.vGetZoom();
			float zoomTo = ++currZoom;
			if (currZoom >= 5) {
				zoomTo = 1.0f;
			}
			final PDFLayout.PDFPos pdfPos = layout.vGetPos((int) x, (int) y);
			layout.vZoomSet((int) x, (int) y, pdfPos, zoomTo);

			m_view.invalidate();
		}
		return true;
    }

Our developers are working to solve it definitively.

You can find some documentation on basic things here : www.radaeepdf.com/support/knowledge-base
The topic has been locked.

PDFLayout zoom 8 years 10 months ago #10711

  • johannes.bolz
  • johannes.bolz's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
Hmm, this doesn't fix the problem of the document zooming into unexpected locations. Please note that I'm already using a different workaround of OnPDFDoubleTapped() being called from the wrong SimpleGestureListener methods. This is a different issue.

Also, I disagree that the knowledge base covers all basic things. There's no word on how to implement zoom, for instance. Also, the PDFLayout.vZoom* methods aren't documented either. It's pure guesswork for consumers of your API. The documentation is really lacking, and as others have pointed out, should be improved.
Last edit: by johannes.bolz.
The topic has been locked.

PDFLayout zoom 8 years 10 months ago #10714

  • johannes.bolz
  • johannes.bolz's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
I've noticed that also PDFLayout.vSetPos() has no effect at all, regardless of the x, y and PDFPos parameters passed. So I guess something's broken within the internal document center calculation.
Last edit: by johannes.bolz.
The topic has been locked.
  • Page:
  • 1
  • 2
Powered by Kunena Forum