Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active September 22, 2015 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/1b2463754bc41279b76f to your computer and use it in GitHub Desktop.
Save bjoerntx/1b2463754bc41279b76f to your computer and use it in GitHub Desktop.
/********************************************************
* ProcessCheckboxFields method
* desc: Sets the Unicode characters for all
* checkbox fields
* parameter: document - the document in the internal
* Text Control format
********************************************************/
private byte[] ProcessCheckboxFields(byte[] document)
{
// create a new temporary ServerTextControl
using (TXTextControl.ServerTextControl tx =
new TXTextControl.ServerTextControl())
{
// load the document
tx.Create();
tx.Load(document,
TXTextControl.BinaryStreamType.InternalUnicodeFormat);
// loop through all ApplicationFields
foreach (IFormattedText textPart in tx.TextParts)
{
foreach (ApplicationField field in textPart.ApplicationFields)
{
if ((field.TypeName != "FORMCHECKBOX"))
return null;
// create a new adapter field
FormCheckBox checkboxField = new FormCheckBox(field);
// select the field to change the font name
textPart.Selection.Start = checkboxField.Start - 1;
textPart.Selection.Length = checkboxField.Length;
textPart.Selection.FontName = "Arial Unicode MS";
// set the text (state)
checkboxField.Text =
checkboxField.Checked == true ? CHECKED : UNCHECKED;
}
}
tx.Save(out document, BinaryStreamType.InternalUnicodeFormat);
return document;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment