Is there a way to add a button dynamically to clear a form field value?
(Refer to the attachment for the equivalent functionality in Acrobat Pro)
What I would like to do is to go thru each Radio Button group and create a button next to each radio button group called “Clear”. When the button is pressed, I would like to clear the radio button value (since it can’t be unclicked once a user clicks on it).
Here is the code I came up so far but it doesn’t seem like adding any buttons.
And I am not sure what to pass to “url” parameter of “AddSubmitBtn” method.
public void FillTemplate(string pdfTemplate)
{
string fname = Guid.NewGuid().ToString();
string fname1 = fname + “_1.pdf”;
fname = fname + “.pdf”;
string srcFile = Path.Combine(_context.Request.PhysicalApplicationPath,
string.Format(@"{0}{1}", TempOutput, fname1));
string destFile = Path.Combine(_context.Request.PhysicalApplicationPath,
string.Format(@"{0}{1}", TempOutput, fname));
if (!Directory.Exists(Path.GetDirectoryName(srcFile)))
Directory.CreateDirectory(Path.GetDirectoryName(srcFile));
var pdfFileStamp = new Kit.PdfFileStamp(pdfTemplate, srcFile);
var fileNumber = GetFileNumber(_clientId);
var formattedText = new Kit.FormattedText(
string.Format(“WL# {0}”, fileNumber),
System.Drawing.Color.Navy,
Kit.FontStyle.HelveticaOblique,
Kit.EncodingType.Winansi, true, 8F);
pdfFileStamp.AddFooter(formattedText, 10F, 10F, 10F);
pdfFileStamp.Close();
var fc = new Kit.FormFieldFacade { FontSize = 8F };
var fe = new Kit.FormEditor(srcFile, destFile) { Facade = fc };
fe.Save();
var form = new Kit.Form(destFile, _context.Response.OutputStream);
string[] fieldNames = form.FieldNames;
// Add “clear” button next to radio buttons
for (int i = 0; i < fieldNames.Length; i++)
{
if (form.GetFieldType(fieldNames[i]) != Kit.FieldType.Radio) continue;
Kit.FormFieldFacade facade = form.GetFieldFacade(fieldNames[i]);
fe.AddSubmitBtn(string.Format("{0}Clear", fieldNames[i]), facade.PageNumber, “Clear”, “”,
facade.Box.Top, facade.Box.Left, 40 ,20);
}
fe.Save();
FillForm(form);
form.Save();
}