@@ -23,21 +23,20 @@ This file is part of the iText (R) project.
23
23
package com .itextpdf .forms .form .element ;
24
24
25
25
import com .itextpdf .commons .utils .DateTimeUtil ;
26
- import com .itextpdf .forms .form .renderer .SigFieldRenderer ;
26
+ import com .itextpdf .forms .form .renderer .SignatureAppearanceRenderer ;
27
27
import com .itextpdf .io .image .ImageData ;
28
28
import com .itextpdf .kernel .pdf .xobject .PdfFormXObject ;
29
29
import com .itextpdf .layout .properties .BoxSizingPropertyValue ;
30
30
import com .itextpdf .layout .properties .Property ;
31
31
import com .itextpdf .layout .properties .UnitValue ;
32
32
import com .itextpdf .layout .renderer .IRenderer ;
33
33
34
- import java .text .SimpleDateFormat ;
35
34
import java .util .Calendar ;
36
35
37
36
/**
38
37
* Extension of the {@link FormField} class representing a signature field in PDF.
39
38
*/
40
- public class SigField extends FormField <SigField > {
39
+ public class SignatureFieldAppearance extends FormField <SignatureFieldAppearance > {
41
40
/**
42
41
* Default paddings for the signature field.
43
42
*/
@@ -87,6 +86,7 @@ public class SigField extends FormField<SigField> {
87
86
* Holds value of property signDate.
88
87
*/
89
88
private Calendar signDate ;
89
+ private boolean isSignDateSet = false ;
90
90
91
91
/**
92
92
* The image that needs to be used for a visible signature.
@@ -130,11 +130,11 @@ public class SigField extends FormField<SigField> {
130
130
private String idWithDots = null ;
131
131
132
132
/**
133
- * Creates a new {@link SigField } instance.
133
+ * Creates a new {@link SignatureFieldAppearance } instance.
134
134
*
135
135
* @param id the id.
136
136
*/
137
- public SigField (String id ) {
137
+ public SignatureFieldAppearance (String id ) {
138
138
// We should support signing of existing fields with dots in name.
139
139
super (id != null && id .contains ("." ) ? "" : id );
140
140
if (id .contains ("." )) {
@@ -162,9 +162,9 @@ public RenderingMode getRenderingMode() {
162
162
*
163
163
* @param renderingMode the rendering mode.
164
164
*
165
- * @return this same {@link SigField } instance.
165
+ * @return this same {@link SignatureFieldAppearance } instance.
166
166
*/
167
- public SigField setRenderingMode (RenderingMode renderingMode ) {
167
+ public SignatureFieldAppearance setRenderingMode (RenderingMode renderingMode ) {
168
168
this .renderingMode = renderingMode ;
169
169
return this ;
170
170
}
@@ -183,9 +183,9 @@ public String getReason() {
183
183
*
184
184
* @param reason signing reason.
185
185
*
186
- * @return this same {@link SigField } instance.
186
+ * @return this same {@link SignatureFieldAppearance } instance.
187
187
*/
188
- public SigField setReason (String reason ) {
188
+ public SignatureFieldAppearance setReason (String reason ) {
189
189
this .reason = reason ;
190
190
return this ;
191
191
}
@@ -195,9 +195,9 @@ public SigField setReason(String reason) {
195
195
*
196
196
* @param reasonCaption new signing reason caption.
197
197
*
198
- * @return this same {@link SigField } instance.
198
+ * @return this same {@link SignatureFieldAppearance } instance.
199
199
*/
200
- public SigField setReasonCaption (String reasonCaption ) {
200
+ public SignatureFieldAppearance setReasonCaption (String reasonCaption ) {
201
201
this .reasonCaption = reasonCaption ;
202
202
return this ;
203
203
}
@@ -216,9 +216,9 @@ public String getLocation() {
216
216
*
217
217
* @param location new signing location.
218
218
*
219
- * @return this same {@link SigField } instance.
219
+ * @return this same {@link SignatureFieldAppearance } instance.
220
220
*/
221
- public SigField setLocation (String location ) {
221
+ public SignatureFieldAppearance setLocation (String location ) {
222
222
this .location = location ;
223
223
return this ;
224
224
}
@@ -228,9 +228,9 @@ public SigField setLocation(String location) {
228
228
*
229
229
* @param locationCaption new signing location caption.
230
230
*
231
- * @return this same {@link SigField } instance.
231
+ * @return this same {@link SignatureFieldAppearance } instance.
232
232
*/
233
- public SigField setLocationCaption (String locationCaption ) {
233
+ public SignatureFieldAppearance setLocationCaption (String locationCaption ) {
234
234
this .locationCaption = locationCaption ;
235
235
return this ;
236
236
}
@@ -249,9 +249,9 @@ public String getSignatureCreator() {
249
249
*
250
250
* @param signatureCreator new name of the application signing a document.
251
251
*
252
- * @return this same {@link SigField } instance.
252
+ * @return this same {@link SignatureFieldAppearance } instance.
253
253
*/
254
- public SigField setSignatureCreator (String signatureCreator ) {
254
+ public SignatureFieldAppearance setSignatureCreator (String signatureCreator ) {
255
255
this .signatureCreator = signatureCreator ;
256
256
return this ;
257
257
}
@@ -270,9 +270,9 @@ public String getContact() {
270
270
*
271
271
* @param contact new signing contact.
272
272
*
273
- * @return this same {@link SigField } instance.
273
+ * @return this same {@link SignatureFieldAppearance } instance.
274
274
*/
275
- public SigField setContact (String contact ) {
275
+ public SignatureFieldAppearance setContact (String contact ) {
276
276
this .contact = contact ;
277
277
return this ;
278
278
}
@@ -291,9 +291,9 @@ public ImageData getSignatureGraphic() {
291
291
*
292
292
* @param signatureGraphic image rendered.
293
293
*
294
- * @return this same {@link SigField } instance.
294
+ * @return this same {@link SignatureFieldAppearance } instance.
295
295
*/
296
- public SigField setSignatureGraphic (ImageData signatureGraphic ) {
296
+ public SignatureFieldAppearance setSignatureGraphic (ImageData signatureGraphic ) {
297
297
this .signatureGraphic = signatureGraphic ;
298
298
return this ;
299
299
}
@@ -312,9 +312,9 @@ public boolean isReuseAppearance() {
312
312
*
313
313
* @param reuseAppearance is an appearances reusing flag value to set.
314
314
*
315
- * @return this same {@link SigField } instance.
315
+ * @return this same {@link SignatureFieldAppearance } instance.
316
316
*/
317
- public SigField setReuseAppearance (boolean reuseAppearance ) {
317
+ public SignatureFieldAppearance setReuseAppearance (boolean reuseAppearance ) {
318
318
this .reuseAppearance = reuseAppearance ;
319
319
return this ;
320
320
}
@@ -333,9 +333,9 @@ public ImageData getImage() {
333
333
*
334
334
* @param image the background image.
335
335
*
336
- * @return this same {@link SigField } instance.
336
+ * @return this same {@link SignatureFieldAppearance } instance.
337
337
*/
338
- public SigField setImage (ImageData image ) {
338
+ public SignatureFieldAppearance setImage (ImageData image ) {
339
339
this .image = image ;
340
340
return this ;
341
341
}
@@ -357,9 +357,9 @@ public float getImageScale() {
357
357
*
358
358
* @param imageScale the scaling to be applied to the background image.
359
359
*
360
- * @return this same {@link SigField } instance.
360
+ * @return this same {@link SignatureFieldAppearance } instance.
361
361
*/
362
- public SigField setImageScale (float imageScale ) {
362
+ public SignatureFieldAppearance setImageScale (float imageScale ) {
363
363
this .imageScale = imageScale ;
364
364
return this ;
365
365
}
@@ -370,9 +370,9 @@ public SigField setImageScale(float imageScale) {
370
370
* @param text the signature text identifying the signer. If null or not set
371
371
* a standard description will be used.
372
372
*
373
- * @return this same {@link SigField } instance.
373
+ * @return this same {@link SignatureFieldAppearance } instance.
374
374
*/
375
- public SigField setDescription (String text ) {
375
+ public SignatureFieldAppearance setDescription (String text ) {
376
376
description = text ;
377
377
return this ;
378
378
}
@@ -393,9 +393,9 @@ public String getDescription(boolean generate) {
393
393
*
394
394
* @param signedBy name of the signer.
395
395
*
396
- * @return this same {@link SigField } instance.
396
+ * @return this same {@link SignatureFieldAppearance } instance.
397
397
*/
398
- public SigField setSignedBy (String signedBy ) {
398
+ public SignatureFieldAppearance setSignedBy (String signedBy ) {
399
399
this .signedBy = signedBy ;
400
400
return this ;
401
401
}
@@ -423,10 +423,11 @@ public java.util.Calendar getSignDate() {
423
423
*
424
424
* @param signDate new signature date.
425
425
*
426
- * @return this same {@link SigField } instance.
426
+ * @return this same {@link SignatureFieldAppearance } instance.
427
427
*/
428
- public SigField setSignDate (java .util .Calendar signDate ) {
428
+ public SignatureFieldAppearance setSignDate (java .util .Calendar signDate ) {
429
429
this .signDate = signDate ;
430
+ this .isSignDateSet = true ;
430
431
return this ;
431
432
}
432
433
@@ -444,9 +445,9 @@ public PdfFormXObject getBackgroundLayer() {
444
445
*
445
446
* @param n0 layer xObject.
446
447
*
447
- * @return this same {@link SigField } instance.
448
+ * @return this same {@link SignatureFieldAppearance } instance.
448
449
*/
449
- public SigField setBackgroundLayer (PdfFormXObject n0 ) {
450
+ public SignatureFieldAppearance setBackgroundLayer (PdfFormXObject n0 ) {
450
451
this .n0 = n0 ;
451
452
return this ;
452
453
}
@@ -466,9 +467,9 @@ public PdfFormXObject getSignatureAppearanceLayer() {
466
467
*
467
468
* @param n2 layer xObject.
468
469
*
469
- * @return this same {@link SigField } instance.
470
+ * @return this same {@link SignatureFieldAppearance } instance.
470
471
*/
471
- public SigField setSignatureAppearanceLayer (PdfFormXObject n2 ) {
472
+ public SignatureFieldAppearance setSignatureAppearanceLayer (PdfFormXObject n2 ) {
472
473
this .n2 = n2 ;
473
474
return this ;
474
475
}
@@ -490,15 +491,15 @@ public String getId() {
490
491
*/
491
492
@ Override
492
493
protected IRenderer makeNewRenderer () {
493
- return new SigFieldRenderer (this );
494
+ return new SignatureAppearanceRenderer (this );
494
495
}
495
496
496
497
private String generateDescriptionText () {
497
498
StringBuilder buf = new StringBuilder ();
498
499
if (!signedBy .isEmpty ()) {
499
500
buf .append ("Digitally signed by " ).append (signedBy );
500
501
}
501
- if (signDate != null ) {
502
+ if (isSignDateSet ) {
502
503
buf .append ('\n' ).append ("Date: " ).append (DateTimeUtil .dateToString (signDate ));
503
504
}
504
505
if (reason != null ) {
0 commit comments