Click here to Skip to main content
16,011,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i am converting html document into plain text using the below funcion

private void TextFileConvertion(string strsource, string strtarget)
        {
            // Use for the parameter whose type are not known or  
            // say Missing
            object Unknown = Type.Missing;
            //Creating the instance of Word Application
            Word.Application newApp = new Word.Application();
            newApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
            try
            {
                lblProgress.Text = "Converting " + strsource + " into Text file is under process.";
                Application.DoEvents();
                // specifying the Source & Target file names
                object Source = strsource;
                object Target = strtarget;
                 
                // Source document open here
                // Additional Parameters are not known so that are  
                // set as a missing type
                newApp.Documents.Open(ref Source, ref Unknown,
                     ref Unknown, ref Unknown, ref Unknown,
                     ref Unknown, ref Unknown, ref Unknown,
                     ref Unknown, ref Unknown, ref Unknown,
                     ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown);
                // Specifying the format in which you want the output file 
                object format = Word.WdSaveFormat.wdFormatText;
                //Changing the format of the document
                newApp.ActiveDocument.SaveAs(ref Target, ref format,
                        ref Unknown, ref Unknown, ref Unknown,
                        ref Unknown, ref Unknown, ref Unknown,
                        ref Unknown, ref Unknown, ref Unknown,
                        ref Unknown, ref Unknown, ref Unknown,
                        ref Unknown, ref Unknown);
            }
            catch (Exception ex)
            {
                ZoniacLogger.Error("Exception : " + ex.Message + " Stack Trace : " + ex.StackTrace);
            }
            finally
            {
                if (newApp != null)
                {
                    // for closing the application
                    newApp.Quit(ref Unknown, ref Unknown, ref Unknown);
                    newApp = null;
                }
            }
        }

while executing above code , i get a warning like this :

"Linked style sheets are supported only in web format files. By
saving to this format , all links to style sheets would be lost"

After i click "continue" ,it converts the html document into text file.
How can i avoid such warnings through the program ?
Can anybody help me to overcome this problem. waiting for solution.

regards
kumaran
Posted
Updated 17-Mar-10 1:40am
v3

You could strip the style sheets from the html before you do the conversion ? If the end document is plain text, no formatting, you could consider just stripping the HTML tags in your own code. If it's an RTF, that doesn't work, obviously.
 
Share this answer
 
Please don't use the 'answer' button to post more questions. A stylesheet is a HTML tag with a known format. you can use reguar expressions to find them in your html text and then remove them from there.
 
Share this answer
 
Hi Christian Graus,

Can you show how to strip the style sheets from html

Can you give example code to strip the style sheet from html

waiting for ur replay

regards
kumaran
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900