flex在线展示word,excel,pdf解决方案
2014-02-27 09:52
435 查看
首先声明后台使用的是c#,
使用了四个工具第一个pdf2swf,
第二个和第三个都是dll,Aspose.Cells和Aspose.Words
第四个是flex使用的工具flexpaper
这些东西在网上都能下载到
word展示的具体思路是用Aspose.Words将word转为pdf,再把pdf转为swf,传给前台展示。
excel,和pdf思路也是一样的这里就不多说了
后台pdf转swf代码
/// <summary>
/// 将PDF转换为SWF文件
/// </summary>
/// <param name="pdfPath">PDF文件路径</param>
/// <param name="swfPath">SWF文件路径</param>
/// <param name="page"></param>
private void ConvertToSwf(string pdfPath, string swfPath)
{
try
{
string exe = ConfigurationManager.AppSettings["ExePath"];//应用程序地址
if (!File.Exists(exe))
{
throw new ApplicationException("Can not find: " + exe);
}
StringBuilder sb = new StringBuilder();
sb.Append(" -o \"" + swfPath + "\"");//output
sb.Append(" -z");
sb.Append(" -s flashversion=9");//flash version
sb.Append(" -s disablelinks");//禁止PDF里面的链接
// sb.Append(" -p " + "1" + "-" + page);//page range
sb.Append(" -j 100");//Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
sb.Append(" \"" + pdfPath + "\"");//input
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = exe;
proc.StartInfo.Arguments = sb.ToString();
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
proc.Close();
}
catch (Exception ex)
{
throw ex;
}
}
后台word转pdf关键代码
Document doc = new Document(ReturnPath+name);
doc.Save(TemPath+name, Aspose.Words.SaveFormat.Pdf);
后台excel转pdf关键代码
Workbook wb = new Workbook(ReturnPath + name);
wb.Save(TemPath + name, Aspose.Cells.SaveFormat.Pdf);
前台展示代码也很简单
<flexpaper:FlexPaperViewer id="File_ViewflexPaper" width="100%" height="100%" SwfFile="返回的uri" / >这样后台就能直接解析了。
顺便说一下Aspose.Cells和Aspose.Words这两个功能真的很强大,我用过Aspose.Words以前处理excel用的都是NPOI下次可以试一下Aspose.Cells
使用了四个工具第一个pdf2swf,
第二个和第三个都是dll,Aspose.Cells和Aspose.Words
第四个是flex使用的工具flexpaper
这些东西在网上都能下载到
word展示的具体思路是用Aspose.Words将word转为pdf,再把pdf转为swf,传给前台展示。
excel,和pdf思路也是一样的这里就不多说了
后台pdf转swf代码
/// <summary>
/// 将PDF转换为SWF文件
/// </summary>
/// <param name="pdfPath">PDF文件路径</param>
/// <param name="swfPath">SWF文件路径</param>
/// <param name="page"></param>
private void ConvertToSwf(string pdfPath, string swfPath)
{
try
{
string exe = ConfigurationManager.AppSettings["ExePath"];//应用程序地址
if (!File.Exists(exe))
{
throw new ApplicationException("Can not find: " + exe);
}
StringBuilder sb = new StringBuilder();
sb.Append(" -o \"" + swfPath + "\"");//output
sb.Append(" -z");
sb.Append(" -s flashversion=9");//flash version
sb.Append(" -s disablelinks");//禁止PDF里面的链接
// sb.Append(" -p " + "1" + "-" + page);//page range
sb.Append(" -j 100");//Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
sb.Append(" \"" + pdfPath + "\"");//input
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = exe;
proc.StartInfo.Arguments = sb.ToString();
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
proc.Close();
}
catch (Exception ex)
{
throw ex;
}
}
后台word转pdf关键代码
Document doc = new Document(ReturnPath+name);
doc.Save(TemPath+name, Aspose.Words.SaveFormat.Pdf);
后台excel转pdf关键代码
Workbook wb = new Workbook(ReturnPath + name);
wb.Save(TemPath + name, Aspose.Cells.SaveFormat.Pdf);
前台展示代码也很简单
<flexpaper:FlexPaperViewer id="File_ViewflexPaper" width="100%" height="100%" SwfFile="返回的uri" / >这样后台就能直接解析了。
顺便说一下Aspose.Cells和Aspose.Words这两个功能真的很强大,我用过Aspose.Words以前处理excel用的都是NPOI下次可以试一下Aspose.Cells
相关文章推荐
- 【顶级推荐】NET-Word、Excel、PPT、PDF在线预览解决方案
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- web在线编辑word,excel,pdf插件-----WebOffice 文档控件API
- [置顶] Android应用内展示word、excel、pdf、ppt等文件
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!(续)
- Aspose office (Excel,Word,PPT),PDF 在线预览
- Asp.Net Word、Excel转PDF在线预览
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- pdf word excel ppt 在线预览方案收集
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!(续)
- PDF在线转Word、Excel等
- [Asp.net]常见word,excel,ppt,pdf在线预览方案(转)
- PDF/WORD/EXCEL/PPT 文档在线阅读
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版
- Ubuntu 服务器 PHP实现word、excel、ppt、pdf 等文档在线阅读功能的实现
- 常见word,excel,ppt,pdf在线预览方案[转]
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!
- 应用内展示word ,pdf, excel,ppt等文件
- Flex 在线查看word,pdf,ppt等文档
- 类似百度文库在线预览文档flash版(支持word、excel、ppt、pdf)+在线预览文档html版