Office转SWF的一些感想(Office2007和Office2010)

Office2007需要借助SaveAsPDFandXPS的插件完成,Office2010可以直接兼容。

Office2PDF主要采用的是 Microsoft.Office.Interop的方式进行,PDF2SWF主要采用的是SWFTools的pdf2swf工具。至于SWFTools的各种命令,网上有很多的资料可以参考,这里就不一一举例了。


  1 /// <summary>
2 /// 把Word文件转换成为PDF格式文件
3 /// </summary>
4 /// <param name="sourcePath">源文件路径</param>
5 /// <param name="targetPath">目标文件路径</param>
6 /// <returns>true=转换成功</returns>
7 public static bool WordToPDF(string sourcePath, string targetPath)
8 {
9 bool result = false;
10 Word.WdExportFormat exportFormat = Word.WdExportFormat.wdExportFormatPDF;
11 object paramMissing = Type.Missing;
12 Word.Application wordApplication = new Word.Application();
13 Word.Document wordDocument = null;
14 try
15 {
16 object paramSourceDocPath = sourcePath;
17 string paramExportFilePath = targetPath;
18 Word.WdExportFormat paramExportFormat = exportFormat;
19 bool paramOpenAfterExport = false;
20 Word.WdExportOptimizeFor paramExportOptimizeFor = Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForPrint;
21 Word.WdExportRange paramExportRange = Word.WdExportRange.wdExportAllDocument;
22 int paramStartPage = 0;
23 int paramEndPage = 0;
24 Word.WdExportItem paramExportItem = Word.WdExportItem.wdExportDocumentContent;
25 bool paramIncludeDocProps = true;
26 bool paramKeepIRM = true;
27 Word.WdExportCreateBookmarks paramCreateBookmarks = Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks;
28 bool paramDocStructureTags = true;
29 bool paramBitmapMissingFonts = true;
30 bool paramUseISO19005_1 = false;
31 wordDocument = wordApplication.Documents.Open(
32 ref paramSourceDocPath, ref paramMissing, ref paramMissing,
33 ref paramMissing, ref paramMissing, ref paramMissing,
34 ref paramMissing, ref paramMissing, ref paramMissing,
35 ref paramMissing, ref paramMissing, ref paramMissing,
36 ref paramMissing, ref paramMissing, ref paramMissing,
37 ref paramMissing);
38 if (wordDocument != null)
39 wordDocument.ExportAsFixedFormat(paramExportFilePath,
40 paramExportFormat, paramOpenAfterExport,
41 paramExportOptimizeFor, paramExportRange, paramStartPage,
42 paramEndPage, paramExportItem, paramIncludeDocProps,
43 paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,
44 paramBitmapMissingFonts, paramUseISO19005_1,
45 ref paramMissing);
46 result = true;
47 }
48 catch
49 {
50 result = false;
51 }
52 finally
53 {
54 if (wordDocument != null)
55 {
56 wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing);
57 wordDocument = null;
58 }
59 if (wordApplication != null)
60 {
61 wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing);
62 wordApplication = null;
63 }
64 GC.Collect();
65 GC.WaitForPendingFinalizers();
66 GC.Collect();
67 GC.WaitForPendingFinalizers();
68 }
69 return result;
70 //bool result = false;
71 //Microsoft.Office.Interop.Word.WdExportFormat exportFormat = Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;
72 //Microsoft.Office.Interop.Word.Application application = null;
73
74 //Microsoft.Office.Interop.Word.Document document = null;
75 //try
76 //{
77 // application = new Microsoft.Office.Interop.Word.Application();
78 // application.Visible = false;
79 // document = application.Documents.Open(sourcePath);
80 // document.SaveAs();
81 // document.ExportAsFixedFormat(targetPath, exportFormat);
82 // result = true;
83 //}
84 //catch (Exception e)
85 //{
86
87 // result = false;
88 // throw e;
89 //}
90 //finally
91 //{
92 // if (document != null)
93 // {
94 // document.Close();
95 // document = null;
96 // }
97 // if (application != null)
98 // {
99 // application.Quit();
100 // application = null;
101 // }
102 // GC.Collect();
103 // GC.WaitForPendingFinalizers();
104 // GC.Collect();
105 // GC.WaitForPendingFinalizers();
106 //}
107 //return result;
108 }


ExcelToPDF

 1   /// <summary>
2 /// 把Microsoft.Office.Interop.Excel文件转换成PDF格式文件
3 /// </summary>
4 /// <param name="sourcePath">源文件路径</param>
5 /// <param name="targetPath">目标文件路径</param>
6 /// <returns>true=转换成功</returns>
7 public static bool ExcelToPDF(string sourcePath, string targetPath)
8 {
9 bool result = false;
10 Excel.XlFixedFormatType targetType = Excel.XlFixedFormatType.xlTypePDF;
11 object missing = Type.Missing;
12 Excel.Application application = null;
13 Excel.Workbook workBook = null;
14 try
15 {
16 application = new Excel.Application();
17 object target = targetPath;
18 object type = targetType;
19 workBook = application.Workbooks.Open(sourcePath, missing, missing, missing, missing, missing,
20 missing, missing, missing, missing, missing, missing, missing, missing, missing);
21 workBook.ExportAsFixedFormat(targetType, target, Excel.XlFixedFormatQuality.xlQualityStandard, true, false, missing, missing, missing, missing);
22 result = true;
23 }
24 catch
25 {
26 result = false;
27 }
28 finally
29 {
30 if (workBook != null)
31 {
32 workBook.Close(true, missing, missing);
33 workBook = null;
34 }
35 if (application != null)
36 {
37 application.Quit();
38 application = null;
39 }
40 GC.Collect();
41 GC.WaitForPendingFinalizers();
42 GC.Collect();
43 GC.WaitForPendingFinalizers();
44 }
45 return result;
46 //bool result = false;
47 //Microsoft.Office.Interop.Excel.XlFixedFormatType targetType = Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF;
48 //object missing = Type.Missing;
49 //Microsoft.Office.Interop.Excel.Application application = null;
50 //Microsoft.Office.Interop.Excel.Workbook workBook = null;
51 //try
52 //{
53 // application = new Microsoft.Office.Interop.Excel.Application();
54 // application.Visible = false;
55 // workBook = application.Workbooks.Open(sourcePath);
56 // workBook.SaveAs();
57 // workBook.ExportAsFixedFormat(targetType, targetPath);
58 // result = true;
59 //}
60 //catch (Exception e)
61 //{
62
63 // result = false;
64 // throw e;
65 //}
66 //finally
67 //{
68 // if (workBook != null)
69 // {
70 // workBook.Close(true, missing, missing);
71 // workBook = null;
72 // }
73 // if (application != null)
74 // {
75 // application.Quit();
76 // application = null;
77 // }
78 // GC.Collect();
79 // GC.WaitForPendingFinalizers();
80 // GC.Collect();
81 // GC.WaitForPendingFinalizers();
82 //}
83 //return result;
84 }


PowerPointToPDF

 1 /// <summary>
2 /// 把PowerPoint文件转换成PDF格式文件
3 /// </summary>
4 /// <param name="sourcePath">源文件路径</param>
5 /// <param name="targetPath">目标文件路径</param>
6 /// <returns>true=转换成功</returns>
7 public static bool PowerPointToPDF(string sourcePath, string targetPath)
8 {
9 bool result;
10 PowerPoint.PpSaveAsFileType targetFileType = PowerPoint.PpSaveAsFileType.ppSaveAsPDF;
11
12 object missing = Type.Missing;
13 PowerPoint.Application application = null;
14 PowerPoint.Presentation persentation = null;
15 try
16 {
17 application = new PowerPoint.Application();
18 persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
19 persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);
20 result = true;
21 }
22 catch
23 {
24 result = false;
25 }
26 finally
27 {
28 if (persentation != null)
29 {
30 persentation.Close();
31 persentation = null;
32 }
33 if (application != null)
34 {
35 application.Quit();
36 application = null;
37 }
38 GC.Collect();
39 GC.WaitForPendingFinalizers();
40 GC.Collect();
41 GC.WaitForPendingFinalizers();
42 }
43 return result;
44
45 //bool result;
46 //Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType targetFileType = Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPDF;
47 //object missing = Type.Missing;
48 //Microsoft.Office.Interop.PowerPoint.Application application = null;
49 //Microsoft.Office.Interop.PowerPoint.Presentation persentation = null;
50 //try
51 //{
52 // application = new Microsoft.Office.Interop.PowerPoint.Application();
53 // //application.Visible = MsoTriState.msoFalse;
54 // persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
55 // persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);
56
57 // result = true;
58 //}
59 //catch (Exception e)
60 //{
61 // result = false;
62 // throw e;
63 //}
64 //finally
65 //{
66 // if (persentation != null)
67 // {
68 // persentation.Close();
69 // persentation = null;
70 // }
71 // if (application != null)
72 // {
73 // application.Quit();
74 // application = null;
75 // }
76 // GC.Collect();
77 // GC.WaitForPendingFinalizers();
78 // GC.Collect();
79 // GC.WaitForPendingFinalizers();
80 //}
81 //return result;
82 }


VisioToPDF

 1         /// <summary>
2 /// 把Visio文件转换成PDF格式文件
3 /// </summary>
4 /// <param name="sourcePath">源文件路径</param>
5 /// <param name="targetPath">目标文件路径</param>
6 /// <returns>true=转换成功</returns>
7 public static bool VisioToPDF(string sourcePath, string targetPath)
8 {
9 bool result;
10
11 Microsoft.Office.Interop.Visio.VisFixedFormatTypes targetType = Microsoft.Office.Interop.Visio.VisFixedFormatTypes.visFixedFormatPDF;
12 object missing = Type.Missing;
13 Microsoft.Office.Interop.Visio.Application application = null;
14 Microsoft.Office.Interop.Visio.Document document = null;
15 try
16 {
17 application = new Microsoft.Office.Interop.Visio.Application();
18 application.Visible = false;
19 document = application.Documents.Open(sourcePath);
20 document.Save();
21 document.ExportAsFixedFormat(targetType, targetPath, Microsoft.Office.Interop.Visio.VisDocExIntent.visDocExIntentScreen, Microsoft.Office.Interop.Visio.VisPrintOutRange.visPrintAll);
22 result = true;
23 }
24 catch (Exception e)
25 {
26 result = false;
27
28 throw e;
29 }
30 finally
31 {
32 if (application != null)
33 {
34 application.Quit();
35 application = null;
36 }
37 GC.Collect();
38 GC.WaitForPendingFinalizers();
39 GC.Collect();
40 GC.WaitForPendingFinalizers();
41 }
42 return result;
43 }

因为这里的代码只支持Office2007以及以上版本,所以需要检测目标机器的Office版本,这里我的方法是查询注册表信息,对于绿色安装的Office楼主没有想到好的办法。


GetOfficePath

  1 /// <summary>
2 /// 获取当前某个版本Office的安装路径
3 /// </summary>
4 /// <param name="Path">返回当前系统Office安装路径</param>
5 /// <param name="Version">返回当前系统Office版本信息</param>
6 public static void GetOfficePath(out string Path, out string Version)
7 {
8 string strPathResult = "";
9 string strVersionResult = "";
10 string strKeyName = "Path";
11 object objResult = null;
12 Microsoft.Win32.RegistryValueKind regValueKind;
13 Microsoft.Win32.RegistryKey regKey = null;
14 Microsoft.Win32.RegistryKey regSubKey = null;
15
16 try
17 {
18 regKey = Microsoft.Win32.Registry.LocalMachine;
19 if (regSubKey == null)
20 {//office2010
21 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot", false);
22 strVersionResult = "office2010";
23 strKeyName = "Path";
24 try
25 {
26
27 objResult = regSubKey.GetValue(strKeyName);
28
29 regValueKind = regSubKey.GetValueKind(strKeyName);
30
31 }
32
33 catch (Exception ex)
34 {
35
36 regSubKey = null;
37
38 }
39
40 }
41 if (regSubKey == null)
42 {//office2007
43 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot", false);
44 strVersionResult = "office2007";
45 strKeyName = "Path";
46 try
47 {
48
49 objResult = regSubKey.GetValue(strKeyName);
50
51 regValueKind = regSubKey.GetValueKind(strKeyName);
52
53 }
54
55 catch (Exception ex)
56 {
57
58 regSubKey = null;
59
60 }
61 }
62
63 if (regSubKey == null)
64 {//Office2003
65 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot", false);
66 strVersionResult = "office2003";
67 strKeyName = "Path";
68 try
69 {
70
71 objResult = regSubKey.GetValue(strKeyName);
72
73 regValueKind = regSubKey.GetValueKind(strKeyName);
74
75 }
76
77 catch (Exception ex)
78 {
79
80 regSubKey = null;
81
82 }
83 }
84 if (regSubKey == null)
85 {//officeXp
86 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot", false);
87 strVersionResult = "officeXP";
88 strKeyName = "Path";
89 try
90 {
91
92 objResult = regSubKey.GetValue(strKeyName);
93
94 regValueKind = regSubKey.GetValueKind(strKeyName);
95
96 }
97
98 catch (Exception ex)
99 {
100
101 regSubKey = null;
102
103 }
104 }
105 if (regSubKey == null)
106 {//Office2000
107 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\9.0\Common\InstallRoot", false);
108 strVersionResult = "office2000";
109 strKeyName = "Path";
110 try
111 {
112
113 objResult = regSubKey.GetValue(strKeyName);
114
115 regValueKind = regSubKey.GetValueKind(strKeyName);
116
117 }
118
119 catch (Exception ex)
120 {
121
122 regSubKey = null;
123
124 }
125 }
126 if (regSubKey == null)
127 {//office97
128 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\8.0\Common\InstallRoot", false);
129 strVersionResult = "office97";
130 strKeyName = "OfficeBin";
131 try
132 {
133
134 objResult = regSubKey.GetValue(strKeyName);
135
136 regValueKind = regSubKey.GetValueKind(strKeyName);
137
138 }
139
140 catch (Exception ex)
141 {
142
143 regSubKey = null;
144
145 }
146 }
147
148 objResult = regSubKey.GetValue(strKeyName);
149 regValueKind = regSubKey.GetValueKind(strKeyName);
150 if (regValueKind == Microsoft.Win32.RegistryValueKind.String)
151 {
152 strPathResult = objResult.ToString();
153 }
154 }
155 catch (System.Security.SecurityException ex)
156 {
157 throw new System.Security.SecurityException("您没有读取注册表的权限", ex);
158 }
159 catch (Exception ex)
160 {
161 throw new Exception("读取注册表出错!", ex);
162 }
163 finally
164 {
165
166 if (regKey != null)
167 {
168 regKey.Close();
169 regKey = null;
170 }
171
172 if (regSubKey != null)
173 {
174 regSubKey.Close();
175 regSubKey = null;
176 }
177 }
178
179 Path = strPathResult;
180 Version = strVersionResult;
181 }

当文档转成PDF后,就成功一半啦,接下来就只剩下转换成SWF了。

转换的命令其实很简单的,但是楼主在实际操作的时候出现了问题,在转换的时候我们一般使用的是Process在进行命令行的执行,但是此类提供的标准output流只有2k,对于页数很多的PDF转换SWF的时候,会出现SWF无法生成的问题,借助网上很多同仁的资料,改良后的方面对于处理五六十页以内的PDF转SWF的问题不大,具体代码如下:


 1              //pdf转swf
2 string pdf2swfExe = @"SWFTools\pdf2swf.exe";
3
4 string args = " -t \"" + szPDF + "\" -o \"" + szSWF
5 + "\" -s drawonlyshapes -s flashversion=9 -s poly2bitmap";
6 using (Process p = new Process())
7 {
8
9 string cmd = pdf2swfExe;
10
11
12 p.StartInfo.FileName = cmd;
13 p.StartInfo.Arguments = args;
14 p.StartInfo.UseShellExecute = false;
15
16 ////此类提供的标准output流只有2k,不要重定向
17 p.StartInfo.RedirectStandardOutput = true;
18
19 p.StartInfo.CreateNoWindow = true;
20 p.Start();
21
22 p.PriorityClass = ProcessPriorityClass.High;
23 p.BeginOutputReadLine();
24 p.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
25
26 }

主要采用的方式是自行读取OUTPUT中的数据流,


process_OutputDataReceived

 1 private void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
2 {
3
4 // 这里仅做输出的示例,实际上您可以根据情况取消获取命令行的内容
5
6 // 参考:process.CancelOutputRead()
7
8
9 (sender as Process).Close();
10
11 if (String.IsNullOrEmpty(e.Data) == false)
12 {
13
14 string szPDF = Fileinfo.FileNewName.Split(‘.‘)[0] + ".pdf";
15 string szSWF = Fileinfo.FileNewName.Split(‘.‘)[0] + ".swf";
16 if (File.Exists(szSWF))
17 {
18 try
19 {
20
21
22
23 ThreadDelegate changeProcessDel = delegate() //后台中要更改主线程中的UI,于是我们还是用委托来实现,再创建一个实例
24 {
25 DataGridTemplateColumn templeColumn = Datagrid.Columns[Datagrid.Columns.Count - 1] as DataGridTemplateColumn;
26 FrameworkElement element = templeColumn.GetCellContent(Datagrid.Items[Index]);
27 GifImage img = (GifImage)templeColumn.CellTemplate.FindName("gifimage", element);
28 img.Visibility = System.Windows.Visibility.Hidden;
29 Label Successed = (Label)templeColumn.CellTemplate.FindName("Successed", element);
30 Successed.Visibility = System.Windows.Visibility.Visible;
31 Successed.Content = "文件转换成功!";
32 };//要调用的过程
33 Dispatcher.BeginInvoke(DispatcherPriority.Send, changeProcessDel); //使用分发器让这个委托等待执行
34 Thread.Sleep(3000);
35
36
37
38 //删除原文件
39 if (File.Exists(Fileinfo.FileNewName))
40 {
41 File.Delete(Fileinfo.FileNewName);
42 }
43 //删除pdf
44 //if (File.Exists(szPDF))
45 //{
46 // File.Delete(szPDF);
47 //}
48 }
49 catch (Exception ex)
50 {
51 throw ex;
52 }
53 }
54 else
55 {
56 //ThreadDelegate changeProcessDel = delegate() //后台中要更改主线程中的UI,于是我们还是用委托来实现,再创建一个实例
57 //{
58 // DataGridTemplateColumn templeColumn = Datagrid.Columns[Datagrid.Columns.Count - 1] as DataGridTemplateColumn;
59 // FrameworkElement element = templeColumn.GetCellContent(Datagrid.Items[Index]);
60 // GifImage img = (GifImage)templeColumn.CellTemplate.FindName("gifimage", element);
61 // img.Visibility = System.Windows.Visibility.Hidden;
62 // Label Successed = (Label)templeColumn.CellTemplate.FindName("Successed", element);
63 // Successed.Visibility = System.Windows.Visibility.Visible;
64 // Successed.Content = "文件转换出错!";
65 //};//要调用的过程
66 //Dispatcher.BeginInvoke(DispatcherPriority.Send, changeProcessDel); //使用分发器让这个委托等待执行
67 //Thread.Sleep(3000);
68
69 }
70 }
71
72 }

本程序的框架是WPF搭建的。

关于PDF转SWF就说这么多了,当然楼主所有的代码中不乏是网上同仁的心血,楼主在这里只是对某些代码进行整改和总结,并非侵权。

时间: 2024-10-30 08:51:51

Office转SWF的一些感想(Office2007和Office2010)的相关文章

office2007安装时显示安装程序找不到 office.zh-cn\officeLR.cab怎么办

根本原因是和VS2008有关解决方法如下:1. 找到vs2008安装程序(光盘,镜像文件,解压文件都一样),找到WCU文件夹在他里面找到WebDesignerCore文件夹,然后打开它找到WebDesignerCore.EXE,右击用RAR解压它(不是双击它,切记)然后打开解压得到的文件夹找打setup.exe双击它选择"删除"单击"继续",完成之后再双击setup.exe选择"立即安装",或者然后到目标目录里把该目录下的Office.Zh-CN

在线浏览office 文件

http://blog.csdn.net/binyao02123202/article/details/20051683 [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你! 2014-02-27 15:04     1089人阅读     评论(0)     收藏     举报 目录(?)[+] 引言 方案一 方案二 方案三 方案四 方案五 方案六 总结 引言 之前项目需要,查找了office文档在线预览的解决方案,顺便记录一下,方便以后查询.

Atitit.office&#160;word&#160;&#160;excel&#160;&#160;ppt&#160;pdf&#160;的web在线预览方案与html转换方案&#160;attilax&#160;总结

Atitit.office word  excel  ppt pdf 的web在线预览方案与html转换方案 attilax 总结 1. office word  excel pdf 的web预览要求1 1.1. 显示效果要好1 1.2. 可以自定义显示界面1 1.3. 不需要控件,兼容性好1 1.4. 支持编辑操作1 2. 纯html预览解决之道(自由的格式)1 3. 转换swf flash方案2 4. 转换pdf方式..更多的浏览器已经直接支持pdf格式查看2 5. 控件方式2 6. Hyb

注册表检测office版本

#region 查询注册表,判断本机是否安装Office2003,2007和WPS public int ExistsRegedit() { int ifused = 0; RegistryKey rk = Registry.LocalMachine; //查询Office2003 RegistryKey f03 = rk.OpenSubKey(@"SOFTWARE\Microsoft\Office\11.0\Excel\InstallRoot\"); //查询Office2007 R

解决Office软件冲突问题

Office软件冲突问题,原因就是不同版本的问题,我的电脑上是Office2007和Office2010冲突.解决办法: 1.开始种找到Microsoft  Office文件夹,在该文件夹下找到Office2007管理,进行卸载: 2.卸载完成后,打开Office2010任一款工具,Word.Excel都行,系统会提示安装,这个要确保安装进行,不能取消.等安装完成,分别打开所需工具,如Access.Word: 3.点击[文件]菜单工具下的[选项]工具, 4.进入选项,在管理下选择[COM加载项]

自从我安装卸载几次OFFICE和WPS后,VB6就出现了这样的问题。

然后在网上收集各种解决办法: 1.第一种:工程文件引用可能有问题,跟本机的相关组件版本不一致. 用记事本打开VBP文件找到这一行:Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0; MSCOMCTL.OCX改为:Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX保存即可 打开我的工程文件,发现本来就是2.0的,这种方法就没有任何用武之地了. 2.第二种:MSCOM

[Asp.net]常见word,excel,ppt,pdf在线预览方案(转)

引言 之前项目需要,查找了office文档在线预览的解决方案,顺便记录一下,方便以后查询. 方案一 直接在浏览器中打开Office文档在页面上的链接.会弹出如下窗口: 优点:主流浏览器都支持. 缺点:Office文档链接在浏览器中打开,会有如上图的提示,需用户自己选择打开或者保存功能,如果客户电脑上安装迅雷下载软件,会启动迅雷下载,用户体验不好. 方案二 office文档转html,首先引入com组件中office库,然后在程序集扩展中引入word,excel,ppt的dll. 然后F6生成,会

笔记——文档在线阅读的解决方案(未完待续)

目前现在很多大型的网站或是某些项目需要让用户上传的文档可以在线预览.这个目前我所了解到的有以下几种情况: 1.pdf 在线阅读 2.office 在线阅读 对于pdf目前有很多解决方案了,可以参考 http://www.open-open.com/news/view/1fc3e18  ,对于office在线阅读,目前.我的办法是,先转换为PDF,然后使用pdf在线阅读的方式进行浏览.目前好像很多站点都是这么做的. 然而,我在项目中,这类文档在线阅读方案是这样的.OFFICE --> PDF  -

Onenote实现OCR识别图片

OCR识别推荐两个软件: Tesseract:一个开源的,由谷歌维护的OCR软件. Onenote:微软Office附带或者可以自己独立安装. 这次讲Onenote实现的OCR识别. 注:2010版及其以后版本OCR实现方式类似:office将其转换为特定xm格式,然后提取想要的节点就ok了:onenote2007识别比较简单:通过MODI API接口直接之别. 我这里是实现了 office2007和office2010的ocr识别函数. 源程序下载:坚果云连接 1 using Microsof