Click here to Skip to main content
15,903,523 members
Home / Discussions / C#
   

C#

 
GeneralRe: Virtual - Ovverride -> Drive me Crazy ... help pliz! Pin
Emanuele Bonin6-Feb-15 8:54
Emanuele Bonin6-Feb-15 8:54 
GeneralRe: Virtual - Ovverride -> Drive me Crazy ... help pliz! Pin
OriginalGriff6-Feb-15 9:09
mveOriginalGriff6-Feb-15 9:09 
QuestionHow to solve ? Pin
Member 114321975-Feb-15 23:40
Member 114321975-Feb-15 23:40 
AnswerRe: How to solve ? Pin
BillWoodruff5-Feb-15 23:44
professionalBillWoodruff5-Feb-15 23:44 
AnswerRe: How to solve ? Pin
V.5-Feb-15 23:54
professionalV.5-Feb-15 23:54 
AnswerRe: How to solve ? Pin
Keith Barrow6-Feb-15 0:55
professionalKeith Barrow6-Feb-15 0:55 
Questionhow to add an edit button on first row in gridview Pin
upendra shahi5-Feb-15 21:27
upendra shahi5-Feb-15 21:27 
AnswerRe: how to add an edit button on first row in gridview Pin
Richard MacCutchan5-Feb-15 22:00
mveRichard MacCutchan5-Feb-15 22:00 
QuestionECC implementation Pin
Member 114315045-Feb-15 19:14
Member 114315045-Feb-15 19:14 
AnswerRe: ECC implementation Pin
DelphiCoder5-Feb-15 20:24
DelphiCoder5-Feb-15 20:24 
Questionmultilanguage support by windows application using C# Pin
Member 114314135-Feb-15 18:58
Member 114314135-Feb-15 18:58 
AnswerRe: multilanguage support by windows application using C# Pin
V.5-Feb-15 20:15
professionalV.5-Feb-15 20:15 
QuestionTable Adapter Pin
Member 114310155-Feb-15 12:49
Member 114310155-Feb-15 12:49 
SuggestionRe: Table Adapter Pin
Richard MacCutchan5-Feb-15 21:59
mveRichard MacCutchan5-Feb-15 21:59 
QuestionReorganise algorithm Pin
sebyku5-Feb-15 11:27
sebyku5-Feb-15 11:27 
AnswerRe: Reorganise algorithm Pin
DelphiCoder5-Feb-15 17:24
DelphiCoder5-Feb-15 17:24 
QuestionImport C function from DLL with passing FILE stream pointer as parameter Pin
Miloš Križan5-Feb-15 9:26
Miloš Križan5-Feb-15 9:26 
AnswerRe: Import C function from DLL with passing FILE stream pointer as parameter Pin
Richard Andrew x645-Feb-15 14:41
professionalRichard Andrew x645-Feb-15 14:41 
QuestionSocket IAsyncResult - Catch SocketError Pin
sheldons5-Feb-15 8:47
sheldons5-Feb-15 8:47 
SuggestionRe: Socket IAsyncResult - Catch SocketError Pin
Richard MacCutchan5-Feb-15 21:56
mveRichard MacCutchan5-Feb-15 21:56 
GeneralRe: Socket IAsyncResult - Catch SocketError Pin
sheldons6-Feb-15 5:59
sheldons6-Feb-15 5:59 
GeneralRe: Socket IAsyncResult - Catch SocketError Pin
Richard MacCutchan6-Feb-15 6:01
mveRichard MacCutchan6-Feb-15 6:01 
QuestionWord document converted to image is showing transparent background Pin
Member 103642244-Feb-15 22:27
professionalMember 103642244-Feb-15 22:27 
Hi

I have converted a word document into an image using c# code , the image created using code is showing transparent background in some image format and showing black back ground in some formates



C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
using Microsoft.Office.Core;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Word;
using System.Drawing.Printing;

   string startupPath = @"C:\Users\infoobjects\Desktop\";
            string filename1 = "Test1.doc";
            var docPath = Path.Combine(startupPath, filename1);
            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();

            test.messageclass.MessageFilter.Register();

            app.Visible = true;

            var doc = app.Documents.Open(docPath);

            doc.ShowGrammaticalErrors = false;
            doc.ShowRevisions = false;
            doc.ShowSpellingErrors = false;

            if (!Directory.Exists(startupPath + "\\" + filename1.Split('.')[0]))
            {
                Directory.CreateDirectory(startupPath + "\\" + filename1.Split('.')[0]);
            }

            //Opens the word document and fetch each page and converts to image
            foreach (Microsoft.Office.Interop.Word.Window window in doc.Windows)
            {
                foreach (Microsoft.Office.Interop.Word.Pane pane in window.Panes)
                {
                    pane.View.DisplayBackgrounds = true;

                    for (var ii = 1; ii <= pane.Pages.Count; ii++)
                    {
                        var page = pane.Pages[ii];
                        var bits = page.EnhMetaFileBits;
                        var target = Path.Combine(startupPath + "\\" + filename1.Split('.')[0], string.Format("{1}_page_{0}", ii, filename1.Split('.')[0]));

                        try
                        {
                            using (var ms = new MemoryStream((byte[])(bits)))
                            {
                                var image = System.Drawing.Image.FromStream(ms);
                                var pngTarget = Path.ChangeExtension(target, "Wmf");
                                image.Save(pngTarget, System.Drawing.Imaging.ImageFormat.Wmf);
                            }

                        }
                        catch (System.Exception ex)
                        { }
                    }
                }
            }
            doc.Close(Type.Missing, Type.Missing, Type.Missing);
            app.Quit(Type.Missing, Type.Missing, Type.Missing);
            test.messageclass.MessageFilter.Revoke();



SQL
I have also tried to recreate the same image with diff background, some results
I would appreciate any feedback as to where I'm going wrong...

AnswerRe: Word document converted to image is showing transparent background Pin
BillWoodruff5-Feb-15 0:58
professionalBillWoodruff5-Feb-15 0:58 
AnswerRe: Word document converted to image is showing transparent background Pin
DelphiCoder5-Feb-15 17:50
DelphiCoder5-Feb-15 17:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.