Q: How can I implement a fit to height view using Qoppa’s Android qPDF Toolkit and the PDF Viewer QPDFNotesView?

A: We don’t have a predefined way of fitting the document to its height within the viewer. You can calculate the appropriate scale and set it on the viewer. See sample code below.

package com.sample;
 
import com.qoppa.android.pdfProcess.PDFDocument;
import com.qoppa.notes.QPDFNotesView;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
 
/**
 * Sample for fitting the page to the height of the viewer. *
 */
public class FitHeightSampleActivity extends Activity 
{
	public QPDFNotesView notes;
 
	protected void onCreate(Bundle bundle)
	{
		super.onCreate(bundle);
 
		notes = new QPDFNotesView(this);
		notes.setActivity(this);
 
		Button fitHeight = new Button(this);
		fitHeight.setText("FitHeight");
		fitHeight.setOnClickListener(new OnClickListener() {
 
			@Override
			public void onClick(View v)
			{
				fitToHeight();
			}
		});
		notes.getToolbar().addView(fitHeight);
 
		setContentView(notes);
 
	}
 
	private void fitToHeight()
	{
		PDFDocument doc = notes.getDocument();
		float pageHeight = doc.getPage(0).getDisplayHeight();
		float scale = notes.getHeight() / pageHeight;
		notes.setScale(scale);
	}
 
}