This is a sample program showing how to add a button for flattening all annotations on all pages in a PDF document using Qoppa’s Android annotating view, QPDFNotesView and Qoppa’s android toolkit, qPDF Toolkit.

import com.qoppa.android.pdf.PDFException;
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;
public class FlattenActivity extends Activity
{
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{		
		super.onCreate(savedInstanceState);
		final QPDFNotesView notes = new QPDFNotesView(this);
		notes.setActivity(this);
		Button flatten = new Button(this);
		flatten.setText("flatten");
		flatten.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v)
			{
				PDFDocument doc = notes.getDocument();
				int pageCount = doc.getPageCount();
				for (int i = 0; i < pageCount; i++)
				{
					try
					{
						doc.getPage(i).flattenAnnotations(true);
					}
					catch (PDFException e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				notes.refreshTiles();
			}
		});
		notes.getToolbar().addView(flatten);
		setContentView(notes);
	}
}

FlattenActivity
FlattenActivity
FlattenActivity.java
1.2 KiB
199 Downloads
Details