프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 2f1edec9

이력 | 보기 | 이력해설 | 다운로드 (71.4 KB)

1 7ca218b3 KangIngu
using IFinalPDF;
2
using iTextSharp.text.pdf;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Serialize.Core;
7
using MarkupToPDF.Serialize.S_Control;
8
using System;
9
using System.Collections.Generic;
10 7f01e35f ljiyeon
using System.Configuration;
11 7ca218b3 KangIngu
using System.IO;
12
using System.Linq;
13
using System.Net;
14 7f01e35f ljiyeon
using System.Runtime.InteropServices;
15 7ca218b3 KangIngu
using System.Text;
16
using System.Windows;
17
using System.Windows.Media;
18
19
namespace MarkupToPDF
20
{
21
    public class MarkupToPDF : IDisposable
22
    {
23
        #region 초기 데이터
24
        private static iTextSharp.text.Rectangle mediaBox;
25
        private FileInfo PdfFilePath = null;
26
        private FileInfo FinalPDFPath = null;
27
        private string _FinalPDFStorgeLocal = null;
28
        private string _FinalPDFStorgeRemote = null;
29
        private string OriginFileName = null;
30
        public FINAL_PDF FinalItem;
31
        public DOCINFO DocInfoItem = null;
32
        public List<DOCPAGE> DocPageItem = null;
33
        public MARKUP_INFO MarkupInfoItem = null;
34
        public List<MARKUP_DATA> MarkupDataSet = null;
35
        //private string _PrintPDFStorgeLocal = null;
36
        //private string _PrintPDFStorgeRemote = null;
37
        public event EventHandler<MakeFinalErrorArgs> FinalMakeError;
38
        public event EventHandler<EndFinalEventArgs> EndFinal;
39
40
        private iTextSharp.text.Rectangle pdfSize { get; set; }
41
        private double pageW = 0;
42
        private double pageH = 0;
43
44
        //private const double zoomLevel = 3.0;
45
        private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음
46
        #endregion
47
48
        #region 메서드        
49
        public static bool IsLocalIPAddress(string host)
50
        {
51
            try
52
            {
53
                IPAddress[] hostIPs = Dns.GetHostAddresses(host);
54
                IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
55
56
                foreach (IPAddress hostIP in hostIPs)
57
                {
58
                    if (IPAddress.IsLoopback(hostIP)) return true;
59
60
                    foreach (IPAddress localIP in localIPs)
61
                    {
62
                        if (hostIP.Equals(localIP)) return true;
63
                    }
64
                }
65
            }
66
            catch { }
67
            return false;
68
        }
69
70
        private void SetNotice(string finalID , string message)
71
        {
72
            if (FinalMakeError != null)
73
            {
74
                FinalMakeError(this, new MakeFinalErrorArgs { FinalID = finalID, Message = message });
75
            }
76
        }
77
78
        private string GetFileName(string hrefLink)
79
        {
80
            return System.IO.Path.GetFileName(hrefLink.Replace("/", "\\"));
81
        }
82
83
        public Point GetPdfPointSystem(Point point)
84
        {
85
            point = new Point(point.X + pdfSize.Left * scaleWidth, point.Y - pdfSize.Bottom * scaleHeight);
86
            return new Point((float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight));
87
        }
88
89 488ba687 humkyung
        public double GetPdfSize(double size)
90
        {
91
            return (size / scaleWidth);
92
        }
93
94 7ca218b3 KangIngu
        public List<Point> GetPdfPointSystem(List<Point> point) 
95
        {
96
            List<Point> dummy = new List<Point>();
97
            foreach (var item in point)
98
            {
99
                dummy.Add(GetPdfPointSystem(item));
100
            }
101
            return dummy;
102
        }
103
104
        public double returnAngle(Point start, Point end)
105
        {
106
            double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y);
107
            //angle *= -1;
108
109
            angle += 90;
110
            //if (angle < 0)
111
            //{
112
            //    angle = angle + 360;
113
            //}
114
            return angle;
115
        }
116
117
        public string replaceXY(string text)
118
        {
119
            return text.Replace(@"_x", @"X").Replace(@"_y", @"Y");
120
121
        }
122
123
124
125
        #endregion
126
127
        #region 생성자 & 소멸자
128
        public void MakeFinalPDF(object _FinalPDF)
129
        {
130
            
131
            DOCUMENT_ITEM documentItem;
132
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
133
            FinalItem = FinalPDF;
134
135
136
            string PdfFilePathRoot = null;
137
            string TestFile = System.IO.Path.GetTempFileName();
138
139
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
140 488ba687 humkyung
            try
141 7ca218b3 KangIngu
            {
142
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
143
                {
144
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
145
146
                    if (_properties.Count () > 0)
147
                    {
148
                        PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
149
                        _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
150
                        _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
151
                    }
152
                    else
153
                    {
154
                        SetNotice(FinalPDF.ID, "프로퍼티를 가지고 올 수 없습니다.");
155
                        return;
156
                    }
157
158
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
159
160
                    if (finalList.Count() > 0)
161
                    {
162
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
163
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
164
                        _entity.SaveChanges(); 
165
                    }
166
                }
167
            }
168
            catch (Exception ex)
169
            {
170
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
171
                return;
172
            }
173
            #endregion
174
175
            #region 문서 복사
176
            try
177
            {
178
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
179
                {
180
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
181
182
                    if (_DOCINFO.Count() > 0)
183
                    {
184
                        DocInfoItem = _DOCINFO.FirstOrDefault();
185
                        DocPageItem = DocInfoItem.DOCPAGE.ToList();
186
187
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
188
                                         + (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString()
189
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
190
191
                        MarkupInfoItem = DocInfoItem.MARKUP_INFO.Where(data => data.CONSOLIDATE == 1 && data.AVOID_CONSOLIDATE == 0 && data.PART_CONSOLIDATE == 0).FirstOrDefault();
192
193
                        if (MarkupInfoItem == null)
194
                        {
195
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
196
                        }
197
                        else
198
                        {
199
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0)
200
                            {
201
                                MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d=>d.PAGENUMBER).ToList();
202
                            }
203
                            else
204
                            {
205
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
206
                            }
207
                        }
208
209
                        using (CIEntities _ci_Internal = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
210
                        {
211
                            documentItem = _ci_Internal.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID).FirstOrDefault();
212
                            if (documentItem == null)
213
                            {
214
                                throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
215
                            }
216
217
                            var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 
218
219
                            #region 파일 체크
220
                            if (_files.Count() == 1)
221
                            {
222
                                if (_files.First().Name.ToLower() == GetFileName(documentItem.ORIGINAL_FILE).ToLower())
223
                                {
224
                                    OriginFileName = _files.First().Name;
225
                                    PdfFilePath = _files.First().CopyTo(TestFile, true);
226
                                }
227
                                else
228
                                {
229
                                    throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다");
230
                                }
231
                            }
232
                            else if (_files.Count() > 1)
233
                            {
234
                                var originalFile = _files.Where(data => data.Name == GetFileName(documentItem.ORIGINAL_FILE)).FirstOrDefault();
235
236
                                if (originalFile == null)
237
                                {
238
                                    throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
239
                                }
240
                                else
241
                                {
242
                                    OriginFileName = originalFile.Name;
243
                                    PdfFilePath = originalFile.CopyTo(TestFile, true);
244
                                }
245
                            }
246
                            else
247
                            {
248
                                throw new Exception("PDF를 찾지 못하였습니다");
249
                            }
250
                            #endregion
251
252
                            #region 예외처리
253
                            if (PdfFilePath == null)
254
                            {
255
                                throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
256
                            }
257
                            if (!PdfFilePath.Exists)
258
                            {
259
                                throw new Exception("PDF원본이 존재하지 않습니다");
260
                            }
261
                            #endregion
262
                        }
263
                    }
264
                    else
265
                    {
266
                        throw new Exception("일치하는 DocInfo가 없습니다");
267
                    }
268
                }
269
            }
270
            catch (Exception ex)
271
            {
272
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
273
                {
274
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
275
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
276
                    process.StartInfo.FileName = "cmd";
277
                    process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
278
                    process.Start();
279
                }
280
                else
281
                {
282
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
283
                }
284
            }
285
            #endregion
286
287
            try
288
            {
289
290
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
291
                {
292
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
293
294
                    if (finalList.Count() > 0)
295
                    {
296
                        TestFile = SetFlattingPDF(TestFile);
297
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.Insert;
298
                        //_entity.SaveChanges();
299
300
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
301
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.PdfStamp;
302
                        //_entity.SaveChanges();
303
                    }
304
                }
305
                    if (EndFinal != null)
306
                    {
307
                        EndFinal(this, new EndFinalEventArgs
308
                        {
309
                            OriginPDFName = OriginFileName,
310
                            FinalPDFPath = _FinalPDFStorgeRemote + "\\" + FinalPDFPath.Name,
311
                            Error = "",
312
                            Message = "",
313
                            FinalPDF = FinalPDF,
314
                        });
315
                    }
316
            }
317
            catch (Exception ex)
318
            {
319
320
                throw;
321
            }
322
        }
