Hi.
I´m trying to copy, fill a pdf and then do another process with it using itextsharp in the backed. This is the function to fill it:
public void fillPdf(String rutaPdf, Map<String, String> valores, Activity actividad){
try{
Log.d("PdfFiller", "archivo a abrir: " + rutaPdf);
// obtengo el documento
Global.Init(actividad);
Document m_doc = new Document();
int ret = m_doc.Open(rutaPdf, "");
// Me quedo con el numero de paginas que tiene el documento
int i = m_doc.GetPageCount();
Page p;
int currentPage;
String property, value;
Map.Entry<String, String> entity;
Page.Annotation an;
// Recorro los diferentes valores
Iterator<Map.Entry<String, String>> it = valores.entrySet().iterator();
while (it.hasNext()) {
entity = it.next();
property = (String) entity.getKey();
value = (String) entity.getValue();
currentPage = 0;
an = null;
// Recorro las diferentes paginas
while (currentPage < i) {
Log.d("PdfFiller", "property: " + property);
p = m_doc.GetPage(currentPage);
p.ObjsStart();
Log.d("PdfFiller", "Arranco " + p.toString());
Log.d("PdfFiller", "cantidad de paginas: " + m_doc.GetPageCount());
Log.d("PdfFiller", "cantidad de anotaciones: " + p.GetAnnotCount());
int numAnotaciones = p.GetAnnotCount();
for(int j = 0; j<numAnotaciones; j++){
Page.Annotation annot = p.GetAnnot(j);
String name = annot.GetFieldFullName();
if(valores.containsKey(name)){
String valor = valores.get(name);
int type = annot.GetType();
int editType = annot.GetEditType();
int fieldType = annot.GetFieldType();
Boolean resultado = annot.SetEditText(valor);
Log.d("PdfFiller", "Resultado de guardar " + resultado);
}
}
p.FlatAnnots();
currentPage++;
}
}
Boolean canSave = m_doc.CanSave();
boolean salvo = m_doc.Save();
m_doc.Close();
Log.d("PdfFiller", "se supone que salvo " + salvo);
}catch(Exception ex){
String error = ex.getMessage();
}
}
This is the error that itextsharp throws when I do the other stuff with it:
Append mode requires a document without errors even if recovery was
possible.
If I dont fill it, it works. Also if I take the document after filling it, open it with adobe, save it and then continue the process.. it works. What can I do?
Thanks