使用Microsoft对象库的Word to HTML Converter [英] Word to HTML Converter using Microsoft object Library

查看:101
本文介绍了使用Microsoft对象库的Word to HTML Converter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够将word doc转换为html.
但是对于标题和图像会创建一个单独的文件夹.对于标题会在该文件夹中创建一个单独的html文件.
它不包含在主要内容中.
如何包含带有主要内容的标题和图像.

我的代码是

I am able to convert word doc to html.
But for the header and images a seperate folder is created.For header a seperate html file is created in that folder.
Its not included with the main content.
How is it possible to include header and images with main content.

My code is

object fltDocFormat = WdSaveFormat.wdFormatHTML;

Microsoft.Office.Interop.Word.Document adoc = app.Documents.Open(ref FilePath, ref missing, ref isReadonly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

adoc.Activate(); 

adoc.SaveAs(ref FileHtmPath, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing, 
ref missing, ref embedTrueTypeFont, ref saveNativePicFormat, ref missing, ref missing, ref missing, ref missing, ref missing, 
ref missing, ref missing);

adoc.Close(ref prompt, ref missing, ref missing);


请帮帮我.
在此先感谢.


Please help me.
Thanks in Advance.

推荐答案

请这样做
protected void B1(object s, EventArgs e)
{
if (FileUpload1.HasFile)
{

string FTSI = @"c:\temp\doc\";
string FP = folder_to_save_in + FileUpload1.FileName;

FileUpload1.SaveAs(FP);


Word.ApplicationClass wordApplication = new Word.ApplicationClass();


object oNO = System.Reflection.Missing.Value;
object oFP = FP;
Word.Document doc = wordApplication.Documents.Open(ref oFP,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO);


string newfilename = folder_to_save_in + FileUpload1.FileName.Replace(".doc", ".html");
object oNF = newfilename;
object oFR = Word.WdSaveFormat.wdFormatHTML;
object oEN = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
object oEN = Word.WdLineEndingType.wdCRLF;

wordApplication.ActiveDocument.SaveAs(ref oNF, ref oFR, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO, ref oNO,
ref oNO, ref oNO, ref oNO);


Label1.Text = "Uploaded file successfully!";

doc.Close(ref oNO, ref oNO, ref oNO);
}
}


感谢大家的答复.
我通过使用printout方法而不是saveas将word doc转换为图像.
获得了word文档的所有内容.
请参考 http://help.lockergnome.com/office/convert- word-doc-file-tif-file--ftopict991689.html [
Thanks everyone for the reply.
I converted word doc to image by using printout method instead of saveas.
Got all the contents of word document.
Refer http://help.lockergnome.com/office/convert-word-doc-file-tif-file--ftopict991689.html[^] for it.


这篇关于使用Microsoft对象库的Word to HTML Converter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