类似百度文库效果实现


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

实现的效果如下:
文库
步骤:
1,利用FileUpload控件做文件上传
2,转换:安装FlashPaper2.2,
在程序中调用cmd命令完成转换:
FlashPrinter.exe “test.doc” -o “test4.swf”
注:iis及应用程序池需开权限以执行FlashPrinter
如下:

try
{

Process p = new Process();

p.StartInfo.FileName = "cmd";

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;

p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

p.Start();

string strOutput = null;

string outputPath = Server.MapPath("~//test5.swf");
string s = @"FlashPrinter.exe "   + "\"" + FilePath + "\" -o \"" + outputPath + "\"";

p.StandardInput.WriteLine(s);

p.StandardInput.WriteLine("exit");

strOutput = p.StandardOutput.ReadToEnd();

Console.WriteLine(strOutput);

p.WaitForExit();

p.Close();

lblMessage.Text = "success";

embed1.Attributes.Add("src", outputPath);

}

catch (Exception ex)
{

lblMessage.Text = ex.ToString();

}

注:执行完之后可关掉进程
///?<summary>
 ///?根据进程名称来关闭进程
 ///?</summary>
 ///?<param?name="processName"></param>
 private?static?void?KillPrecess(string?processName)
 {
 foreach?(Process?p?in?Process.GetProcesses())
 {
 if?(p.ProcessName?==?processName)
 {
 p.Kill();
 }
 }?
 }

3,在线播放:若文档较小,一般的flash播放器即可。若文件很大,一次加载所有再显示文件的播放器显然会拖慢速度,这时需要了解的是一个开源的flexpaper播放器,它可以播放一帧一页的flash;要像百度文库、豆丁一样修改flexpaper,让它支持一次仅读取指定页数的flash;如果文档安全级别较高,不允许下载查看,则需要给flexpaper加上加密解密算法;如果需要登录用户才能查看,则要让flexpaper有登录UI。