Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created October 25, 2024 13:03
Show Gist options
  • Save bjoerntx/5a0c8e4f1f037727896cb3d7d4c6f19c to your computer and use it in GitHub Desktop.
Save bjoerntx/5a0c8e4f1f037727896cb3d7d4c6f19c 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,
BackColor = System.Drawing.Color.LightGray,
Frame = Frame.BottomLine,
FrameLineColor = System.Drawing.Color.Red,
FrameStyle = FrameStyle.Double,
FrameLineWidth = 10
};
// Set the font format
selection.FontSize = 240; // 240 twips = 12 pt
selection.FontName = "Arial";
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