|
@@ -41,6 +41,10 @@ namespace XHWK.WKTool
|
41
|
41
|
public event ChangeTextHandler ChangeTextEvent;
|
42
|
42
|
//定义委托
|
43
|
43
|
public delegate void ChangeTextHandler(string text);
|
|
44
|
+ /// <summary>
|
|
45
|
+ /// 图片
|
|
46
|
+ /// </summary>
|
|
47
|
+ string [] ImgPDFPath = new string[300];
|
44
|
48
|
#endregion
|
45
|
49
|
|
46
|
50
|
#region 初始化
|
|
@@ -85,6 +89,8 @@ namespace XHWK.WKTool
|
85
|
89
|
drawingAttributes.IgnorePressure = false;
|
86
|
90
|
blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
|
87
|
91
|
wfhCamera.Visibility = Visibility.Hidden;
|
|
92
|
+ ImgPDFPath = null;
|
|
93
|
+ ImgPDFPath = new string[300];
|
88
|
94
|
}
|
89
|
95
|
#endregion
|
90
|
96
|
|
|
@@ -600,8 +606,8 @@ namespace XHWK.WKTool
|
600
|
606
|
}
|
601
|
607
|
#endregion
|
602
|
608
|
|
603
|
|
- APP.Paths = images.ToArray();
|
604
|
|
-
|
|
609
|
+ APP.Paths = images.ToArray();
|
|
610
|
+ ImgPDFPath= images.ToArray();
|
605
|
611
|
for (int i = 0; i < APP.Paths.Length; i++)
|
606
|
612
|
{
|
607
|
613
|
APP.pageData.pagenum += 1;
|
|
@@ -921,6 +927,58 @@ namespace XHWK.WKTool
|
921
|
927
|
/// <param name="e"></param>
|
922
|
928
|
private void BtnPrint_Click(object sender, RoutedEventArgs e)
|
923
|
929
|
{
|
|
930
|
+ if (APP.IsLoginType == false)
|
|
931
|
+ {
|
|
932
|
+ Login();
|
|
933
|
+ return;
|
|
934
|
+ }
|
|
935
|
+
|
|
936
|
+ //for(int i=0;i< APP.pageData.pagenum; i++)
|
|
937
|
+ //{
|
|
938
|
+
|
|
939
|
+ //}
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+ ////string[] files = { @"C:\101\1.jpg", @"C:\101\2.jpg" };
|
|
944
|
+ iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
|
|
945
|
+ try
|
|
946
|
+ {
|
|
947
|
+ iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(@"G:\101.pdf", FileMode.Create, FileAccess.ReadWrite));
|
|
948
|
+ document.Open();
|
|
949
|
+ iTextSharp.text.Image image;
|
|
950
|
+ for (int i = 0; i < ImgPDFPath.Length; i++)
|
|
951
|
+ {
|
|
952
|
+ if (String.IsNullOrEmpty(ImgPDFPath[i])) break;
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+ image = iTextSharp.text.Image.GetInstance(ImgPDFPath[i]);
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+ if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
|
|
959
|
+ {
|
|
960
|
+ image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
|
|
961
|
+ }
|
|
962
|
+ else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
|
|
963
|
+ {
|
|
964
|
+ image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
|
|
965
|
+ }
|
|
966
|
+ image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
|
|
967
|
+ document.NewPage();
|
|
968
|
+ document.Add(image);
|
|
969
|
+ //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
|
|
970
|
+ //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
|
|
971
|
+ //p1.Leading = 150; //行间距
|
|
972
|
+ //document.Add(p1);
|
|
973
|
+ }
|
|
974
|
+ Console.WriteLine("转换成功!");
|
|
975
|
+ }
|
|
976
|
+ catch (Exception ex)
|
|
977
|
+ {
|
|
978
|
+ Console.WriteLine("转换失败,原因:" + ex.Message);
|
|
979
|
+ }
|
|
980
|
+ document.Close();
|
|
981
|
+ ////Console.ReadKey();
|
924
|
982
|
|
925
|
983
|
}
|
926
|
984
|
/// <summary>
|
|
@@ -992,6 +1050,22 @@ namespace XHWK.WKTool
|
992
|
1050
|
{
|
993
|
1051
|
imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
|
994
|
1052
|
}
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+ try
|
|
1057
|
+ {
|
|
1058
|
+ Dispatcher.Invoke(() =>
|
|
1059
|
+ {
|
|
1060
|
+ string FilePathName = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" +"pdf"+ APP.pageData.currpage.ToString() + ".jpg";
|
|
1061
|
+ ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
|
|
1062
|
+ ImgPDFPath[APP.pageData.currpage - 1] =FilePathName;
|
|
1063
|
+ });
|
|
1064
|
+ }
|
|
1065
|
+ catch (Exception ex)
|
|
1066
|
+ {
|
|
1067
|
+ LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
|
|
1068
|
+ }
|
995
|
1069
|
}
|
996
|
1070
|
}
|
997
|
1071
|
/// <summary>
|