2016-08-17 2 views
0

En créant 2 PdfSignatureFormFields de la même manière, j'ai obtenu 2 champs affichés différemment dans Adobe Reader: un avec une petite image indiquant un champ de signature et l'autre sans indication.Pourquoi l'apparence de 2 champs de signature créés de manière identique est-elle différente dans IText 7?

J'utilise un appel setNextRenderer cellulaire pour créer ces champs comme montré dans le prochain extrait:

static private Cell createSignatureFieldCell(PdfDocument document, String name, String label, PdfFont font) { 
    Cell cell = new Cell(); 
    cell.setHeight(100); 
    cell.setNextRenderer(new SignatureCellEvent(cell,name,label)); 
    return cell; 
    } 

    static private class SignatureCellEvent extends CellRenderer 
    { 
    protected String fieldname; 
    protected String labelcontent; 
    public SignatureCellEvent(Cell modelElement, String fieldname,String label) { 
    super(modelElement); 
    this.fieldname=fieldname; 
    this.labelcontent=label; 
    } 

    @Override 
    public void draw(DrawContext drawContext) 
    { 
    float x = getOccupiedAreaBBox().getLeft() ; 
    float y = (getOccupiedAreaBBox().getTop() + getOccupiedAreaBBox().getBottom())/2; 
    PdfDocument doc=drawContext.getDocument(); 
    PdfAcroForm form=PdfAcroForm.getAcroForm(doc, true); 
    Rectangle rect = new Rectangle(x, y - 10, 50, 50); 
    PdfSignatureFormField field = PdfFormField.createSignature(doc,rect); 
    field.setFieldName(fieldname); 
    field.setRequired(true); 
    form.addField(field); 

    } 
} 
+0

S'il vous plaît partager le pdf en question. – mkl

+0

Voici ... https: //1drv.ms/b/s! AkF6t4TavwMvchwL3wL2HXZKPuM –

Répondre

0

Désolé pour la gêne occasionnée!

J'ai trouvé la raison de ce comportement:

Il se produit lorsqu'il ya une collision de nom de domaine dans le document. Dans mon cas, un champ créé dynamiquement avait le même nom qu'un champ statique préexistant.

Cordialement,

David L.