323
        #endregion
324
325
        #region PDF
326
        float scaleWidth = 0;
327
        float scaleHeight = 0;
328
329
         
330
        private string SetFlattingPDF(string tempFileInfo)
331
        {
332
            if (File.Exists(tempFileInfo))
333
            {
334
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
335
336
                PdfReader pdfReader = new PdfReader(tempFileInfo);
337
                for (int i = 1; i < pdfReader.NumberOfPages; i++)
338
                {
339
                    var mediaBox = pdfReader.GetPageSize(i);
340
                    var cropbox = pdfReader.GetCropBox(i);
341
342
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
343
                    //{
344
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
345
                    //}
346
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
347
348
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
349
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
350
                    //scaleWidth = 2.0832634F;
351
                    //scaleHeight = 3.0F;
352
353
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
354
                    //강인구 수정
355
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
356
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
357
                    //{
358
                    //    var pageDict = pdfReader.GetPageN(i);
359
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
360
                    //}
361
                }
362
363
                var memStream = new MemoryStream();
364
                var stamper = new PdfStamper(pdfReader, memStream)
365
                {
366
                    FormFlattening = true,
367
                    FreeTextFlattening = true,
368
                    AnnotationFlattening = true,
369
                };
370
371
                stamper.Close();
372
                pdfReader.Close();
373
                var array = memStream.ToArray();
374
                File.Delete(tempFileInfo);
375
                File.WriteAllBytes(TestFile.FullName, array);
376
377
                return TestFile.FullName;
378
            }
379
            else
380
            {
381
                return tempFileInfo;
382
            }
383
        }
