Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 8, 2021 20:24
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/d7d743e064183e8cba22090102ee93d6 to your computer and use it in GitHub Desktop.
Save bjoerntx/d7d743e064183e8cba22090102ee93d6 to your computer and use it in GitHub Desktop.
using (ServerTextControl tx = new ServerTextControl())
{
tx.Create();
// create a new selection range
Selection range = new Selection();
range.Bold = true;
range.FontSize = 400;
range.Text = "This is a new paragraph\r\n";
// insert the range to the document
tx.Selection = range;
// add a table
tx.Tables.Add(5, 5, 10);
foreach (TableCell cell in tx.Tables.GetItem(10).Cells)
{
cell.Text = cell.Row.ToString() + ", " + cell.Column.ToString();
}
// save the document as DOCX
tx.Save("test.docx", StreamType.WordProcessingML);
// save the document as PDF
tx.Save("test.pdf", StreamType.AdobePDF);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment