文档什么时候转换,是人为转换吗?还是电脑自动转换的?1.转换不同:(1)手动转换:用户上传文件—>文档编辑审核用户上传的文件。并设置审核标志—>管理员选择时间转换审核通过的文档(2)、电脑转换:用户上传文件—>电脑初审—>电脑启动文档转换程序进行转换document—>同时启动进程监控服务,关闭死锁转换程序,释放内存资源补充:在整个文档业务中,我们希望加入上报业务,即上报坏文档。(管理员可以对上报的文件进行针对性的管理)二、doc、docx、xls等文件到pdf的转换过程。我用FlashPaper完成了doc、docx、xls等文档到pdf的转换过程,所以要完成这个操作,大家必须安装flashpaper,至于flashpaper的版本!你自己决定!思路是只要能用就可以用。 //////将用户所在传文件转成pdf文件///privatevoidConvertToPdf(stringresFilePath,stringpdfFilePath){try{Processp=newProcess();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.开始();字符串strOutput=null;strings=ConfigurationSettings.AppSettings["FlashPaper"]+resFilePath+"-o"+pdfFilePath;p.StandardInput.WriteLine(s);p.StandardInput.WriteLine("退出");strOutput=p.StandardOutput.ReadToEnd();控制台.WriteLine(strOutput);p.WaitForExit();p.关闭();}catch(Exceptionex){LogHelper.Info("转换为pdf时发生错误"+ex.Message);扔前;三、到pdf的转换过程完成,接下来我们要实现swf到pdf再到swf的转换,借用了SWFTools系列工具中的pdf2swf.exe。至于下载地址,大家google一下。//////将用户上传的文件转换为swf文件///pdfFilePath,为要转换的pdf文件的路径///privatevoidConvertToSwf(stringpdfFilePath,stringsaveSwfFilePath,stringfileName){try{intflag=0;intpageCount=GetPageCount(pdfFilePath);//计算pdf的页数stringswfUrl=string.Empty;如果(Directory.Exists(saveSwfFilePath)==false)Directory.CreateDirectory(saveSwfFilePath);stringexe=ConfigurationSettings.AppSettings["FlexPaper"];if(!File.Exists(exe))thrownewApplicationException("找不到:"+exe);StringBuildersb=newStringBuilder();if(pageCount%5>0)//每5页转成一个swf文件。这个细节非常重要。我每5页转成一个swf文件,这样可以方便预加载。标志=1;否则标志=0;对于(vari=0;i<(pageCount/5+flag);i++){swfUrl=saveSwfFilePath+"\\"+fileName+"-"+(i*5+1).ToString()+"-"+((i+1)*5)+".swf";sb.Append(exe);sb.Append("-o\""+swfUrl+"\"");//输出sb.Append("-z");sb.Append("-sflashversion=9");//flash版本sb.Append("-sdisablelinks");//禁止PDF里面的链接sb.Append("-p"+(i*5+1)+"-"+((i+1)*5));//pagerangesb.Append("-j100");//设置内嵌jpeg图片质量为quality。0是最差(小),100是最好(大)。(default:85)sb.Append("\""+pdfFilePath+"\"");//输入字符串strOutput=null;Processproc=newProcess();proc.StartInfo.FileName="cmd";proc.StartInfo.UseShellExecute=false;proc.StartInfo.RedirectStandardInput=true;proc.StartInfo.RedirectStandardOutput=true;proc.StartInfo.RedirectStandardError=true;proc.StartInfo.CreateNoWindow=true;proc.StartInfo.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden;proc.开始();proc.StandardInput.WriteLine(sb.ToString());proc.StandardInput.WriteLine("退出");strOutput=proc.StandardOutput.ReadToEnd();控制台.WriteLine(strOutput);proc.WaitForExit();proc.Close();sb.Remove(0,sb.Length);}}catch(Exceptionex){LogHelper.Info("转化为swf文件错误"+ex.Message);扔前;}}//////计算pdf文件总页数/////////publicstaticintGetPageCount(stringpdfPath){try{byte[]buffer=File.ReadAllBytes(pdfPath);}intlength=buffer.Length;如果(缓冲区==null)返回-1;如果(缓冲区。长度<=0)返回-1;字符串pdfText=Encoding.Default.GetString(缓冲区);System.Text.RegularExpressions.Regexrx1=newSystem.Text.RegularExpressions.Regex(@"/Type\s*/Page[^s]");System.Text.RegularExpressions.MatchCollectionmatches=rx1.Matches(pdfText);返回匹配项。计数;}catch(Exceptionex){LogHelper.Info("计算pdf文件总页数错误"+ex.Message);扔前;}}好了,文档的转换就完成了。这是我在网上看到的关于图书馆网站改版的。大家可以参考一下。如果大家对图书馆网站的开发有什么疑问,可以私信或者微信kjwenlc联系我,一起交流,共同进步。