Hey so I am trying to use iText to get Strings added by the user and then add them to a fillable PDF which i imported into the app. However, my app does not recognize the pre-described strings I am adding. I will just add some snippets of the code so anyone can tell me whats wrong. Sorry if it may sound like a weak question, but this is my first time using iText.
This is my MainActivity.java
public class Main extends Activity {
EditText editText,editText2,editText3,editText4,editText5,editText6,editText7,editText8,editText9,editText10;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
final Customer newCustomer=new Customer();
try {
reader=new PdfReader(getResources().openRawResource(R.raw.pgform));
} catch (IOException e) {
e.printStackTrace();
}
findViewsById();
savebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Customer newCustomer=new Customer();
//newCustomer.one(editText.getText().toString());
//newCustomer.two(editText2.getText().toString());
OutputStream output=null;
try {
reader=new PdfReader(getResources().openRawResource(R.raw.pvgform));
} catch (IOException e) {
e.printStackTrace();
}
try {
PdfStamper stamper=new PdfStamper(reader,output);
AcroFields acroFields=stamper.getAcroFields();
acroFields.setField("fullnameorinitials",one);
acroFields.setField("agedob",two);
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
private void findViewsById(){
editText=(EditText)findViewById(R.id.editText);
editText2=(EditText)findViewById(R.id.editText2);
editText3=(EditText)findViewById(R.id.editText3);
editText4=(EditText)findViewById(R.id.editText4);
editText5=(EditText)findViewById(R.id.editText5);
editText6=(EditText)findViewById(R.id.editText6);
editText7=(EditText)findViewById(R.id.editText7);
editText8=(EditText)findViewById(R.id.editText8);
editText9=(EditText)findViewById(R.id.editText9);
editText10=(EditText)findViewById(R.id.editText10);
}
public class Customer{
String one=editText.getText().toString();
String two=editText2.getText().toString();
String three=editText3.getText().toString();
String four=editText4.getText().toString();
String five=editText5.getText().toString();
String six=editText6.getText().toString();
String seven=editText7.getText().toString();
String eight=editText8.getText().toString();
String nine=editText9.getText().toString();
String ten=editText10.getText().toString();
}
}
The line of code that seems to have issues are when I try to set the fields in the PDF with each editText in my app.
acroFields.setField("fullnameorinitials",one);
The error is on the string value (one). Please any kind of reproductive help is appreciated!