Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created April 9, 2025 21:13
Show Gist options
  • Save bjoerntx/78f642590a24eda1a31c75ab87deb304 to your computer and use it in GitHub Desktop.
Save bjoerntx/78f642590a24eda1a31c75ab87deb304 to your computer and use it in GitHub Desktop.
using TXTextControl;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
// Add a paragraph to the document
TXTextControl.Selection selection = new TXTextControl.Selection(0, 0);
selection.Text = "Hello, Office Open XML!";
// Set the paragraph format
selection.ParagraphFormat = new ParagraphFormat()
{
Alignment = HorizontalAlignment.Center,
};
// Set the font format
selection.FontSize = 240; // 240 twips = 12 pt
selection.FontName = "Lato";
selection.Bold = true;
// Apply the changes to the document
tx.Selection = selection;
// Save the document
tx.Save("results.docx", TXTextControl.StreamType.WordprocessingML);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment