|
@@ -510,7 +510,7 @@ namespace XHWK.WKTool
|
510
|
510
|
Thread.Sleep(400);
|
511
|
511
|
Dispatcher.Invoke(new Action(() =>
|
512
|
512
|
{
|
513
|
|
- OpenDialogPPT();
|
|
513
|
+ OpenDialog();
|
514
|
514
|
}
|
515
|
515
|
));
|
516
|
516
|
})
|
|
@@ -524,36 +524,6 @@ namespace XHWK.WKTool
|
524
|
524
|
}
|
525
|
525
|
}
|
526
|
526
|
private void OpenDialog()
|
527
|
|
- {
|
528
|
|
- result = ofd.ShowDialog();
|
529
|
|
- if (result == System.Windows.Forms.DialogResult.OK)
|
530
|
|
- {
|
531
|
|
- if (ofd.FileName != "")
|
532
|
|
- {
|
533
|
|
- string filepath = ofd.FileName;
|
534
|
|
- string path = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
535
|
|
- APP.Paths = ConvertWordToImage(filepath, path, "", 0, 0, null, 0).ToArray();
|
536
|
|
-
|
537
|
|
- for (int i = 0; i < APP.Paths.Length; i++)
|
538
|
|
- {
|
539
|
|
- APP.pageData.pagenum += 1;
|
540
|
|
- }
|
541
|
|
- if (APP.pageData.pagenum > 1)
|
542
|
|
- {
|
543
|
|
- APP.pageData.pagenum -= 1;
|
544
|
|
- }
|
545
|
|
- if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
546
|
|
- {
|
547
|
|
- imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
|
548
|
|
- }
|
549
|
|
- else
|
550
|
|
- {
|
551
|
|
- imgCanvas.Source = null;
|
552
|
|
- }
|
553
|
|
- }
|
554
|
|
- }
|
555
|
|
- }
|
556
|
|
- private void OpenDialogPPT()
|
557
|
527
|
{
|
558
|
528
|
result = ofd.ShowDialog();
|
559
|
529
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
@@ -563,68 +533,110 @@ namespace XHWK.WKTool
|
563
|
533
|
#region PPT转PDF
|
564
|
534
|
string filepath = ofd.FileName;
|
565
|
535
|
string path = ofd.SafeFileName.Replace(".ppt", "").Trim();
|
566
|
|
- string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
567
|
|
- path = pathTemp + path + ".pdf";
|
568
|
|
- //PPT转PDF
|
569
|
|
- Presentation ppt = new Presentation(filepath);
|
570
|
|
- ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
|
571
|
|
- #endregion
|
572
|
|
-
|
573
|
|
-
|
574
|
|
- #region PDF转图片
|
575
|
|
- // 图片绝对路径集合
|
576
|
|
- List<string> images = new List<string>();
|
577
|
|
- string directoryPath = pathTemp;
|
578
|
|
- //aspose许可证
|
579
|
|
- //Aspose.Pdf.License l = new Aspose.Pdf.License();
|
580
|
|
- //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
|
581
|
|
- //l.SetLicense(licenseName);
|
582
|
|
- //定义Jpeg转换设备
|
583
|
|
- Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
|
584
|
|
- var device = new Aspose.Pdf.Devices.JpegDevice();
|
585
|
|
- //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
|
586
|
|
- //directoryPath += quality;
|
587
|
|
- Directory.CreateDirectory(directoryPath);
|
588
|
|
- //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
|
589
|
|
- device = new Aspose.Pdf.Devices.JpegDevice(100);
|
590
|
|
- //遍历每一页转为jpg
|
591
|
|
- for (var i = 1; i <= document.Pages.Count; i++)
|
|
536
|
+ string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Trim();
|
|
537
|
+ if (type.Contains("typezsygppt"))
|
592
|
538
|
{
|
593
|
|
- long ii = Timestamp();
|
594
|
|
- string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
|
595
|
|
- images.Add(filePathOutPut);
|
596
|
|
- FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
|
597
|
539
|
try
|
598
|
540
|
{
|
599
|
|
- device.Process(document.Pages[i], fs);
|
600
|
|
- fs.Close();
|
|
541
|
+ string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
|
542
|
+ path = pathTemp + path + ".pdf";
|
|
543
|
+ //PPT转PDF
|
|
544
|
+ Presentation ppt = new Presentation(filepath);
|
|
545
|
+ ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
|
|
546
|
+ #endregion
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+ #region PDF转图片
|
|
550
|
+ // 图片绝对路径集合
|
|
551
|
+ List<string> images = new List<string>();
|
|
552
|
+ string directoryPath = pathTemp;
|
|
553
|
+ //aspose许可证
|
|
554
|
+ //Aspose.Pdf.License l = new Aspose.Pdf.License();
|
|
555
|
+ //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
|
|
556
|
+ //l.SetLicense(licenseName);
|
|
557
|
+ //定义Jpeg转换设备
|
|
558
|
+ Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
|
|
559
|
+ var device = new Aspose.Pdf.Devices.JpegDevice();
|
|
560
|
+ //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
|
|
561
|
+ //directoryPath += quality;
|
|
562
|
+ Directory.CreateDirectory(directoryPath);
|
|
563
|
+ //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
|
|
564
|
+ device = new Aspose.Pdf.Devices.JpegDevice(100);
|
|
565
|
+ //遍历每一页转为jpg
|
|
566
|
+ for (var i = 1; i <= document.Pages.Count; i++)
|
|
567
|
+ {
|
|
568
|
+ long ii = Timestamp();
|
|
569
|
+ string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
|
|
570
|
+ images.Add(filePathOutPut);
|
|
571
|
+ FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
|
|
572
|
+ try
|
|
573
|
+ {
|
|
574
|
+ device.Process(document.Pages[i], fs);
|
|
575
|
+ fs.Close();
|
|
576
|
+ }
|
|
577
|
+ catch (Exception ex)
|
|
578
|
+ {
|
|
579
|
+ fs.Close();
|
|
580
|
+ File.Delete(filePathOutPut);
|
|
581
|
+ }
|
|
582
|
+ }
|
|
583
|
+ #endregion
|
|
584
|
+
|
|
585
|
+ APP.Paths = images.ToArray();
|
|
586
|
+ ImgPDFPath = images.ToArray();
|
|
587
|
+ for (int i = 0; i < APP.Paths.Length; i++)
|
|
588
|
+ {
|
|
589
|
+ APP.pageData.pagenum += 1;
|
|
590
|
+ }
|
|
591
|
+ if (APP.pageData.pagenum > 1)
|
|
592
|
+ {
|
|
593
|
+ APP.pageData.pagenum -= 1;
|
|
594
|
+ }
|
|
595
|
+ if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
|
596
|
+ {
|
|
597
|
+ imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
|
|
598
|
+ }
|
|
599
|
+ else
|
|
600
|
+ {
|
|
601
|
+ imgCanvas.Source = null;
|
|
602
|
+ }
|
601
|
603
|
}
|
602
|
604
|
catch (Exception ex)
|
603
|
605
|
{
|
604
|
|
- fs.Close();
|
605
|
|
- File.Delete(filePathOutPut);
|
|
606
|
+ LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog PPT)" + ex.Message, ex);
|
606
|
607
|
}
|
607
|
|
- }
|
608
|
|
- #endregion
|
609
|
|
-
|
610
|
|
- APP.Paths = images.ToArray();
|
611
|
|
- ImgPDFPath= images.ToArray();
|
612
|
|
- for (int i = 0; i < APP.Paths.Length; i++)
|
613
|
|
- {
|
614
|
|
- APP.pageData.pagenum += 1;
|
615
|
|
- }
|
616
|
|
- if (APP.pageData.pagenum > 1)
|
617
|
|
- {
|
618
|
|
- APP.pageData.pagenum -= 1;
|
619
|
|
- }
|
620
|
|
- if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
621
|
|
- {
|
622
|
|
- imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
|
623
|
608
|
}
|
624
|
609
|
else
|
625
|
610
|
{
|
626
|
|
- imgCanvas.Source = null;
|
|
611
|
+ try
|
|
612
|
+ {
|
|
613
|
+ string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
|
614
|
+ APP.Paths = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
|
|
615
|
+
|
|
616
|
+ for (int i = 0; i < APP.Paths.Length; i++)
|
|
617
|
+ {
|
|
618
|
+ APP.pageData.pagenum += 1;
|
|
619
|
+ }
|
|
620
|
+ if (APP.pageData.pagenum > 1)
|
|
621
|
+ {
|
|
622
|
+ APP.pageData.pagenum -= 1;
|
|
623
|
+ }
|
|
624
|
+ if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
|
625
|
+ {
|
|
626
|
+ imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
|
|
627
|
+ }
|
|
628
|
+ else
|
|
629
|
+ {
|
|
630
|
+ imgCanvas.Source = null;
|
|
631
|
+ }
|
|
632
|
+ }
|
|
633
|
+ catch (Exception ex)
|
|
634
|
+ {
|
|
635
|
+ LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog PDF)" + ex.Message, ex);
|
|
636
|
+ }
|
627
|
637
|
}
|
|
638
|
+
|
|
639
|
+
|
628
|
640
|
}
|
629
|
641
|
}
|
630
|
642
|
}
|
|
@@ -943,10 +955,15 @@ namespace XHWK.WKTool
|
943
|
955
|
iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
|
944
|
956
|
try
|
945
|
957
|
{
|
|
958
|
+ //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
|
|
959
|
+ //设置纸张横向
|
|
960
|
+ document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
|
|
961
|
+
|
|
962
|
+
|
946
|
963
|
iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(@"G:\101.pdf", FileMode.Create, FileAccess.ReadWrite));
|
947
|
964
|
document.Open();
|
948
|
965
|
iTextSharp.text.Image image;
|
949
|
|
- for (int i = 0; i < ImgPDFPath.Length; i++)
|
|
966
|
+ for (int i = 0; i < 10/*ImgPDFPath.Length*/; i++)
|
950
|
967
|
{
|
951
|
968
|
if (String.IsNullOrEmpty(ImgPDFPath[i])) break;
|
952
|
969
|
|
|
@@ -1002,6 +1019,21 @@ namespace XHWK.WKTool
|
1002
|
1019
|
{
|
1003
|
1020
|
if (APP.pageData.currpage > 1)
|
1004
|
1021
|
{
|
|
1022
|
+ try
|
|
1023
|
+ {
|
|
1024
|
+ Dispatcher.Invoke(() =>
|
|
1025
|
+ {
|
|
1026
|
+ string filePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/pdfimagetemp/");
|
|
1027
|
+ FileToolsCommon.CreateDirectory(filePath);
|
|
1028
|
+ string filePathName = filePath + APP.pageData.currpage.ToString() + ".jpg";
|
|
1029
|
+ ImageHelper.SaveUIToImage(GridMain, filePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
|
|
1030
|
+ ImgPDFPath[APP.pageData.currpage - 1] = filePathName;
|
|
1031
|
+ });
|
|
1032
|
+ }
|
|
1033
|
+ catch (Exception ex)
|
|
1034
|
+ {
|
|
1035
|
+ LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(last_button_Click)生成图片错误:" + ex.Message, ex);
|
|
1036
|
+ }
|
1005
|
1037
|
APP.pageData.currpage -= 1;
|
1006
|
1038
|
myblackboard.changepage(APP.pageData.currpage - 1);
|
1007
|
1039
|
if (APP.Paths.Length > 0)
|
|
@@ -1031,11 +1063,26 @@ namespace XHWK.WKTool
|
1031
|
1063
|
{
|
1032
|
1064
|
if (APP.pageData.currpage < APP.pageData.pagenum)
|
1033
|
1065
|
{
|
|
1066
|
+ try
|
|
1067
|
+ {
|
|
1068
|
+ Dispatcher.Invoke(() =>
|
|
1069
|
+ {
|
|
1070
|
+ string filePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/pdfimagetemp/");
|
|
1071
|
+ FileToolsCommon.CreateDirectory(filePath);
|
|
1072
|
+ string filePathName = filePath + APP.pageData.currpage.ToString() + ".jpg";
|
|
1073
|
+ ImageHelper.SaveUIToImage(GridMain, filePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
|
|
1074
|
+ ImgPDFPath[APP.pageData.currpage - 1] = filePathName;
|
|
1075
|
+ });
|
|
1076
|
+ }
|
|
1077
|
+ catch (Exception ex)
|
|
1078
|
+ {
|
|
1079
|
+ LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(next_btn_Click)生成图片错误:" + ex.Message, ex);
|
|
1080
|
+ }
|
1034
|
1081
|
APP.pageData.currpage += 1;
|
1035
|
1082
|
myblackboard.changepage(APP.pageData.currpage - 1);
|
1036
|
1083
|
if (APP.Paths.Length > 0)
|
1037
|
1084
|
{
|
1038
|
|
-
|
|
1085
|
+
|
1039
|
1086
|
if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.Paths.Length)
|
1040
|
1087
|
{
|
1041
|
1088
|
imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
|
|
@@ -1049,22 +1096,6 @@ namespace XHWK.WKTool
|
1049
|
1096
|
{
|
1050
|
1097
|
imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
|
1051
|
1098
|
}
|
1052
|
|
-
|
1053
|
|
-
|
1054
|
|
-
|
1055
|
|
- try
|
1056
|
|
- {
|
1057
|
|
- Dispatcher.Invoke(() =>
|
1058
|
|
- {
|
1059
|
|
- string FilePathName = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" +"pdf"+ APP.pageData.currpage.ToString() + ".jpg";
|
1060
|
|
- ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
|
1061
|
|
- ImgPDFPath[APP.pageData.currpage - 1] =FilePathName;
|
1062
|
|
- });
|
1063
|
|
- }
|
1064
|
|
- catch (Exception ex)
|
1065
|
|
- {
|
1066
|
|
- LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
|
1067
|
|
- }
|
1068
|
1099
|
}
|
1069
|
1100
|
}
|
1070
|
1101
|
/// <summary>
|