Created
June 10, 2024 15:30
-
-
Save bjoerntx/634cb76a8c9777e67bbe6f6edd1296ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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