Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

Filling pdf makes it unable to after process it

More
9 years 8 months ago #11414 by fdelcaz
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
More
9 years 8 months ago #11415 by support
It could be an issue in the original pdf file or in our core lib.
May you provide your pdf file, please?
We will do some investigation.
More
9 years 8 months ago - 9 years 8 months ago #11416 by fdelcaz
I have tried with several different pdfs. This is one of them..
Last edit: 9 years 8 months ago by fdelcaz.
More
9 years 8 months ago #11417 by Davide
Hi,
sorry but there is no attachment.
If you want you can send it privately here : www.radaeepdf.com/support/tickets
More
9 years 8 months ago #11423 by Davide
Hi,
the problem in your code is that you call
Code:
p.FlatAnnots();

/**
* remove all annotations and display it as normal content on page.<br/>
* this method require premium license.
* @return true or false
*/


If you delete it, the pdf will be editable even after the fill.
More
9 years 8 months ago #11424 by fdelcaz
It throws the same error if I remove that line.. Anyway, I need it to be flattened
Time to create page: 0.725 seconds
Powered by Kunena Forum