It won't work if you opened the stamper in append mode, you don't call 
MarkUsed().

Paulo
  ----- Original Message ----- 
  From: djdjdj 
  To: [email protected] 
  Sent: Monday, October 11, 2010 8:03 PM
  Subject: Re: [iText-questions] Clearing a Digital Signature Field's value.



  Hello,

  I have found Paulo's updated code to clear a digital signature. 
  Unfortunately, I cannot update my itextsharp library at this time (using
  version 4.1.6).  So, I have attempted to accomplish the task using a
  variation of his code posted to the Acrofields.cs file as an update.  Again,
  I'm calling this code inside of my project not inside of the Acrofields
  file.  My version of ClearSignatureField is being passed the fieldName to be
  unsigned the same as the developer updated version from this weekend.

  My Code:

  public Boolean ClearSignatureField(string fieldName)
  try
  {
  ArrayList list = this.Stamper.AcroFields.GetSignatureNames();
  if(!list.Contains(fieldName))
  {
  return false;
  }

  AcroFields.Item item = this.Stamper.AcroFields.GetFieldItem(fieldName);
  ClearSignatureDictionary((PdfDictionary)item.merged[0]);
  ClearSignatureDictionary((PdfDictionary)item.widgets[0]);
  ClearSignatureDictionary((PdfDictionary)item.values[0]);
  return true;
  }

  catch(Exception ex)
  {
  throw new Exception("An error has occurred: ", ex);
  }
  }

  private static void ClearSignatureDictionary(PdfDictionary dic)
  {
  dic.Remove(PdfName.AP);
  dic.Remove(PdfName.AS);
  dic.Remove(PdfName.V);
  dic.Remove(PdfName.DV);
  dic.Remove(PdfName.SV);
  dic.Remove(PdfName.FF);
  dic.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
  }


  This code appears to do the same as the code posted this weekend...however
  the code still does not unsign the signature field.

  Link to clear signature update posted this weekend:
  
http://itext.svn.sourceforge.net/viewvc/itext/trunk/src/core/com/itextpdf/text/pdf/AcroFields.java?r1=4557&r2=4599&pathrev=4599
  Clear Digital Signature Code 

  Again, my goal is not to question someone else's code but more to gain an
  understanding of what I might be doing wrong.

  Thanks ahead of time to Paulo or any of the other developers who might
  reply.
  -- 
  View this message in context: 
http://itext-general.2136553.n4.nabble.com/Clearing-a-Digital-Signature-Field-s-value-tp2966934p2990404.html
  Sent from the iText - General mailing list archive at Nabble.com.

  ------------------------------------------------------------------------------
  Beautiful is writing same markup. Internet Explorer 9 supports
  standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
  Spend less time writing and  rewriting code and more time creating great
  experiences on the web. Be a part of the beta today.
  http://p.sf.net/sfu/beautyoftheweb
  _______________________________________________
  iText-questions mailing list
  [email protected]
  https://lists.sourceforge.net/lists/listinfo/itext-questions

  Many questions posted to this list can (and will) be answered with a 
reference to the iText book: http://www.itextpdf.com/book/
  Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to