Field Formatting

The PDF Creator .NET Library enables you to create secure PDF documents on the fly and to view, print and process existing PDF documents. If you have any questions about PDF Creator .Net, please post them here.
Post Reply
BrianSA
Posts: 2
Joined: Fri Apr 27 2007

Field Formatting

Post by BrianSA »

I am currently evaluating PDF Creator for .NET and I have a question about fields on a PDF.

When using PDF Creator as a control on a .NET form, the Format attribute of a field object seems to have no effect on what can be entered into that field. If I set the Format attribute of the field to "mm/dd/yyyy" I am still able to enter things such as "aaa". I have tried adjusting some things (such as setting the DataType for the field, adjusting the Format string) to get it to work and they don't seem to do anything. If I use your .exe to set the formatting of a field, it works in the .exe but when I use the .NET control in my application it seems to do nothing. Is there another attribute of the field that needs to be set? Would this be the supported way to validate user input into fields? I am probably missing something here but I am not sure what it could be.

Also, do you have examples of valid format strings for things such as numbers, dates, and strings?
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I tried this and it worked. You need to set the datatype to date and the field format to whatever format you want.

Which version of the PDF Creator.Net are you using?

I am adding here a VBA code that creates a Field and set its data tpe to 'Date'

Code: Select all

'Create a Field
    '==============
    
    .CreateObject acObjectTypeField, "Field1"
    
    ' get a reference to the object that we just created
    Set obj = .GetObjectByName("Field1")
    If obj Is Nothing Then
        MsgBox "Unable to find object"
        Exit Sub
    End If
    
    'Set the attributes of Field1
    With obj
        .Attribute("Left") = 1200
        .Attribute("Top") = 8600
        .Attribute("Right") = 4000
        .Attribute("Bottom") = 9200
        .Attribute("Text") = "= 2 + 3"
        .Attribute("Value") = "= 2 + 3"
        .Attribute("BackColor") = "296BF7"    'Orange, 200 red
        .Attribute("BorderWidth") = 2
        .Attribute("DataType") = 3
        .Attribute("Format") = "mm/dd/yyyy"
    End With
BrianSA
Posts: 2
Joined: Fri Apr 27 2007

Post by BrianSA »

Hi,

I am using PDF Creator.Net version 3.0.
acPDFCreator.Net.dll version is 3.0.2626.35598
acPDFCreatorLib.Net.dll version is 3.0.2626.35555

I translated the VBA code you added to VB .Net code and tried it. When the PDF loaded in the control, it said "!error", as expected. However, the field still allowed input of "abc" without reporting it as an error. If I type "=2+3" back into the field I get "!error" again. It seems like the field is recognizing "abc" as fitting the format string for "mm/dd/yyyy".
Post Reply