Hi:
I´m trying to fill a pdf form on background. This is the sample code
public void fillPdf(String rutaPdf, Map<String, String> valores, Activity actividad){
try{
Log.d("GXC", "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("GXC", "property: " + property);
p = m_doc.GetPage(currentPage);
p.ObjsStart();
Log.d("GXC", "Arranco " + p.toString());
Log.d("GXC", "cantidad de paginas: " + m_doc.GetPageCount());
Log.d("GXC", "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();
Boolean resultado = annot.SetEditText(valor);
}
}
currentPage++;
}
}
Boolean canSave = m_doc.CanSave();
boolean salvo = m_doc.Save();
m_doc.Close();
Log.d("GXC", "se supone que salvo " + salvo);
}catch(Exception ex){
String error = ex.getMessage();
}
}
Annot.SetEditText always returns false. page.getAnnotByName is also unable to retrieve the annotation so I´m looping over all the annotations in the page and see if it´s one of which I have to fill up... The library was updated on June 2016
We have a premium license that activates correctly. The document can be filled with adobe DC. Anyway, Im giving you a pair of example files I´m trying to fill.