Perhaps I'm a bit impatient and I should wait for an answer for a longer time, but I just had the need to get this done...
Using the great but hardly documented DocX library for C# I was able to solve that task and create a small console application that extracts all images from a document into a folder. According to my short tests, all images are in PNG format when pasted from clipboard.
The following code works for .docx
files only, which is ok for me.
using System;
using System.IO;
using Novacode;
namespace BmpFromDocx
{
static class Program
{
static void Main(string[] args)
{
if (args.Length < 2)
{
PrintHelp();
return;
}
var doc = DocX.Load(args[0]);
var index = 0;
foreach (var image in doc.Images)
{
var stream = image.GetStream(FileMode.Open, FileAccess.Read);
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
File.WriteAllBytes(Path.Combine(args[1], $"image{index}.png"), buffer);
index++;
}
}
private static void PrintHelp()
{
Console.WriteLine("Usage: BmpFromDocx <docx> <output path>");
}
}
}