Converting images from word document into bitmap object

早过忘川 提交于 2019-11-29 07:39:02
aclalex

Resolved in this post: https://stackoverflow.com/a/7937590/1071212 It's a problem with STAThread:

Thread thread = new Thread([Method]);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();

Try this.

foreach (InlineShape shape in d.InlineShapes)             
{ 
    if (shape != null)
    {
        shape.Range.Select(); 
        d.ActiveWindow.Selection.Copy();
        Bitmap bitmap = new Bitmap(Clipboard.GetImage());
    }
}
Skier In Summer

There's two Clipboard.

Usually we'd use System.Windows.Forms.Clipboard, but it sucks.

Use System.Windows.Clipboard instead, just add PresentationCore to your references.

(in my case, C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client\PresentationCore.dll)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!