384
385
        public void flattenPdfFile(string src, ref string dest)
386
        {
387
            PdfReader reader = new PdfReader(src);
388
            var memStream = new MemoryStream();
389
            var stamper = new PdfStamper(reader, memStream)
390
            {
391
                FormFlattening = true,
392
                FreeTextFlattening = true,
393
                AnnotationFlattening = true,
394
            };
395
396
            stamper.Close();
397
            var array = memStream.ToArray();
398
            File.WriteAllBytes(dest, array);
399
        }
400
401
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
402
        {
403
            string pdfFilePath = null;
404
            FileInfo tempFileInfo = new FileInfo(testFile);
405
406
            if (!Directory.Exists(_FinalPDFStorgeLocal))
407
            {
408
                Directory.CreateDirectory(_FinalPDFStorgeLocal);
409
            }
410
            pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name;
411
412
            using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
413
            {
414
                FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
415
416
                #region 코멘트 적용 + 커버시트
417
                using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
418
                {
419
                    PdfReader pdfReader = new PdfReader(pdfStream);
420
                    //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
421
                    Dictionary<string, object> bookmark;
422
                    List<Dictionary<string, object>> outlines;
423
                    outlines = new List<Dictionary<string, object>>();
424
                    List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
425
426
                    var dic = new Dictionary<string, object>();
427
                    MarkupDataSet.Select(d => d.PAGENUMBER).ToList().ForEach(a =>
428
                      {
429
                          bookmark = new Dictionary<string, object>();
430
                          bookmark.Add("Title", "Commented Page : " + a);
431
                          bookmark.Add("Page", a + " Fit");
432
                          //bookmark.Add("Page", "2 /XYZ 50 500 50 50");
433
                          bookmark.Add("Action", "GoTo");
434
                          bookmark.Add("Kids", outlines);
435
                          root.Add(bookmark);
436
                      });
437
438
439
                    using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
440
                    {
441
                        var _SetColor = new SolidColorBrush(Colors.Red);
442
                        
443
                        string[] delimiterChars = { "|DZ|" };
444
                        string[] delimiterChars2 = { "|" };
445
446
                        //pdfStamper.FormFlattening = true; //이미 선처리 작업함
447
                        pdfStamper.SetFullCompression();
448
                        _SetColor = new SolidColorBrush(Colors.Red);
449
450
                        foreach (var markupItem in MarkupDataSet)
451
                        {
452
                            pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
453
                            var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault();
454
455
                            mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
456
                            var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
457
458
                            //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
459
                            //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
460
                            
461
                            //강인구 테스트
462
                            scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
463
                            scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
464
465 f633b10b KangIngu
                            if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
466 7ca218b3 KangIngu
                            {
467
                                mediaBox = cropBox;
468
                            }
469
                            
470
                            pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
471
                            _entity.SaveChanges();
472
473
                            string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
474
475
                            PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
476
477
                            
478
                            foreach (var data in markedData)
479
                            {
480
                                
481
                                var item = JsonSerializerHelper.UnCompressString(data);
482
                                //item = data.Replace("H", "_h");
483
                                var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
484
485
                                try
486
                                {
487
                                    switch (ControlT.Name)
488
                                    {
489
                                        #region LINE
490
                                        case "LineControl":
491
                                            {
492
                                                using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
493
                                                {
494
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
495
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
496
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
497
                                                    DoubleCollection DashSize = control.DashSize;
498
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
499
500
                                                    var Opacity = control.Opac;
501
                                                    string UserID = control.UserID;
502
                                                    double Interval = control.Interval;
503
                                                    double LineSize = Convert.ToDouble(InnerData.First());
504
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
505
                                                    switch (control.LineStyleSet)
506
                                                    {
507
                                                        //case LineStyleSet.SingleLine:
508
                                                        //    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
509
                                                        //    break;
510
                                                        case LineStyleSet.ArrowLine:
511
                                                            //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
512
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
513
                                                            break;
514
                                                        case LineStyleSet.CancelLine:
515
                                                            {
516
                                                                var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X)));
517
                                                                var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y)));
518
519
                                                                if (x > y)
520
                                                                {
521
                                                                    StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
522
                                                                    EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
523
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity);
524
                                                                }
525
                                                            }
526
                                                            break;
527
                                                        case LineStyleSet.TwinLine:
528
                                                            {
529
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
530
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
531
                                                                //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
532
                                                            }
533
                                                            break;
534
                                                        case LineStyleSet.DimLine:
535
                                                            {
536
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
537
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
538
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
539
                                                            }
540
                                                            break;
541
                                                        default:
542
                                                            break;
543
                                                    }
544
545
                                                    
546
                                                }
547
                                            }
548
                                            break;
549
                                        #endregion
550
                                        #region ArrowControlMulti
551
                                        case "ArrowControl_Multi":
552
                                            {
553
                                                using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
554
                                                {
555
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
556
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
557
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
558
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
559
                                                    DoubleCollection DashSize = control.DashSize;
560
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
561
                                                    double LineSize = Convert.ToDouble(InnerData.First());
562
563
                                                    double Opacity = control.Opac;
564
565
                                                    if (EndPoint == MidPoint)
566
                                                    {
567
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
568
                                                    }
569
                                                    else
570
                                                    {
571
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
572
                                                    }
573
574
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
575
576
                                                }
577
                                            }
578
                                            break;
579
                                        #endregion
580
                                        #region PolyControl
581
                                        case "PolygonControl":
582
                                         using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize <S_PolyControl>(item))
583
                                         {
584
                                                string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
585
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
586
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
587
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
588
                                                double LineSize = Convert.ToDouble(InnerData.First());
589
                                                double Opacity = control.Opac;
590
                                                DoubleCollection DashSize = control.DashSize;
591
592
                                                Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
593
                                            }
594
                                        break;
595
                                        #endregion
596
                                        #region ArcControl
597
                                        case "ArcControl":
598
                                            {
599
                                                using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
600
                                                {
601
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
602
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
603
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
604
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
605
                                                    DoubleCollection DashSize = control.DashSize;
606
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
607
608
                                                    var Opacity = control.Opac;
609
                                                    string UserID = control.UserID;
610
                                                    double LineSize = Convert.ToDouble(InnerData.First());
611
                                                    bool IsTransOn = control.IsTransOn;
612
613
                                                    if (control.IsTransOn)
614
                                                    {
615
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
616
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
617
                                                    }
618
                                                    else
619
                                                    {
620
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
621
                                                    }
622
623
                                                }
624
                                            }
625
                                            break;
626
                                        #endregion
627
                                        #region RectangleControl
628
                                        case "RectangleControl":
629
                                        using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
630
                                        {
631
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
632
                                                double LineSize = Convert.ToDouble(data2.First());
633
                                                var PaintStyle = control.PaintState;
634
                                                double Angle = control.Angle;
635
                                                DoubleCollection DashSize = control.DashSize;
636
                                                double Opacity = control.Opac;
637
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
638
                                                //bookmark = new Dictionary<string, object>();
639
                                                //bookmark.Add("Title", "Commented Page : " + markupItem.PAGENUMBER);
640
                                                //bookmark.Add("Page", a + " Fit");
641
                                                //bookmark.Add("Page",  "2 /XYZ 50 500 50 50");
642
                                                //var pointRect = MathSet.GetPointsToRectX(PointSet);
643
644
                                                //PdfDestination.INDIRECT
645
                                                //bookmark.Add("Page", String.Format("{0} /XYZ {1} {2} {3}", markupItem.PAGENUMBER, pointRect.Left, pointRect.Top, 1f));
646
                                                //bookmark.Add("Action", "GoTo");
647
                                                //bookmark.Add("Kids", outlines);
648
                                                //root.Add(bookmark);
649
650
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
651
                                        }
652
                                        break;
653
                                        #endregion
654
                                        #region TriControl
655
                                        case "TriControl":
656
                                        using (S_TriControl control  = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
657
                                        {
658
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
659
                                                double LineSize = Convert.ToDouble(data2.First());
660
                                                var PaintStyle = control.Paint;
661
                                                double Angle = control.Angle;
662
                                                //StrokeColor = _SetColor, //색상은 레드
663
                                                DoubleCollection DashSize = control.DashSize;
664
                                                double Opacity = control.Opac;
665
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
666
667
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
668
                                            }
669
                                        break;
670
                                        #endregion
671
                                        #region CircleControl
672
                                        case "CircleControl":                                            
673
                                            using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
674
                                            {
675
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
676
                                                double LineSize = Convert.ToDouble(data2.First());
677
                                                var StartPoint = GetPdfPointSystem(control.StartPoint);
678
                                                var EndPoint = GetPdfPointSystem(control.EndPoint);
679
                                                var PaintStyle = control.PaintState;
680
                                                double Angle = control.Angle;
681
                                                DoubleCollection DashSize = control.DashSize;
682
                                                double Opacity = control.Opac;
683
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
684
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
685
686
                                            }
687
                                        break;
688
                                        #endregion
689
                                        #region RectCloudControl
690
                                        case "RectCloudControl":
691
                                            using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
692
                                            {
693
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
694
                                                double LineSize = Convert.ToDouble(data2.First());
695
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
696 53393bae KangIngu
                                                //double ArcLength = 30;
697 7ca218b3 KangIngu
                                                double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
698 f633b10b KangIngu
699 53393bae KangIngu
700
                                                double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength;
701
702
                                                //ArcLength = (size * 0.13);
703 f633b10b KangIngu
704
                                                //강인구 수정(클라우드 사이즈)
705
                                                //if (ArcLength <= 10)
706
                                                //{
707
                                                //    ArcLength = 10;
708
                                                //}
709 53393bae KangIngu
                                                //if (ArcLength <= 3)
710
                                                //{
711
                                                //    ArcLength = 10;
712
                                                //}
713
                                                //else if (ArcLength <= 10)
714
                                                //{
715
                                                //    ArcLength = 20;
716
                                                //}
717
                                                //else if (ArcLength <= 30)
718
                                                //{
719
                                                //    ArcLength = 30;
720
                                                //}
721 f633b10b KangIngu
722 7ca218b3 KangIngu
                                                var PaintStyle = control.PaintState;
723
                                                double Opacity = control.Opac;
724
                                                DoubleCollection DashSize = control.DashSize;
725
726
                                                //드로잉 방식이 표현되지 않음
727
                                                var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
728
729
                                                double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
730
                                                bool reverse = (area < 0);
731
                                                if (PaintStyle == PaintSet.None)
732
                                                {
733 23b7be0e humkyung
                                                    Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
734 7ca218b3 KangIngu
                                                }
735
                                                else
736
                                                {
737 23b7be0e humkyung
                                                    Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
738 7ca218b3 KangIngu
                                                }
739
                                            }
740
                                            break;
741
                                        #endregion
742
                                        #region CloudControl
743
                                        case "CloudControl":
744
                                            using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
745
                                            {
746
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
747
                                                double LineSize = Convert.ToDouble(data2.First());
748
                                                double Toler = control.Toler;
749
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
750 53393bae KangIngu
                                                double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength;
751 7ca218b3 KangIngu
                                                var PaintStyle = control.PaintState;
752
                                                double Opacity = control.Opac;
753
                                                bool isTransOn = control.IsTrans;
754
                                                bool isChain = control.IsChain;
755
756
                                                DoubleCollection DashSize = control.DashSize;
757
758
                                                if (isChain)
759
                                                {
760
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
761
                                                }
762
                                                else
763
                                                {
764
                                                    if (isTransOn)
765
                                                    {
766
                                                        double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
767
                                                        bool reverse = (area < 0);
768
769
                                                        if (PaintStyle == PaintSet.None)
770
                                                        {
771 23b7be0e humkyung
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
772 7ca218b3 KangIngu
                                                        }
773
                                                        else
774
                                                        {
775 23b7be0e humkyung
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
776 7ca218b3 KangIngu
                                                        }
777
                                                    }
778
                                                    else
779
                                                    {
780
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
781
                                                    }
782
                                                }
783
                                            }
784
                                        break;
785
                                        #endregion
786
                                        #region TEXT
787
                                        case "TextControl":
788
                                            using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
789
                                            {
790
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
791
                                                string Text = " " + replaceXY(control.Text);
792
793
                                                bool isUnderline = false;
794
                                                control.BoxW -= scaleWidth;
795
                                                control.BoxH -= scaleHeight;
796
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
797
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
798
                                                Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
799
800
                                                List<Point> pointSet = new List<Point>();
801
                                                pointSet.Add(StartPoint);
802
                                                pointSet.Add(EndPoint);
803
804
                                                PaintSet paint = PaintSet.None;
805
                                                switch (control.paintMethod)
806
                                                {
807
                                                    case 1:
808
                                                        {
809
                                                            paint = PaintSet.Fill;
810
                                                        }
811
                                                        break;
812
                                                    case 2:
813
                                                        {
814
                                                            paint = PaintSet.Hatch;
815
                                                        }
816
                                                        break;
817
                                                    default:
818
                                                        break;
819
                                                }
820 488ba687 humkyung
                                                if (control.isHighLight) paint |= PaintSet.Highlight;
821 7ca218b3 KangIngu
822
                                                double LineSize = Convert.ToDouble(data2.First());
823
                                                double TextSize = Convert.ToDouble(data2[1]);
824
                                                SolidColorBrush FontColor = _SetColor;
825
                                                double Angle = control.Angle;
826
                                                double Opacity = control.Opac;
827
                                                FontFamily fontfamilly = new FontFamily(control.fontConfig[0]);
828
                                                var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
829
830
                                                FontStyle fontStyle = FontStyles.Normal;
831
                                                if (FontStyles.Italic == TextStyle)
832
                                                {
833
                                                    fontStyle = FontStyles.Italic;
834
                                                }
835
836
                                                FontWeight fontWeight = FontWeights.Black;
837
838
                                                var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
839 d4b0c723 KangIngu
                                                //강인구 수정(2018.04.17)
840
                                                if (FontWeights.Bold == TextWeight)
841
                                                //if (FontWeights.ExtraBold == TextWeight)
842 7ca218b3 KangIngu
                                                {
843
                                                    fontWeight = FontWeights.Bold;
844
                                                }
845
846
                                                TextDecorationCollection decoration = TextDecorations.Baseline;
847
                                                if (control.fontConfig.Count() == 4)
848
                                                {
849
                                                    decoration = TextDecorations.Underline;
850
                                                }
851
852
                                                if (LineSize <= 3)
853
                                                {
854
                                                    LineSize = 3;
855
                                                }
856
857 23b7be0e humkyung
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
858 7ca218b3 KangIngu
                                            }
859
                                            break;
860
                                        #endregion
861
                                        #region ArrowTextControl
862
                                        case "ArrowTextControl":
863
                                            using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item))
