Przeglądaj źródła

转档新库-更新BUG

liyijie 2 lat temu
rodzic
commit
63eeed1f0c

BIN
PDF Office/ComDocumentAIKit.dll


BIN
PDF Office/ComPDFKit_Conversion.dll


+ 78 - 50
PDF Office/Helper/ConverterHelper.cs

@@ -27,24 +27,24 @@ namespace PDF_Office.Helper
         public static CPDFConverterImg imgConverter = null;
         public static CPDFConverterRTF rtfConverter = null;
         public static CPDFConverterHTML htmlConverter = null;
-        public static async Task<bool> WordConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertWordOptions wordOptions = null)
+        public static async Task<bool> WordConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertWordOptions wordOptions = null, bool IsCustomFileName = true)
         {
             bool result = false;
             try
             {
                 int[] pageArray = pageIndexLists.ToArray();
                 wordConverter = new CPDFConverterWord(inputpath, pawssword);
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                string outputFileName = Path.GetFileNameWithoutExtension(outputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
                 string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".docx");
                 result = await Task.Run(() => wordConverter.Convert(outputFolder, ref outputFileName, wordOptions, pageArray, ref error, getProgress));
                 if (result)
                 {
-                       CommonHelper.ShowFileBrowser(outputFileName.Replace("/","\\"));
+                    CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
                 }
             }
-            
+
             catch (Exception ex)
             {
 
@@ -52,7 +52,7 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static async Task<bool> PPTConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertPPTOptions pptOptions=null)
+        public static async Task<bool> PPTConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertPPTOptions pptOptions = null, bool IsCustomFileName = true)
         {
             bool result = false;
             try
@@ -60,13 +60,13 @@ namespace PDF_Office.Helper
                 int[] pageArray = pageIndexLists.ToArray();
 
                 pptConverter = new CPDFConverterPPT(inputpath, pawssword);
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                string outputFileName = Path.GetFileNameWithoutExtension(outputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
 
                 string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".ppt");
 
-                result = await Task.Run(() => pptConverter.Convert(outputFolder, ref outputFileName, pptOptions,pageArray, ref error, getProgress));
+                result = await Task.Run(() => pptConverter.Convert(outputFolder, ref outputFileName, pptOptions, pageArray, ref error, getProgress));
                 if (result)
                 {
                     CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
@@ -79,18 +79,18 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static async Task<bool> ExcelConvert(string inputpath, string outputpath,OnProgress getProgress , List<int> pageIndexLists, string pawssword,CPDFConvertExcelOptions ExcelOption)
+        public static async Task<bool> ExcelConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertExcelOptions ExcelOption, bool IsCustomFileName = true)
         {
             bool result = false;
             try
             {
-                excelConverter = new CPDFConverterExcel(inputpath,pawssword);
+                excelConverter = new CPDFConverterExcel(inputpath, pawssword);
                 int[] pageArray = pageIndexLists.ToArray();
 
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                string outputFileName = Path.GetFileNameWithoutExtension(outputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
-                 result = await Task.Run(() => excelConverter.Convert(outputFolder, ref outputFileName, ExcelOption, pageArray, ref error, getProgress));
+                result = await Task.Run(() => excelConverter.Convert(outputFolder, ref outputFileName, ExcelOption, pageArray, ref error, getProgress));
                 if (result)
                 {
                     if (File.Exists(outputFileName))
@@ -98,13 +98,13 @@ namespace PDF_Office.Helper
                     else if (outputFileName == "NoTable")
                         MessageBoxEx.Show("No Table");
                 }
-               
-                   
+
+
             }
             catch (Exception ex)
-           {
+            {
 
-               }
+            }
             return result;
         }
 
@@ -129,7 +129,7 @@ namespace PDF_Office.Helper
         //    return result;
         //}
 
-        public static async Task<bool> CSVConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertCsvOptions csvOptions =null)
+        public static async Task<bool> CSVConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertCsvOptions csvOptions = null, bool IsCustomFileName = true)
         {
             bool result = false;
             try
@@ -137,18 +137,44 @@ namespace PDF_Office.Helper
                 int[] pageArray = pageIndexLists.ToArray();
 
                 csvConverter = new CPDFConverterCsv(inputpath, pawssword);
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = "";
+                string outputFileName = "";
+                if (IsCustomFileName)
+                {
+                    outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                    outputFileName = Path.GetFileNameWithoutExtension(outputpath);
+                }
+                else
+                {
+                    outputFolder = outputpath;
+                    outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                }
+
                 ConvertError error = ConvertError.ERR_UNKNOWN;
                 string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".csv");
                 result = await Task.Run(() => csvConverter.Convert(outputFolder, ref outputFileName, csvOptions, pageArray, ref error, getProgress));
                 if (result)
                 {
+
+
                     if (File.Exists(outputFileName))
-                        CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
+                    {
+                        if (IsCustomFileName)
+                        {
+                            CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
+                        }
+                        else
+                        {
+                            string FileName = CommonHelper.CreateFolder(outputFileName.Replace(".zip", ""));
+                            ZipFile.ExtractToDirectory(outputFileName, FileName);
+                            File.Delete(outputFileName);
+                            CommonHelper.ShowFileBrowser(FileName.Replace("/", "\\"));
+                        }
+
+                    }
                     else
                         MessageBox.Show("None CSV");
-                    
+
                 }
             }
             catch (Exception ex)
@@ -158,7 +184,7 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static async Task<bool> TxtConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword,CPDFConvertTxtOptions txtOptions =null)
+        public static async Task<bool> TxtConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertTxtOptions txtOptions = null, bool IsCustomFileName = true)
         {
             bool result = false;
             try
@@ -166,8 +192,8 @@ namespace PDF_Office.Helper
                 int[] pageArray = pageIndexLists.ToArray();
 
                 txtConverter = new CPDFConverterTxt(inputpath, pawssword);
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                string outputFileName = Path.GetFileNameWithoutExtension(outputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
                 string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".txt");
                 result = await Task.Run(() => txtConverter.Convert(outputFolder, ref outputFileName, txtOptions, pageArray, ref error, getProgress));
@@ -183,29 +209,31 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static void ImageMagickPDFToImage(string imageType,string filePath,string outputFolder,string outputFileName,ref string FileName) {
-            FileName = CommonHelper.CreateFolder(outputFolder +"\\"+ outputFileName);
+        public static void ImageMagickPDFToImage(string imageType, string filePath, string outputFolder, string outputFileName, ref string FileName)
+        {
+            FileName = CommonHelper.CreateFolder(outputFolder + "\\" + outputFileName);
             ZipFile.ExtractToDirectory(filePath, FileName);
             var files = Directory.GetFiles(FileName, "*.png");
-            int i=0;
+            int i = 0;
             var images = new MagickImageCollection();
             foreach (var file in files)
             {
                 //pdf整体转为gif,将.gifoff改为.gif
                 Trace.WriteLine(file);
-                if (imageType == ".gifoff") {
+                if (imageType == ".gifoff")
+                {
                     images.Add(file);
                     images[i].AnimationDelay = 100; // in this example delay is 1000ms/1sec
                     images[i].Flip();
                 }
-                
+
                 using (var image = new MagickImage(file))
                 {
                     if (imageType != ".gifoff")
                     {
-                    //Save frame as jpg
-                    //image.Format = MagickFormat.Jp2;
-                    image.Write(file.Remove(file.LastIndexOf(".png"), 4) + imageType);
+                        //Save frame as jpg
+                        //image.Format = MagickFormat.Jp2;
+                        image.Write(file.Remove(file.LastIndexOf(".png"), 4) + imageType);
                     }
                     // 删除该文件
                     System.IO.File.Delete(file);
@@ -236,11 +264,11 @@ namespace PDF_Office.Helper
                     }
                 }
                 else { images.Write(outputFolder + "\\" + outputFileName + ".gif"); }
-               
+
             }
             //else {
             //    int fileIndex = 1;
-                
+
             //    if (File.Exists(outputFolder + "\\" + outputFileName + ".zip"))
             //    {
             //        while (fileIndex>=1) {
@@ -253,15 +281,15 @@ namespace PDF_Office.Helper
             //        }
             //    }
             //    else { ZipFile.CreateFromDirectory(outputFolder + "\\" + outputFileName, outputFolder + "\\" + outputFileName + ".zip"); }
-                
+
             //}
             //DirectoryInfo di = new DirectoryInfo(outputFolder + "\\" + outputFileName);
             //di.Delete(true);
 
 
-        }       
+        }
 
-        public static async Task<bool> ImgConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists,string pawssword,string imageType=".png", CPDFConvertImgOptions imgOptions = null)
+        public static async Task<bool> ImgConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, string imageType = ".png", CPDFConvertImgOptions imgOptions = null)
         {
             string FileName = "";
             bool result = false;
@@ -283,7 +311,7 @@ namespace PDF_Office.Helper
                 }
                 else
                 { //创建缓存文件夹
-                   
+
                     string folderPath = Path.Combine(App.CurrentPath, "ConverterImg");
                     //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
                     //保险措施(猜测)
@@ -301,8 +329,8 @@ namespace PDF_Office.Helper
                     //预览图缓存
                     string saveName = Guid.NewGuid().ToString();
                     string savePath = Path.Combine(folderPath, saveName);
-                     result = await Task.Run(() => imgConverter.Convert(folderPath, ref saveName, imgOptions, pageArray, ref error, getProgress));
-                    ImageMagickPDFToImage(imageType, saveName, outputFolder, outputFileName,ref FileName);
+                    result = await Task.Run(() => imgConverter.Convert(folderPath, ref saveName, imgOptions, pageArray, ref error, getProgress));
+                    ImageMagickPDFToImage(imageType, saveName, outputFolder, outputFileName, ref FileName);
                     DirectoryInfo di = new DirectoryInfo(folderPath);
                     di.Delete(true);
                 }
@@ -310,7 +338,7 @@ namespace PDF_Office.Helper
                 if (result)
                 {
                     //Process.Start(FileName.Replace("/", "\\"));
-                    CommonHelper.ShowFileBrowser(FileName);
+                    CommonHelper.ShowFileBrowser(FileName.Replace("/", "\\"));
                 }
             }
             catch (Exception ex)
@@ -320,17 +348,17 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static async Task<bool> RTFConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertRTFOptions rtfOptions=null)
+        public static async Task<bool> RTFConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertRTFOptions rtfOptions = null, bool IsCustomFileName = true)
         {
             bool result = false;
             try
             {
                 int[] pageArray = pageIndexLists.ToArray();
                 rtfConverter = new CPDFConverterRTF(inputpath, pawssword);
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                string outputFileName = Path.GetFileNameWithoutExtension(outputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
-                result = await Task.Run(() => rtfConverter.Convert(outputFolder, ref outputFileName, rtfOptions,pageArray, ref error, getProgress));
+                result = await Task.Run(() => rtfConverter.Convert(outputFolder, ref outputFileName, rtfOptions, pageArray, ref error, getProgress));
                 if (result)
                 {
                     CommonHelper.ShowFileBrowser(outputFileName.Replace("/", "\\"));
@@ -343,7 +371,7 @@ namespace PDF_Office.Helper
             return result;
         }
 
-        public static async Task<bool> HTMLConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertHTMLOptions HtmlOption)
+        public static async Task<bool> HTMLConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword, CPDFConvertHTMLOptions HtmlOption, bool IsCustomFileName = true)
         {
             bool result = false;
             try
@@ -351,8 +379,8 @@ namespace PDF_Office.Helper
                 htmlConverter = new CPDFConverterHTML(inputpath, pawssword);
                 int[] pageArray = pageIndexLists.ToArray();
 
-                string outputFolder = outputpath;
-                string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
+                string outputFolder = outputpath.Remove(outputpath.LastIndexOf("\\"));
+                string outputFileName = Path.GetFileNameWithoutExtension(outputpath);
                 ConvertError error = ConvertError.ERR_UNKNOWN;
                 result = await Task.Run(() => htmlConverter.Convert(outputFolder, ref outputFileName, HtmlOption, pageArray, ref error, getProgress));
                 if (result)

+ 6 - 1
PDF Office/Model/Dialog/ConverterDialogs/ConverterDialogsModel.cs

@@ -60,6 +60,11 @@ namespace PDF_Office.Model.Dialog.ConverterDialogs
         /// </summary>
         public string Pawssword="";
 
+        /// <summary>
+        /// 文档密码;
+        /// </summary>
+        public bool IsCustomFileName=true;
+               
 
         /// <summary>
         /// OCR,与部分功能;
@@ -103,7 +108,7 @@ namespace PDF_Office.Model.Dialog.ConverterDialogs
                         {
                             ConverterCSVModel.PageIndexLists[i] = ConverterCSVModel.PageIndexLists[i] + 1;
                         }
-                        result = await ConverterHelper.CSVConvert(ConverterCSVModel.InputPath, ConverterCSVModel.OutputPath, GetProgress, ConverterCSVModel.PageIndexLists, ConverterCSVModel.Pawssword, ConverterCSVModel.csvOptions);
+                        result = await ConverterHelper.CSVConvert(ConverterCSVModel.InputPath, ConverterCSVModel.OutputPath, GetProgress, ConverterCSVModel.PageIndexLists, ConverterCSVModel.Pawssword, ConverterCSVModel.csvOptions, ConverterCSVModel.IsCustomFileName);
 
                     }
                     else { App.mainWindowViewModel.IsProcessVisible = System.Windows.Visibility.Collapsed; }

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -2094,6 +2094,7 @@
     <Content Include="ComDocumentAIKit.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <None Include="source\models\OCR.model" />
     <Resource Include="Resources\ToolBarIcon\Scan\enhance.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>

+ 45 - 4
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterCSVDialogViewModel.cs

@@ -176,12 +176,50 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         private  void converter()
         {
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            if (ConverterCSVModel.IsCustomFileName) 
             {
-                ConverterCSVModel.OutputPath = dlg.SelectedPath.Trim();
+                System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+                /*
+                 *设置这个对话框的起始保存路径
+                 */
+                sfd.InitialDirectory = currentViewer.Document.FilePath;
+                /*
+                 *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+                 */
+                sfd.Filter = "PDF|*.csv;";
+                /*
+                 *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+                 */
+                sfd.FileName = currentViewer.Document.FileName + ".csv";
+                /*
+                 * 做一些工作
+                 */
+                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+                {
+                    ConverterCSVModel.OutputPath = sfd.FileName;
+                    try { if (File.Exists(ConverterCSVModel.OutputPath)) File.Delete(ConverterCSVModel.OutputPath); }
+                    catch
+                    {
+                        AlertsMessage alertsMessage = new AlertsMessage();
+                        alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                        return;
+                    }
+
+                }
+                else
+                {
+                    return;
+                }
+            } 
+            else {
+                FolderBrowserDialog dlg = new FolderBrowserDialog();
+                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+                {
+                    ConverterCSVModel.OutputPath = dlg.SelectedPath.Trim();
+                }
+                else { return; }
             }
-            else { return; }
+            
             HomePageEditHelper.GetPagerange(PageRangeSelectIndex, currentViewer, ref ConverterCSVModel.PageRange, PageRangeText, true, CurrentPageIndex);
             if (ConverterCSVModel.PageRange == "")
             {
@@ -222,9 +260,11 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                 {
                     case "ForEachPageRadioBtn":
                         ConverterCSVModel.Options.IsMergeCsv = false;
+                        ConverterCSVModel.IsCustomFileName = false;
                         break;
                     case "OnlyTableRadioBtn":
                         ConverterCSVModel.Options.IsMergeCsv = true;
+                        ConverterCSVModel.IsCustomFileName =true;
                         break;
                     default:
                         break;
@@ -257,6 +297,7 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
                 ConverterCSVModel.InputPath = pdfViewer.Document.FilePath;
                 FileInfo fileinfo = new FileInfo(ConverterCSVModel.InputPath);
                 ConverterCSVModel.Options.IsMergeCsv = false;
+                ConverterCSVModel.IsCustomFileName=false;
                 ConverterCSVModel.OutputPath = fileinfo.DirectoryName;
             }
         }

+ 26 - 3
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterExcelDialogViewModel.cs

@@ -131,10 +131,33 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         private void converter()
         {
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = currentViewer.Document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.xlsx;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             */
+            sfd.FileName = currentViewer.Document.FileName + ".xlsx";
+            /*
+             * 做一些工作
+             */
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
-                ConverterExcelModel.OutputPath = dlg.SelectedPath.Trim();
+                ConverterExcelModel.OutputPath = sfd.FileName;
+                try { if (File.Exists(ConverterExcelModel.OutputPath)) File.Delete(ConverterExcelModel.OutputPath); }
+                catch
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                    return;
+                }
+
             }
             else
             {

+ 29 - 5
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterHTMLDialogViewModel.cs

@@ -103,15 +103,39 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
         private void converter()
         {
 
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = currentViewer.Document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.html;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             */
+            sfd.FileName = currentViewer.Document.FileName + ".html";
+            /*
+             * 做一些工作
+             */
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
-                ConverterHTMLModel.OutputPath = dlg.SelectedPath.Trim();
+                ConverterHTMLModel.OutputPath = sfd.FileName;
+                try { if (File.Exists(ConverterHTMLModel.OutputPath)) File.Delete(ConverterHTMLModel.OutputPath); }
+                catch
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                    return;
+                }
+
             }
-            else {
+            else
+            {
                 return;
             }
-         
+
             HomePageEditHelper.GetPagerange(PageRangeSelectIndex, currentViewer, ref ConverterHTMLModel.PageRange, PageRangeText, true, CurrentPageIndex);
             if (ConverterHTMLModel.PageRange == "")
             {

+ 26 - 3
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterPPTDialogViewModel.cs

@@ -102,10 +102,33 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         private void converter()
         {
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = currentViewer.Document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.pptx;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             */
+            sfd.FileName = currentViewer.Document.FileName + ".pptx";
+            /*
+             * 做一些工作
+             */
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
-                ConverterPPTModel.OutputPath = dlg.SelectedPath.Trim();
+                ConverterPPTModel.OutputPath = sfd.FileName;
+                try { if (File.Exists(ConverterPPTModel.OutputPath)) File.Delete(ConverterPPTModel.OutputPath); }
+                catch
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                    return;
+                }
+
             }
             else
             {

+ 26 - 3
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterRTFDialogViewModel.cs

@@ -101,10 +101,33 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         private void converter()
         {
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = currentViewer.Document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.rtf;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             */
+            sfd.FileName = currentViewer.Document.FileName + ".rtf";
+            /*
+             * 做一些工作
+             */
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
-                ConverterRTFModel.OutputPath = dlg.SelectedPath.Trim();
+                ConverterRTFModel.OutputPath = sfd.FileName;
+                try { if (File.Exists(ConverterRTFModel.OutputPath)) File.Delete(ConverterRTFModel.OutputPath); }
+                catch
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                    return;
+                }
+
             }
             else
             {

+ 26 - 3
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterTextDialogViewModel.cs

@@ -102,10 +102,33 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         private  void converter()
         {
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = currentViewer.Document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.txt;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             */
+            sfd.FileName = currentViewer.Document.FileName + ".txt";
+            /*
+             * 做一些工作
+             */
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
-                ConverterTextModel.OutputPath = dlg.SelectedPath.Trim();
+                ConverterTextModel.OutputPath = sfd.FileName;
+                try { if (File.Exists(ConverterTextModel.OutputPath)) File.Delete(ConverterTextModel.OutputPath); }
+                catch
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                    return;
+                }
+
             }
             else
             {

+ 26 - 3
PDF Office/ViewModels/Dialog/ConverterDialogs/ConverterWordDialogViewModel.cs

@@ -1,6 +1,7 @@
 using ComDocumentAIKit;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
+using PDF_Office.EventAggregators;
 using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.Dialog.ConverterDialogs;
@@ -104,10 +105,32 @@ namespace PDF_Office.ViewModels.Dialog.ConverterDialogs
 
         private void converter()
         {
-            FolderBrowserDialog dlg = new FolderBrowserDialog();
-            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = currentViewer.Document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.docx;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             */
+            sfd.FileName = currentViewer.Document.FileName + ".docx";
+            /*
+             * 做一些工作
+             */
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
-                ConverterWordModel.OutputPath = dlg.SelectedPath.Trim();
+                ConverterWordModel.OutputPath = sfd.FileName;
+                try {if(File.Exists(ConverterWordModel.OutputPath)) File.Delete(ConverterWordModel.OutputPath); }
+                catch {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("文件已被占用", "请重新选则目标路径", "确定");
+                    return;
+                }
+               
             }
             else
             {

BIN
PDF Office/source/models/OCR.model


BIN
PDF Office/x64/CPDFConverterNative.dll


BIN
PDF Office/x64/ComDocumentAINative.dll


BIN
PDF Office/x64/DocumentAI.dll


BIN
PDF Office/x64/onnxruntime.dll


BIN
PDF Office/x64/paddle2onnx.dll