Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 10, 2024 15:30
Show Gist options
  • Save bjoerntx/634cb76a8c9777e67bbe6f6edd1296ca to your computer and use it in GitHub Desktop.
Save bjoerntx/634cb76a8c9777e67bbe6f6edd1296ca to your computer and use it in GitHub Desktop.
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load("invoice.docx", TXTextControl.StreamType.WordprocessingML);
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings()
{
ImageSaveMode = TXTextControl.ImageSaveMode.SaveAsData
};
string doc = "";
tx.Save(out doc, TXTextControl.StringStreamType.HTMLFormat, saveSettings);
var images = GetImageBase64Strings(doc);
foreach (var image in images)
{
byte[] imageBytes = Convert.FromBase64String(image.Base64Content);
// write byte array to file
using (FileStream fs = new FileStream("image" + image.Extension, FileMode.Create))
{
fs.Write(imageBytes, 0, imageBytes.Length);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment