Pārlūkot izejas kodu

PDF

tags/录制修改前
zhangxueyang pirms 4 gadiem
vecāks
revīzija
bb481aa75d

+ 2
- 2
XHWK.WKTool/PracticeWindow.xaml.cs Parādīt failu

@@ -43,9 +43,9 @@ namespace XHWK.WKTool
43 43
             blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
44 44
             Pen();
45 45
             blackboard_canvas.Cursor = Cursors.Pen;
46
-            //Cursor cus = new Cursor(@"G:\Icon.ico");
46
+            Cursor cus = new Cursor(@"G:\Icon.cur");
47 47
             
48
-            //blackboard_canvas.Cursor = cus;
48
+            blackboard_canvas.Cursor = cus;
49 49
         }
50 50
 
51 51
 

+ 5
- 5
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs Parādīt failu

@@ -143,15 +143,15 @@ namespace XHWK.WKTool
143 143
         /// <param name="e"></param>
144 144
         private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
145 145
         {
146
+            if (APP.W_XHMicroLessonSystemWindow == null)
147
+            {
148
+                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
149
+            }
150
+            APP.W_XHMicroLessonSystemWindow.Show();
146 151
             if (!IsFirstRS)
147 152
             {
148 153
                 try
149 154
                 {
150
-                    if (APP.W_XHMicroLessonSystemWindow == null)
151
-                    {
152
-                        APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
153
-                    }
154
-                    APP.W_XHMicroLessonSystemWindow.Show();
155 155
                     try
156 156
                     {
157 157
                         APP.FFmpeg.StopFFmpeg(VideoSavePathName);

+ 76
- 2
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Parādīt failu

@@ -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>

+ 3
- 0
XHWK.WKTool/XHWK.WKTool.csproj Parādīt failu

@@ -62,6 +62,9 @@
62 62
     <Reference Include="Aspose.Words">
63 63
       <HintPath>..\dl\Aspose.Words.dll</HintPath>
64 64
     </Reference>
65
+    <Reference Include="itextsharp, Version=5.5.13.1, Culture=neutral, PublicKeyToken=8354ae6d2174ddca, processorArchitecture=MSIL">
66
+      <HintPath>..\packages\iTextSharp.5.5.13.1\lib\itextsharp.dll</HintPath>
67
+    </Reference>
65 68
     <Reference Include="log4net">
66 69
       <HintPath>..\Common\dlls\log4net.dll</HintPath>
67 70
     </Reference>

+ 1
- 0
XHWK.WKTool/packages.config Parādīt failu

@@ -7,5 +7,6 @@
7 7
   <package id="AForge.Video" version="2.2.5" targetFramework="net452" />
8 8
   <package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net452" />
9 9
   <package id="Aspose.PDF" version="19.1.0" targetFramework="net452" />
10
+  <package id="iTextSharp" version="5.5.13.1" targetFramework="net452" />
10 11
   <package id="WpfAnimatedGif" version="2.0.0" targetFramework="net452" />
11 12
 </packages>

Notiek ielāde…
Atcelt
Saglabāt