/// <summary> /// Returns a newly started task that combines all source PDF files into one target file. /// </summary> /// <param name="sourceFiles"></param> /// <param name="targetFile"></param> /// <returns></returns> public async Task <string> BindPDFAsync(IList <IPDFStateFile> sourceFiles , IPDFFile targetFile , IProgress progress) { try { return(await Task.Factory.StartNew <string>(() => { progress.Reset(0, (sourceFiles.Count * 2) - 1, 0); progress.IsVisible = true; bool IsOK = true; progress.Start(0); // Testing all source files for (int i = 0; i < sourceFiles.Count; i++) { sourceFiles[i].State = TestSourceFile(sourceFiles[i].FileName); progress.Value++; if (sourceFiles[i].State != PDFTestResult.OK) { IsOK = false; } } if (IsOK == false) { return string.Empty; } CreateTargetPDF(targetFile.FileName); // Binding source files for (int i = 0; i < sourceFiles.Count; i++) { AddFile((string)sourceFiles[i].FileName); progress.Value++; } return targetFile.FileName; })); } catch (Exception exp) { throw exp; } }
/// <summary> /// 获取office文档内容 /// </summary> /// <param name="file"></param> /// <returns></returns> private static string _GetContent(IOfficeFile file) { if (file is IWordFile) { IWordFile wordFile = file as IWordFile; return(wordFile.ParagraphText); } else if (file is IPowerPointFile) { IPowerPointFile pptFile = file as IPowerPointFile; return(pptFile.AllText); } else if (file is ITextFile) { ITextFile textFile = file as ITextFile; return(textFile.CommentText); } else if (file is IPDFFile) { IPDFFile pdfFile = file as IPDFFile; return(pdfFile.CommentText); } else if (file is IHtmlFile) { IHtmlFile htmlFile = file as IHtmlFile; return(htmlFile.CommentText); } else if (file is IExcelFile) { IExcelFile excelFile = file as IExcelFile; return(excelFile.CommentText); } else { return(String.Format("无法解析")); } }