Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 28, 2024 12:59
Show Gist options
  • Save bjoerntx/8ba2d99737a6e8d0dbac5aa5e16b5586 to your computer and use it in GitHub Desktop.
Save bjoerntx/8ba2d99737a6e8d0dbac5aa5e16b5586 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Drawing.Imaging;
using System.Drawing;
using TXTextControl;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load("test.docx", TXTextControl.StreamType.WordprocessingML);
ArrayList inputImages = new ArrayList();
foreach (Page page in tx.GetPages())
{
MemoryStream image = new MemoryStream();
Bitmap mf = page.GetImage(100, TXTextControl.Page.PageContent.All);
mf.Save(image, ImageFormat.Png);
inputImages.Add(image);
}
// save images as files
int i = 0;
foreach (MemoryStream ms in inputImages)
{
FileStream file = new FileStream("image" + i.ToString() + ".png", FileMode.Create, FileAccess.Write);
ms.WriteTo(file);
file.Close();
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment