package com.qoppa; import java.util.Vector; import android.app.Activity; import android.os.Bundle; import android.util.Log; import com.qoppa.android.pdf.form.AcroForm; import com.qoppa.android.pdf.form.FormField; import com.qoppa.android.pdf.form.TextField; import com.qoppa.android.pdfProcess.PDFDocument; import com.qoppa.android.pdfViewer.fonts.StandardFontTF; public class GetAndSetFieldsSample extends Activity { protected void onCreate(Bundle bundle) { super.onCreate(bundle); StandardFontTF.mAssetMgr = getAssets(); try { PDFDocument pdfDoc = new PDFDocument("/sdcard/form01.pdf", null); AcroForm form = pdfDoc.getAcroForm(); if(form == null) { Log.e("", "document does not contain form fields"); } else { //print current values of all textfields, set the value of "field1" Vector fieldList = form.getFieldList(); for(int i = 0; i < fieldList.size(); i++) { FormField field = (FormField) fieldList.get(i); if(field instanceof TextField) { Log.e("", field.getFieldName() + " " + ((TextField)field).getValue()); if(field.getFieldName().equals("field1") && field instanceof TextField) { ((TextField)field).setValue("value of field1"); } } } } } catch (Throwable t) { Log.e("", Log.getStackTraceString(t)); } } }