Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Filling pdf makes it unable to after process it 7 years 5 months ago #11414

  • fdelcaz
  • fdelcaz's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Filling pdf makes it unable to after process it 7 years 5 months ago #11415

  • support
  • support's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 692
  • Thank you received: 59
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.

Please Log in or Create an account to join the conversation.

Filling pdf makes it unable to after process it 7 years 5 months ago #11416

  • fdelcaz
  • fdelcaz's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 0
I have tried with several different pdfs. This is one of them..

Please Log in or Create an account to join the conversation.

Last edit: by fdelcaz.

Filling pdf makes it unable to after process it 7 years 5 months ago #11417

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
sorry but there is no attachment.
If you want you can send it privately here : www.radaeepdf.com/support/tickets

Please Log in or Create an account to join the conversation.

Filling pdf makes it unable to after process it 7 years 5 months ago #11423

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
the problem in your code is that you call
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.

Please Log in or Create an account to join the conversation.

Filling pdf makes it unable to after process it 7 years 5 months ago #11424

  • fdelcaz
  • fdelcaz's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 0
It throws the same error if I remove that line.. Anyway, I need it to be flattened

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum