C#超级难题,大家来救急。。。 C#读取一个WORD文档,然后转换成一张一张的JPG图片存储,这可如何是好?可以在WINFORM里面,也可以在ASP.NET里面 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 部署的机器上装着Word不? 程序启动Word文档然后截屏 http://www.pdf-convert.com/doc2img/ using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO;using Office = Microsoft.Office;using PowerPoint = Microsoft.Office.Interop.PowerPoint;using Word = Microsoft.Office.Interop.Word;using Excel;namespace OfficeToHTML{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void ConvertWORD(string oFileName, string _HtmlFileName) { object oMissing = System.Reflection.Missing.Value; object True = true; object False = false; object fmt = Word.WdSaveFormat.wdFormatHTML; object strHtml = _HtmlFileName; Word.Application WordApp = new Word.Application(); Word._Document oDoc = null; WordApp = new Word.Application(); WordApp.Visible = false; object fileName = oFileName; try { oDoc =WordApp.Documents.Open(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oDoc.SaveAs(ref strHtml, ref fmt, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oDoc.Close(ref False, ref oMissing, ref oMissing); WordApp.Quit(ref False, ref oMissing, ref oMissing); GC.Collect(); } catch (Exception ex) { display(ex.Message); if (oDoc != null) { oDoc.Close(ref False, ref oMissing, ref oMissing); } WordApp.Quit(ref False, ref oMissing, ref oMissing); GC.Collect(); } } }}需要安装office PIA 2003上面的是将Word转换成HTML,之后就到文件夹里找吧 听说可以用C++和DELPHI做莫非C#不行?囧 如果单用截屏应该不行。word文档很长的话,截屏就失去意义了。 可以分步骤来啊:第一:读取WORD文档(ASP.NET有这个功能,不过我没弄过 嘿嘿)第二:读出的文档写到图片上去(以前做过类似的功能:就是用户登录的验证码,我用的都是随机号码写到图片上去的)第三:考虑如果WORD文档很长 你这个怎么判断截取字符 然后再下一张图片上继续写(这个要看自己的程序了) 问一个调用控件的问题 谁有关于网站建设方面的资料!! 类似赛我网的虚拟房间功能怎么做?50分 怎么样保存<input type=file>这东西 时间日期转换格式问题? 怎样利用DataGrid的EditCommandColumn指定显示的某一个字段变成文本框? 请问各位高手这是为什么? 求FTP方式实现文件上传、下载 为什么我的csv文件下载时,总是保存为txt文件。很急!!!! 关于treeview的问题,只是确认一下。 vs.net 2010 不能单步调试存储过程 数据连接层怎么写啊?
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Office = Microsoft.Office;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Word = Microsoft.Office.Interop.Word;
using Excel;namespace OfficeToHTML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); }
private void ConvertWORD(string oFileName, string _HtmlFileName)
{ object oMissing = System.Reflection.Missing.Value;
object True = true;
object False = false;
object fmt = Word.WdSaveFormat.wdFormatHTML;
object strHtml = _HtmlFileName;
Word.Application WordApp = new Word.Application();
Word._Document oDoc = null;
WordApp = new Word.Application();
WordApp.Visible = false;
object fileName = oFileName;
try
{ oDoc =WordApp.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oDoc.SaveAs(ref strHtml, ref fmt, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oDoc.Close(ref False, ref oMissing, ref oMissing);
WordApp.Quit(ref False, ref oMissing, ref oMissing);
GC.Collect();
} catch (Exception ex)
{ display(ex.Message);
if (oDoc != null)
{
oDoc.Close(ref False, ref oMissing, ref oMissing);
}
WordApp.Quit(ref False, ref oMissing, ref oMissing);
GC.Collect();
}
} }}需要安装office PIA 2003上面的是将Word转换成HTML,
之后就到文件夹里找吧
word文档很长的话,截屏就失去意义了。
第一:读取WORD文档(ASP.NET有这个功能,不过我没弄过 嘿嘿)
第二:读出的文档写到图片上去(以前做过类似的功能:就是用户登录的验证码,我用的都是随机号码写到图片上去的)
第三:考虑如果WORD文档很长 你这个怎么判断截取字符 然后再下一张图片上继续写(这个要看自己的程序了)