@@ -23,21 +23,20 @@ This file is part of the iText (R) project.
2323package com .itextpdf .forms .form .element ;
2424
2525import com .itextpdf .commons .utils .DateTimeUtil ;
26- import com .itextpdf .forms .form .renderer .SigFieldRenderer ;
26+ import com .itextpdf .forms .form .renderer .SignatureAppearanceRenderer ;
2727import com .itextpdf .io .image .ImageData ;
2828import com .itextpdf .kernel .pdf .xobject .PdfFormXObject ;
2929import com .itextpdf .layout .properties .BoxSizingPropertyValue ;
3030import com .itextpdf .layout .properties .Property ;
3131import com .itextpdf .layout .properties .UnitValue ;
3232import com .itextpdf .layout .renderer .IRenderer ;
3333
34- import java .text .SimpleDateFormat ;
3534import java .util .Calendar ;
3635
3736/**
3837 * Extension of the {@link FormField} class representing a signature field in PDF.
3938 */
40- public class SigField extends FormField <SigField > {
39+ public class SignatureFieldAppearance extends FormField <SignatureFieldAppearance > {
4140 /**
4241 * Default paddings for the signature field.
4342 */
@@ -87,6 +86,7 @@ public class SigField extends FormField<SigField> {
8786 * Holds value of property signDate.
8887 */
8988 private Calendar signDate ;
89+ private boolean isSignDateSet = false ;
9090
9191 /**
9292 * The image that needs to be used for a visible signature.
@@ -130,11 +130,11 @@ public class SigField extends FormField<SigField> {
130130 private String idWithDots = null ;
131131
132132 /**
133- * Creates a new {@link SigField } instance.
133+ * Creates a new {@link SignatureFieldAppearance } instance.
134134 *
135135 * @param id the id.
136136 */
137- public SigField (String id ) {
137+ public SignatureFieldAppearance (String id ) {
138138 // We should support signing of existing fields with dots in name.
139139 super (id != null && id .contains ("." ) ? "" : id );
140140 if (id .contains ("." )) {
@@ -162,9 +162,9 @@ public RenderingMode getRenderingMode() {
162162 *
163163 * @param renderingMode the rendering mode.
164164 *
165- * @return this same {@link SigField } instance.
165+ * @return this same {@link SignatureFieldAppearance } instance.
166166 */
167- public SigField setRenderingMode (RenderingMode renderingMode ) {
167+ public SignatureFieldAppearance setRenderingMode (RenderingMode renderingMode ) {
168168 this .renderingMode = renderingMode ;
169169 return this ;
170170 }
@@ -183,9 +183,9 @@ public String getReason() {
183183 *
184184 * @param reason signing reason.
185185 *
186- * @return this same {@link SigField } instance.
186+ * @return this same {@link SignatureFieldAppearance } instance.
187187 */
188- public SigField setReason (String reason ) {
188+ public SignatureFieldAppearance setReason (String reason ) {
189189 this .reason = reason ;
190190 return this ;
191191 }
@@ -195,9 +195,9 @@ public SigField setReason(String reason) {
195195 *
196196 * @param reasonCaption new signing reason caption.
197197 *
198- * @return this same {@link SigField } instance.
198+ * @return this same {@link SignatureFieldAppearance } instance.
199199 */
200- public SigField setReasonCaption (String reasonCaption ) {
200+ public SignatureFieldAppearance setReasonCaption (String reasonCaption ) {
201201 this .reasonCaption = reasonCaption ;
202202 return this ;
203203 }
@@ -216,9 +216,9 @@ public String getLocation() {
216216 *
217217 * @param location new signing location.
218218 *
219- * @return this same {@link SigField } instance.
219+ * @return this same {@link SignatureFieldAppearance } instance.
220220 */
221- public SigField setLocation (String location ) {
221+ public SignatureFieldAppearance setLocation (String location ) {
222222 this .location = location ;
223223 return this ;
224224 }
@@ -228,9 +228,9 @@ public SigField setLocation(String location) {
228228 *
229229 * @param locationCaption new signing location caption.
230230 *
231- * @return this same {@link SigField } instance.
231+ * @return this same {@link SignatureFieldAppearance } instance.
232232 */
233- public SigField setLocationCaption (String locationCaption ) {
233+ public SignatureFieldAppearance setLocationCaption (String locationCaption ) {
234234 this .locationCaption = locationCaption ;
235235 return this ;
236236 }
@@ -249,9 +249,9 @@ public String getSignatureCreator() {
249249 *
250250 * @param signatureCreator new name of the application signing a document.
251251 *
252- * @return this same {@link SigField } instance.
252+ * @return this same {@link SignatureFieldAppearance } instance.
253253 */
254- public SigField setSignatureCreator (String signatureCreator ) {
254+ public SignatureFieldAppearance setSignatureCreator (String signatureCreator ) {
255255 this .signatureCreator = signatureCreator ;
256256 return this ;
257257 }
@@ -270,9 +270,9 @@ public String getContact() {
270270 *
271271 * @param contact new signing contact.
272272 *
273- * @return this same {@link SigField } instance.
273+ * @return this same {@link SignatureFieldAppearance } instance.
274274 */
275- public SigField setContact (String contact ) {
275+ public SignatureFieldAppearance setContact (String contact ) {
276276 this .contact = contact ;
277277 return this ;
278278 }
@@ -291,9 +291,9 @@ public ImageData getSignatureGraphic() {
291291 *
292292 * @param signatureGraphic image rendered.
293293 *
294- * @return this same {@link SigField } instance.
294+ * @return this same {@link SignatureFieldAppearance } instance.
295295 */
296- public SigField setSignatureGraphic (ImageData signatureGraphic ) {
296+ public SignatureFieldAppearance setSignatureGraphic (ImageData signatureGraphic ) {
297297 this .signatureGraphic = signatureGraphic ;
298298 return this ;
299299 }
@@ -312,9 +312,9 @@ public boolean isReuseAppearance() {
312312 *
313313 * @param reuseAppearance is an appearances reusing flag value to set.
314314 *
315- * @return this same {@link SigField } instance.
315+ * @return this same {@link SignatureFieldAppearance } instance.
316316 */
317- public SigField setReuseAppearance (boolean reuseAppearance ) {
317+ public SignatureFieldAppearance setReuseAppearance (boolean reuseAppearance ) {
318318 this .reuseAppearance = reuseAppearance ;
319319 return this ;
320320 }
@@ -333,9 +333,9 @@ public ImageData getImage() {
333333 *
334334 * @param image the background image.
335335 *
336- * @return this same {@link SigField } instance.
336+ * @return this same {@link SignatureFieldAppearance } instance.
337337 */
338- public SigField setImage (ImageData image ) {
338+ public SignatureFieldAppearance setImage (ImageData image ) {
339339 this .image = image ;
340340 return this ;
341341 }
@@ -357,9 +357,9 @@ public float getImageScale() {
357357 *
358358 * @param imageScale the scaling to be applied to the background image.
359359 *
360- * @return this same {@link SigField } instance.
360+ * @return this same {@link SignatureFieldAppearance } instance.
361361 */
362- public SigField setImageScale (float imageScale ) {
362+ public SignatureFieldAppearance setImageScale (float imageScale ) {
363363 this .imageScale = imageScale ;
364364 return this ;
365365 }
@@ -370,9 +370,9 @@ public SigField setImageScale(float imageScale) {
370370 * @param text the signature text identifying the signer. If null or not set
371371 * a standard description will be used.
372372 *
373- * @return this same {@link SigField } instance.
373+ * @return this same {@link SignatureFieldAppearance } instance.
374374 */
375- public SigField setDescription (String text ) {
375+ public SignatureFieldAppearance setDescription (String text ) {
376376 description = text ;
377377 return this ;
378378 }
@@ -393,9 +393,9 @@ public String getDescription(boolean generate) {
393393 *
394394 * @param signedBy name of the signer.
395395 *
396- * @return this same {@link SigField } instance.
396+ * @return this same {@link SignatureFieldAppearance } instance.
397397 */
398- public SigField setSignedBy (String signedBy ) {
398+ public SignatureFieldAppearance setSignedBy (String signedBy ) {
399399 this .signedBy = signedBy ;
400400 return this ;
401401 }
@@ -423,10 +423,11 @@ public java.util.Calendar getSignDate() {
423423 *
424424 * @param signDate new signature date.
425425 *
426- * @return this same {@link SigField } instance.
426+ * @return this same {@link SignatureFieldAppearance } instance.
427427 */
428- public SigField setSignDate (java .util .Calendar signDate ) {
428+ public SignatureFieldAppearance setSignDate (java .util .Calendar signDate ) {
429429 this .signDate = signDate ;
430+ this .isSignDateSet = true ;
430431 return this ;
431432 }
432433
@@ -444,9 +445,9 @@ public PdfFormXObject getBackgroundLayer() {
444445 *
445446 * @param n0 layer xObject.
446447 *
447- * @return this same {@link SigField } instance.
448+ * @return this same {@link SignatureFieldAppearance } instance.
448449 */
449- public SigField setBackgroundLayer (PdfFormXObject n0 ) {
450+ public SignatureFieldAppearance setBackgroundLayer (PdfFormXObject n0 ) {
450451 this .n0 = n0 ;
451452 return this ;
452453 }
@@ -466,9 +467,9 @@ public PdfFormXObject getSignatureAppearanceLayer() {
466467 *
467468 * @param n2 layer xObject.
468469 *
469- * @return this same {@link SigField } instance.
470+ * @return this same {@link SignatureFieldAppearance } instance.
470471 */
471- public SigField setSignatureAppearanceLayer (PdfFormXObject n2 ) {
472+ public SignatureFieldAppearance setSignatureAppearanceLayer (PdfFormXObject n2 ) {
472473 this .n2 = n2 ;
473474 return this ;
474475 }
@@ -490,15 +491,15 @@ public String getId() {
490491 */
491492 @ Override
492493 protected IRenderer makeNewRenderer () {
493- return new SigFieldRenderer (this );
494+ return new SignatureAppearanceRenderer (this );
494495 }
495496
496497 private String generateDescriptionText () {
497498 StringBuilder buf = new StringBuilder ();
498499 if (!signedBy .isEmpty ()) {
499500 buf .append ("Digitally signed by " ).append (signedBy );
500501 }
501- if (signDate != null ) {
502+ if (isSignDateSet ) {
502503 buf .append ('\n' ).append ("Date: " ).append (DateTimeUtil .dateToString (signDate ));
503504 }
504505 if (reason != null ) {
0 commit comments