print2flash小程序求救(高分悬赏)
我做了以下程序(仿百度文库把doc,ppt等转换成swf),在xp下可以运行,但在64位机器上无法运行,请大家帮忙,可以去下载我的代码调试:
代码(包括print2flash3-64bit安装程序)下载:http://www.023niit.com:100/print2flashDemo.rar
Print2Flash 3 Print 虚拟打印机我装好了的
Interop.Print2Flash3.dll此组件我在cmd下一注册就报错
运行到这句就报错:IServer server = new Server();//声明并初始化转换服务器类
部分代码:
protected void Button1_Click(object sender, EventArgs e)
{
IServer server = new Server();//声明并初始化转换服务器类
server.SetP2FPrinterAsDefault();//设置问默认的虚拟打印机
if (server.Skins["custom_chainan"] == null)
{
server.Skins.Add("custom_chainan");
}
ISkin skin = (ISkin)server.Skins["custom_chainan"];
skin.SetToolbarImage(TOOLBAR_IMAGE.IMGLOGO, Server.MapPath("~/UploadFiles/logo.png"));//必须为png格式的图片全名;更改转出来的logo图片
skin.HelpButtonURL = "http://blog.csdn.net/chainan1988";
skin.LogoURL = "http://blog.csdn.net/chainan1988";
skin.ApplyChanges();
Print2Flash3.INTERFACE_OPTION interfaceOption = (Print2Flash3.INTERFACE_OPTION)server.DefaultProfile.InterfaceOptions;
server.DefaultProfile.InterfaceOptions = (int)(interfaceOption & ~Print2Flash3.INTERFACE_OPTION.INTLOGO);//去掉logo图片(可选),这样的话上面设置logo图片就看不到效果
string sourceFile = Server.MapPath("~/UploadFiles/doc.doc");
string outputDir = Server.MapPath("~/UploadFiles/");
string outputFile = outputDir + "out.swf";
//转换单个文档
server.ConvertFile(sourceFile, outputFile, Type.Missing, Type.Missing, Type.Missing);//转换单个文档,第一个参数是要转换的文档名,第二个是转换后的文档名
//转换批量文档
IBatchProcessingOptions batchOptions = new BatchProcessingOptions();
batchOptions.ActivityTimeout = 1000;
batchOptions.AfterPrintingTimeout = 1000;
batchOptions.BeforePrintingTimeout = 1000;
batchOptions.PrintingTimeout = 1000;
batchOptions.KillProcessIfTimeout = ThreeStateFlag.TSF_AUTO;
batchOptions.PressPrintButton = ThreeStateFlag.TSF_AUTO;
batchOptions.KillProcessIfTimeout = ThreeStateFlag.TSF_AUTO;
batchOptions.KeepAutomationAppRef = APPLICATIONTYPE.ALL;
batchOptions.KillAllAutomationProcesses = ThreeStateFlag.TSF_AUTO;
batchOptions.CreateLogFile = true;
batchOptions.LogFileName = "log.log";
batchOptions.LoggingLevel = 1;//设置日志级别
batchOptions.ApplyChanges();
server.ConvertDir(sourceFile, null, outputDir, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//获得转换结果错误数量:server.ErrorCount
//获得转换文档数:server.FilesConverted
} print2flash3-64bit print2flash小程序求救 仿百度文库把docppt等转换成swf 仿百度文库源码
[解决办法]
我是直接命令行调用的,需要管理员权限,管理员权限是指web站点的应用池标识用管理员,winform的话就是管理员运行,以下代码要放到线程池中运行并且需要同步和先杀灭word进程
Process pss = new Process();
pss.StartInfo.UseShellExecute = false;
pss.StartInfo.RedirectStandardInput = true;
pss.StartInfo.RedirectStandardOutput = true;
pss.StartInfo.RedirectStandardError = true;
pss.StartInfo.CreateNoWindow = true;
pss.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
pss.StartInfo.FileName = flashPrinter;
if (!File.Exists(sourcefilefullname))
{
throw new Exception("来源文件保存错误");
}
//DestPath = "D:\";
pss.StartInfo.Arguments = string.Format(""{0}" "{1}"", sourcefilefullname, Path.Combine(DestPath, outPutFileName));
pss.Start();