Converting images from word document into bitmap object

前端 未结 3 2029
天涯浪人
天涯浪人 2020-12-18 05:57

As per project requirement we need to convert images from word document into bitmap object. To achieve this we tried to convert inlineshape object from Microsoft.Office.Inte

相关标签:
3条回答
  • 2020-12-18 06:26

    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)

    0 讨论(0)
  • 2020-12-18 06:29

    Try this.

    foreach (InlineShape shape in d.InlineShapes)             
    { 
        if (shape != null)
        {
            shape.Range.Select(); 
            d.ActiveWindow.Selection.Copy();
            Bitmap bitmap = new Bitmap(Clipboard.GetImage());
        }
    }
    
    0 讨论(0)
  • 2020-12-18 06:34

    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();
    
    0 讨论(0)
提交回复
热议问题