Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 17, 2023 10:26
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/154c9a13e0aff7c3ddb0d0ee78e7b38b to your computer and use it in GitHub Desktop.
Save bjoerntx/154c9a13e0aff7c3ddb0d0ee78e7b38b to your computer and use it in GitHub Desktop.
public IActionResult Index()
{
byte[] bDocument = null;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Selection.FontSize = 800;
tx.Selection.Text = "Sample Form\r\n\r\n";
tx.Selection.FontSize = 400;
tx.Selection.Text = "Company name:\r\n";
// add a text form field
TXTextControl.TextFormField textFormField = new TXTextControl.TextFormField(1000);
textFormField.Name = "company_name";
textFormField.Text = "Text Control, LLC";
tx.FormFields.Add(textFormField);
tx.Selection.Text = "\r\n\r\nCountry:\r\n";
// add a text form field
TXTextControl.SelectionFormField selectionFormField = new TXTextControl.SelectionFormField(1000);
selectionFormField.Name = "company_country";
selectionFormField.Items = new string[] { "United States", "Germany", "Italy" };
selectionFormField.Editable = true;
tx.FormFields.Add(selectionFormField);
tx.InputPosition = new TXTextControl.InputPosition(-1, TXTextControl.TextFieldPosition.OutsideTextField);
tx.Selection.Text = "\r\n\r\nTaxable:\r\n";
// add a text form field
TXTextControl.CheckFormField checkFormField = new TXTextControl.CheckFormField(false);
checkFormField.Name = "company_taxable";
checkFormField.CheckedCharacter = 'X';
checkFormField.UncheckedCharacter = 'O';
tx.FormFields.Add(checkFormField);
// save in the internal format
tx.Save(out bDocument, TXTextControl.BinaryStreamType.AdobePDF);
tx.Save("test.pdf", TXTextControl.StreamType.AdobePDF);
}
return View(bDocument);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment