Field Formatting

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v8.x)  /  Display Thread

DynamicPDF Merger for .NET (v8.x) Forum

 Apr 20 2017 1:04 PM
I am trying to fill an acro form using C#.

public static void Main(string[] args)
{
    var document = new MergeDocument(INPUT_PATH + PDF_FOLDER + BASE + ".pdf");
    document.Form.Fields["effective_date"].Value = DateTime.Now.ToString();
    document.Draw(OUTPUT_PATH + BASE + ".pdf");
}

The effective date acro form field is set under the formatting as a date with the format mm/dd/yyyy.  However, the output pdf is set with the exact text of DateTime.Now.ToString() including the time.  I am also running into similar issues with numbers not getting formatted appropriately as well.

Is using the formatting functionality on the acro form fields supported?  If so, please let me know what I need to update.

Thanks.
 Apr 20 2017 4:52 PM
Posted by a ceTe Software moderator
Hello,

It is not possible to activate the format functionality available in the form field when setting the field value programmatically. However, you can use the string format functionality available in .NET to format the string as needed before assigning it to the form field.

document.Form.Fields["effective_date"].Value = DateTime.Now.ToString("mm/dd/yyyy");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 8:12 AM.