864
                                            {
865
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
866
                                                Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
867
                                                Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
868
                                                Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
869
                                                bool isUnderLine = false;
870
                                                string Text = "";
871 488ba687 humkyung
                                                double fontsize = 30;
872 7ca218b3 KangIngu
873
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
874
                                                Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
875
                                                List<Point> tempPoint = new List<Point>();
876
877
                                                var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
878
879
                                                tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
880
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
881
                                                tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
882
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
883
                                                double Angle = control.Angle;
884
                                                var newStartPoint = tempStartPoint;
885
                                                var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
886
                                                var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
887
888
                                                double LineSize = Convert.ToDouble(data2.First());
889
                                                SolidColorBrush FontColor = _SetColor;
890
                                                bool isHighlight = control.isHighLight;
891
                                                double Opacity = control.Opac;
892
                                                PaintSet Paint = PaintSet.None;
893
894
                                                switch (control.ArrowStyle)
895
                                                {
896
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
897
                                                        {
898
                                                            Paint = PaintSet.None;
899
                                                        }
900
                                                        break;
901
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
902
                                                        {
903
                                                            Paint = PaintSet.Hatch;
904
                                                        }
905
                                                        break;
906
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
907
                                                        {
908
                                                            Paint = PaintSet.Fill;
909
                                                        }
910
                                                        break;
911
                                                    default:
912
                                                        break;
913
                                                }
914 488ba687 humkyung
                                                if (control.isHighLight) Paint |= PaintSet.Highlight;
915 7ca218b3 KangIngu
916
                                                if (Paint == PaintSet.Hatch)
917
                                                {
918
                                                    Text = replaceXY(control.ArrowText);
919
                                                }
920
                                                else
921
                                                {
922
                                                    Text = " " + replaceXY(control.ArrowText);
923
                                                }
924
925
                                                try
926
                                                {
927
                                                    if (control.fontConfig.Count == 4)
928
                                                    {
929 488ba687 humkyung
                                                        fontsize = Convert.ToDouble(control.fontConfig[3]);
930 7ca218b3 KangIngu
                                                    }
931 f633b10b KangIngu
932
                                                    //강인구 수정(2018.04.17)
933
                                                    var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
934
935
                                                    FontStyle fontStyle = FontStyles.Normal;
936
                                                    if (FontStyles.Italic == TextStyle)
937
                                                    {
938
                                                        fontStyle = FontStyles.Italic;
939
                                                    }
940
941
                                                    FontWeight fontWeight = FontWeights.Black;
942
943
                                                    var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
944
                                                    if (FontWeights.Bold == TextWeight)
945
                                                    {
946
                                                        fontWeight = FontWeights.Bold;
947
                                                    }
948
949
                                                    TextDecorationCollection decoration = TextDecorations.Baseline;
950
                                                    if (control.fontConfig.Count() == 5)
951
                                                    {
952
                                                        decoration = TextDecorations.Underline;
953
                                                    }
954
955 7ca218b3 KangIngu
                                                if (control.isTrans)
956
                                                {
957
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(newStartPoint, tempMidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
958
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(newStartPoint, tempMidPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
959
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(tempMidPoint, newEndPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
960 f633b10b KangIngu
                                                    //인구 수정 Arrow Text Style적용 되도록 변경
961
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize,
962
                                                                                            contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
963
                                                    //Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, 
964
                                                    //                                        contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), new FontStyle(), new FontWeight(), new TextDecorationCollection(), Text, sizeF, Opacity, Angle);
965 7ca218b3 KangIngu
966
                                                }
967
                                                else
968
                                                {
969
                                                    if (control.isFixed)
970
                                                    {
971
                                                        var testP = new Point(0, 0);
972
                                                        if (control.isFixed)
973
                                                        {
974
                                                            if (tempPoint[1] == newEndPoint)
975
                                                            {
976
                                                                testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
977
                                                            }
978
                                                            else if (tempPoint[3] == newEndPoint)
979
                                                            {
980
                                                                testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
981
                                                            }
982
                                                            else if (tempPoint[0] == newEndPoint)
983
                                                            {
984
                                                                testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
985
                                                            }
986
                                                            else if (tempPoint[2] == newEndPoint)
987
                                                            {
988
                                                                testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
989
                                                            }
990
                                                        }
991
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(tempStartPoint, testP, (int)LineSize, contentByte, _SetColor, Opacity);
992
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(tempStartPoint, testP, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
993
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(testP, newEndPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
994 f633b10b KangIngu
995
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
996 7ca218b3 KangIngu
                                                        //Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / 3, tempEndPoint.Y - control.BoxHeight / 3), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
997
                                                        //                                                   new FontFamily(), new FontStyle(), new FontWeight(), new TextDecorationCollection(), Text, sizeF, Opacity, Angle);
998
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
999 f633b10b KangIngu
                                                        new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1000 7ca218b3 KangIngu
                                                    }
1001
                                                    else
1002
                                                    {
1003
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(newStartPoint, newMidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
1004
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(newStartPoint, newMidPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
1005
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(newMidPoint, newEndPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
1006 f633b10b KangIngu
1007
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
1008
                                                        //Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), new FontStyle(), new FontWeight(), new TextDecorationCollection(), Text, sizeF, Opacity, Angle);
1009
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1010
1011
1012
                                                        }
1013
                                                }
1014
1015
                                                }
1016
                                                catch (Exception ex)
1017
                                                {
1018
1019 7ca218b3 KangIngu
                                                }
1020
                                            }
1021
                                            break;
1022
                                        #endregion
1023
                                        #region SignControl
1024
                                        case "SignControl":
1025
                                            using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1026
                                            {
1027
                                                
1028
                                                double Angle = control.Angle;
1029
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1030
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1031
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1032
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1033
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1034
                                                double Opacity = control.Opac;
1035
                                                string UserNumber = control.UserNumber;
1036
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1037
                                            }
1038
                                            break;
1039
                                        #endregion
1040
                                        #region MyRegion
1041
                                        case "DateControl":
1042
                                            using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1043
                                            {
1044
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1045
                                                string Text = control.Text;
1046
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1047
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1048
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1049
                                                SolidColorBrush FontColor = _SetColor;
1050
                                                double Angle = control.Angle;
1051
                                                double Opacity = control.Opac;
1052
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1053
                                            }
1054
                                        break;
1055
                                        #endregion
1056
                                        #region SymControlN (APPROVED)
1057
                                        case "SymControlN":
1058
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1059
                                            {
1060
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1061
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1062
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1063
                                                SolidColorBrush FontColor = _SetColor;
1064
                                                double Angle = control.Angle;
1065
                                                double Opacity = control.Opac;
1066 7f01e35f ljiyeon
1067
                                                StringBuilder ApprovedImgPath = new StringBuilder(512);
1068
                                                GetPrivateProfileString("ApprovedImgPath", "URL", "(NONE)", ApprovedImgPath, 512, "C:\\ProgramData\\MARKUS\\settings.ini");
1069
1070 2f1edec9 ljiyeon
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, ApprovedImgPath.ToString());
1071 7ca218b3 KangIngu
                                            }
1072
                                            break;
1073
                                        #endregion
1074
                                        #region Image
1075
                                        case "ImgControl":
1076
                                            using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1077
                                            {
1078
                                                double Angle = control.Angle;
1079
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1080
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1081
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1082
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1083
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1084
                                                double Opacity = control.Opac;
1085
                                                string FilePath = control.ImagePath;
1086
                                                //Uri uri = new Uri(s.ImagePath);
1087
1088
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1089
                                            }
1090
                                            break;
1091
                                        #endregion
1092
                                        default:
1093
                                            break;
1094
                                    }
1095
                                }
1096
                                catch (Exception ex)
1097
                                {
1098
                                    
1099
                                }
1100
                            }
1101
                        }
1102
                        pdfStamper.Outlines = root;
1103
                        pdfStamper.Close();
1104
                        pdfReader.Close();
1105 53393bae KangIngu
                    } 
1106 7ca218b3 KangIngu
                }
1107
                #endregion
1108
            }
1109
1110
            try
1111
            {
1112
                if (tempFileInfo.Exists)
1113
                {
1114
                    tempFileInfo.Delete();
1115
                }
1116
1117
                if (File.Exists(pdfFilePath))
1118
                {
1119
1120
                    FinalPDFPath = new FileInfo(pdfFilePath);
1121
1122 4a1073c1 humkyung
                    ///TODO : 복사할 경로를 configuration으로 빼주세요
1123 7f01e35f ljiyeon
                    //File.Move(FinalPDFPath.FullName, @"\\192.168.0.67\finalpdf\" + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1124
                    //FinalPDFPath = new FileInfo(@"\\192.168.0.67\finalpdf\" + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1125
                    StringBuilder PDFMovePath = new StringBuilder(255);
1126
                    GetPrivateProfileString("PDFMovePath", "URL", "(NONE)", PDFMovePath, 32, "C:\\ProgramData\\MARKUS\\settings.ini");
1127
                    File.Move(FinalPDFPath.FullName, PDFMovePath.ToString() + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1128
                    FinalPDFPath = new FileInfo(PDFMovePath.ToString() + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1129 7ca218b3 KangIngu
1130
                    try
1131
                    {
1132
                        File.Delete(pdfFilePath);
1133
                    }
1134
                    catch (Exception ex)
1135
                    {
1136
                        System.Diagnostics.Debug.Write("삭제 불가" + ex.Message);
1137
                    }
1138
                    //
1139
1140
                    return true;
1141
                }
1142
            }
1143
            catch (Exception ex)
1144
            {
1145
1146
                throw;
1147
            }
1148
1149
            return false;
1150
        }
1151
1152
        public void Dispose()
1153
        {
1154
            throw new NotImplementedException();
1155
        }
1156 7f01e35f ljiyeon
1157
        [DllImport("kernel32")]
1158
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal,
1159
                                                        int size, string filePath);
1160
1161 7ca218b3 KangIngu
        #endregion
1162
    }
1163
}
클립보드 이미지 추가 (최대 크기: 500 MB)