Page 1 of 1

Form Field Date and how to set the formatting

Posted: Sun Jun 18, 2017 5:30 pm
by prime clinical systems
Hi, I've looked everywhere I can think of and need to know how to specifiy a form field as type date, to use the drop down, and set the format for the date.
I found the sample code to detect if a field already has date formatting, like this, since the flag for date TFF_Date is still not working this method was required:

Dim FField As IPXC_FormField
Dim Annot As PDFXEditCtl.IPXC_Annotation
FField.Flags = TFF_Date
Set Annot = FField.Widget(0)
Me.PDF.Doc.CoreDoc.CosDocument.LockDocument
Dim AA As PDFXEditCtl.IPXS_PDFVariant
Dim F As PDFXEditCtl.IPXS_PDFVariant
Set AA = Annot.PDFObject.Dict_Get("AA")
Set F = AA.Dict_Get("F")
Dim sS As String
Dim nAtom As Long
nAtom = Me.p_pxsInst.StrToAtom("S")
sS = F.Dict_GetStringA(nAtom, "")
If sS = "JavaScript" Then
Dim sJS As String
sJS = F.Dict_GetString("JS", "")
If InStr(sJS, "AFDate_Format") Then
'type is date, this works fine for existing field
End If
End If
Me.PDF.Doc.CoreDoc.CosDocument.UnlockDocument
Set Annot = Nothing

But when trying to set this "F" object with the format, well it does not exist after creating a form field ("Text1") from scratch, just the AA object exists, so a code sample to set the formatting
"AFDate_Format("mm/dd/yyyy")" to this is what I need, as I can only get this far:
Dim FField As IPXC_FormField
Dim Annot As PDFXEditCtl.IPXC_Annotation
Set FField = Me.PDF.Doc.CoreDoc.AcroForm.GetFieldByName("Text1")
FField.Flags = TFF_Date
Set Annot = FField.Widget(0)
Me.PDF.Doc.CoreDoc.CosDocument.LockDocument
Dim AA As PDFXEditCtl.IPXS_PDFVariant
Dim F As PDFXEditCtl.IPXS_PDFVariant
Set AA = Annot.PDFObject.Dict_Get("AA")
Set F = AA.Dict_Get("F") 'this line throws error that object AA.Dict_Get("F") does not exist

Similarly, if I want to have a Numeric Field, or format a text box for SS# etc, how would I do that as well?

ce

Re: Form Field Date and how to set the formatting

Posted: Mon Jun 19, 2017 8:18 am
by Sasha - Tracker Dev Team
Hello Clifford,

Replied you here:
https://forum.pdf-xchange.com/ ... 22#p114173

Cheers,
Alex