|
@@ -6,6 +6,11 @@ using System.Threading.Tasks;
|
|
using ComPDFKit_Conversion.Converter;
|
|
using ComPDFKit_Conversion.Converter;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.IO;
|
|
|
|
+using Microsoft.AppCenter.Crashes.Ingestion.Models;
|
|
|
|
+using static Dropbox.Api.Sharing.ListFileMembersIndividualResult;
|
|
|
|
+using ComPDFKit_Conversion.Options;
|
|
|
|
+using PDF_Office.CustomControl;
|
|
|
|
+using Exception = System.Exception;
|
|
|
|
|
|
namespace PDF_Office.Helper
|
|
namespace PDF_Office.Helper
|
|
{
|
|
{
|
|
@@ -15,8 +20,8 @@ namespace PDF_Office.Helper
|
|
public static CPDFConverterExcel excelConverter = null;
|
|
public static CPDFConverterExcel excelConverter = null;
|
|
public static CPDFConverterPPT pptConverter = null;
|
|
public static CPDFConverterPPT pptConverter = null;
|
|
public static CPDFConverterTxt txtConverter = null;
|
|
public static CPDFConverterTxt txtConverter = null;
|
|
- public static CPDFConverterTable tableConverter = null;
|
|
|
|
public static CPDFConverterCsv csvConverter = null;
|
|
public static CPDFConverterCsv csvConverter = null;
|
|
|
|
+ public static CPDFConverterImg imgConverter = null;
|
|
public static async Task<bool> WordConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
public static async Task<bool> WordConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
{
|
|
{
|
|
bool result = false;
|
|
bool result = false;
|
|
@@ -27,10 +32,8 @@ namespace PDF_Office.Helper
|
|
string outputFolder = outputpath;
|
|
string outputFolder = outputpath;
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
-
|
|
|
|
string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".docx");
|
|
string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".docx");
|
|
-
|
|
|
|
- result = await Task.Run(() => wordConverter.Convert(outputFolder, ref filename, pageArray, ref error, getProgress));
|
|
|
|
|
|
+ result = await Task.Run(() => wordConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -54,7 +57,11 @@ namespace PDF_Office.Helper
|
|
string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".ppt");
|
|
string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".ppt");
|
|
|
|
|
|
result = await Task.Run(() => pptConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
result = await Task.Run(() => pptConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
-
|
|
|
|
|
|
+ if (result)
|
|
|
|
+ {
|
|
|
|
+ if (File.Exists(outputFileName))
|
|
|
|
+ Process.Start(outputFileName);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -63,41 +70,69 @@ namespace PDF_Office.Helper
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- public static async Task<bool> ExcelConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
|
|
|
|
+ public static async Task<bool> ExcelConvert(string inputpath, string outputpath,OnProgress getProgress , List<int> pageIndexLists, string pawssword,CPDFConvertExcelOptions ExcelOption)
|
|
{
|
|
{
|
|
bool result = false;
|
|
bool result = false;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ excelConverter = new CPDFConverterExcel(inputpath,pawssword);
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
|
|
|
|
- excelConverter = new CPDFConverterExcel(inputpath, pawssword);
|
|
|
|
string outputFolder = outputpath;
|
|
string outputFolder = outputpath;
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
- string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".xlsx");
|
|
|
|
-
|
|
|
|
- result = await Task.Run(() => excelConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
-
|
|
|
|
|
|
+ result = await Task.Run(() => excelConverter.Convert(outputFolder, ref outputFileName, ExcelOption, pageArray, ref error, getProgress));
|
|
|
|
+ if (result)
|
|
|
|
+ {
|
|
|
|
+ if (File.Exists(outputFileName))
|
|
|
|
+ Process.Start(outputFileName);
|
|
|
|
+ else if (outputFileName == "NoTable")
|
|
|
|
+ MessageBoxEx.Show("No Table");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
- {
|
|
|
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- public static async Task<bool> TableConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
|
|
|
|
+ //public static async Task<bool> TableConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
|
|
+ //{
|
|
|
|
+ // bool result = false;
|
|
|
|
+ // try
|
|
|
|
+ // {
|
|
|
|
+ // int[] pageArray = pageIndexLists.ToArray();
|
|
|
|
+ // tableConverter = new CPDFConverterTable(inputpath, pawssword);
|
|
|
|
+ // string outputFolder = outputpath;
|
|
|
|
+ // string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
|
|
+ // ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
|
|
+ // string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".xlsx");
|
|
|
|
+ // result = await Task.Run(() => tableConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
+
|
|
|
|
+ // }
|
|
|
|
+ // catch (Exception ex)
|
|
|
|
+ // {
|
|
|
|
+
|
|
|
|
+ // }
|
|
|
|
+ // return result;
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ public static async Task<bool> CSVConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
{
|
|
{
|
|
bool result = false;
|
|
bool result = false;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
- tableConverter = new CPDFConverterTable(inputpath, pawssword);
|
|
|
|
|
|
+
|
|
|
|
+ csvConverter = new CPDFConverterCsv(inputpath, pawssword);
|
|
string outputFolder = outputpath;
|
|
string outputFolder = outputpath;
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
- string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".xlsx");
|
|
|
|
- result = await Task.Run(() => tableConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
|
|
+ string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".csv");
|
|
|
|
+ result = await Task.Run(() => csvConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -107,20 +142,19 @@ namespace PDF_Office.Helper
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- public static async Task<bool> CSVConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
|
|
|
|
+ public static async Task<bool> TxtConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
{
|
|
{
|
|
bool result = false;
|
|
bool result = false;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
|
|
|
|
- csvConverter = new CPDFConverterCsv(inputpath, pawssword);
|
|
|
|
|
|
+ txtConverter = new CPDFConverterTxt(inputpath, pawssword);
|
|
string outputFolder = outputpath;
|
|
string outputFolder = outputpath;
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
- string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".csv");
|
|
|
|
-
|
|
|
|
- result = await Task.Run(() => csvConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
|
|
+ string filename = GetFileNameAddSuffix(outputFolder, outputFileName, ".txt");
|
|
|
|
+ result = await Task.Run(() => txtConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -130,19 +164,23 @@ namespace PDF_Office.Helper
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- public static async Task<bool> TxtConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists, string pawssword)
|
|
|
|
|
|
+ public static async Task<bool> ImgConvert(string inputpath, string outputpath, OnProgress getProgress, List<int> pageIndexLists,string pawssword, ImgType type)
|
|
{
|
|
{
|
|
bool result = false;
|
|
bool result = false;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
int[] pageArray = pageIndexLists.ToArray();
|
|
|
|
|
|
- txtConverter = new CPDFConverterTxt(inputpath, pawssword);
|
|
|
|
|
|
+ imgConverter = new CPDFConverterImg(inputpath, pawssword);
|
|
string outputFolder = outputpath;
|
|
string outputFolder = outputpath;
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
string outputFileName = Path.GetFileNameWithoutExtension(inputpath);
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
ConvertError error = ConvertError.ERR_UNKNOWN;
|
|
- result = await Task.Run(() => txtConverter.Convert(outputFolder, ref outputFileName, pageArray, ref error, getProgress));
|
|
|
|
-
|
|
|
|
|
|
+ result = await Task.Run(() => imgConverter.Convert(outputFolder, ref outputFileName, pageArray, type, ref error, getProgress));
|
|
|
|
+ if (result)
|
|
|
|
+ {
|
|
|
|
+ if (File.Exists(outputFileName))
|
|
|
|
+ Process.Start(outputFileName);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -150,6 +188,7 @@ namespace PDF_Office.Helper
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
public static void Clear()
|
|
public static void Clear()
|
|
{
|
|
{
|
|
if (wordConverter != null)
|
|
if (wordConverter != null)
|
|
@@ -168,10 +207,10 @@ namespace PDF_Office.Helper
|
|
{
|
|
{
|
|
txtConverter.Cancel();
|
|
txtConverter.Cancel();
|
|
}
|
|
}
|
|
- if (tableConverter != null)
|
|
|
|
- {
|
|
|
|
- tableConverter.Cancel();
|
|
|
|
- }
|
|
|
|
|
|
+ //if (tableConverter != null)
|
|
|
|
+ //{
|
|
|
|
+ // tableConverter.Cancel();
|
|
|
|
+ //}
|
|
if (csvConverter != null)
|
|
if (csvConverter != null)
|
|
{
|
|
{
|
|
csvConverter.Cancel();
|
|
csvConverter.Cancel();
|