프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 43e1d368

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

1
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 Markus.Fonts;
9
using System;
10
using System.Collections.Generic;
11
using System.Configuration;
12
using System.IO;
13
using System.Linq;
14
using System.Net;
15
using System.Runtime.InteropServices;
16
using System.Text;
17
using System.Web;
18
using System.Windows;
19
using System.Windows.Media;
20

    
21
namespace MarkupToPDF
22
{
23
    public class MarkupToPDF : IDisposable
24
    {
25

    
26
        #region 초기 데이터
27
        private static iTextSharp.text.Rectangle mediaBox;
28
        private FileInfo PdfFilePath = null;
29
        private FileInfo FinalPDFPath = null;
30
        private string _FinalPDFStorgeLocal = null;
31
        private string _FinalPDFStorgeRemote = null;
32
        private string OriginFileName = null;
33
        public FINAL_PDF FinalItem;
34
        public DOCINFO DocInfoItem = null;
35
        public List<DOCPAGE> DocPageItem = null;
36
        public MARKUP_INFO MarkupInfoItem = null;
37
        public List<MARKUP_DATA> MarkupDataSet = null;
38
        //private string _PrintPDFStorgeLocal = null;
39
        //private string _PrintPDFStorgeRemote = null;
40
        public event EventHandler<MakeFinalErrorArgs> FinalMakeError;
41
        public event EventHandler<EndFinalEventArgs> EndFinal;
42
        public event EventHandler<StatusChangedEventArgs> StatusChanged;
43

    
44
        private iTextSharp.text.Rectangle pdfSize { get; set; }
45
        private double pageW = 0;
46
        private double pageH = 0;
47

    
48
        //private const double zoomLevel = 3.0;
49
        private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음
50
        #endregion
51

    
52
        #region 메서드        
53
        public static bool IsLocalIPAddress(string host)
54
        {
55
            try
56
            {
57
                IPAddress[] hostIPs = Dns.GetHostAddresses(host);
58
                IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
59

    
60
                foreach (IPAddress hostIP in hostIPs)
61
                {
62
                    if (IPAddress.IsLoopback(hostIP)) return true;
63

    
64
                    foreach (IPAddress localIP in localIPs)
65
                    {
66
                        if (hostIP.Equals(localIP)) return true;
67
                    }
68
                }
69
            }
70
            catch { }
71
            return false;
72
        }
73

    
74
        private void SetNotice(string finalID, string message)
75
        {
76
            if (FinalMakeError != null)
77
            {
78
                FinalMakeError(this, new MakeFinalErrorArgs { FinalID = finalID, Message = message });
79
            }
80
        }
81

    
82
        private string GetFileName(string hrefLink)
83
        {
84
            try
85
            {
86
                if (hrefLink.Contains("vpcs_doclib"))
87
                {
88
                    return System.IO.Path.GetFileName(hrefLink.Replace("/", "\\"));
89
                }
90
                else
91
                {
92
                    Uri fileurl = new Uri(hrefLink);
93
                    int index = hrefLink.IndexOf("?");
94
                    string filename = HttpUtility.ParseQueryString(fileurl.Query).Get("fileName");
95
                    return filename;
96
                }
97
            }
98
            catch (Exception ex)
99
            {
100
                throw ex;
101
            }
102
        }
103

    
104
        public Point GetPdfPointSystem(Point point)
105
        {
106
            /// 주어진 좌표를 pdf의 (Left, Top - Bottom(?)) 좌표에 맞추어 변환한다.
107
            /// Rotation 90 일 경우 pdfsize box 와 media box 가 달라 다른 계산식 적용
108
            if (pdfSize.Rotation == 90)
109
            {
110
                return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Top - (float)(point.Y / scaleHeight) - pdfSize.Bottom);
111
            }
112
            else
113
            {
114
                return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight) + pdfSize.Bottom);
115
            }  
116
        }
117

    
118
        public double GetPdfSize(double size)
119
        {
120
            return (size / scaleWidth);
121
        }
122

    
123
        public List<Point> GetPdfPointSystem(List<Point> point)
124
        {
125
            List<Point> dummy = new List<Point>();
126
            foreach (var item in point)
127
            {
128
                dummy.Add(GetPdfPointSystem(item));
129
            }
130
            return dummy;
131
        }
132

    
133
        public double returnAngle(Point start, Point end)
134
        {
135
            double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y);
136
            //angle *= -1;
137

    
138
            angle += 90;
139
            //if (angle < 0)
140
            //{
141
            //    angle = angle + 360;
142
            //}
143
            return angle;
144
        }
145

    
146
        #endregion
147

    
148
        public bool AddStamp(string stampData)
149
        {
150
            bool result = false;
151

    
152
            try
153
            {
154
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
155
                {
156
                    var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
157

    
158
                    if(stamp.Count() > 0)
159
                    {
160
                        var xamldata = Serialize.Core.JsonSerializerHelper.CompressStamp(stampData);
161

    
162
                        stamp.First().VALUE = xamldata;
163
                        _entity.SaveChanges();
164
                        result = true;
165
                    }
166
                }
167
            }
168
            catch (Exception)
169
            {
170

    
171
                throw;
172
            }
173

    
174
            return result;
175

    
176
        }
177

    
178
        /// <summary>
179
        /// local에서 final 생성하는 경우 이 함수로 추가 후 실행
180
        /// </summary>
181
        /// <param name="finalpdf"></param>
182
        /// <returns></returns>
183
        public AddFinalPDFResult AddFinalPDF(string ProjectNo,string DocumentID,string UserID)
184
        {
185
            //var list = Markus.Fonts.FontHelper.GetFontStream("Arial Unicode MS");
186
            //System.Diagnostics.Debug.WriteLine(list);
187

    
188
            AddFinalPDFResult result = new AddFinalPDFResult { Success = false };
189

    
190
            try
191
            {
192
                FINAL_PDF addItem = new FINAL_PDF{
193
                    ID = CommonLib.Guid.shortGuid(),
194
                    PROJECT_NO = ProjectNo,
195
                    DOCUMENT_ID = DocumentID,
196
                    CREATE_USER_ID = UserID,
197
                    CREATE_DATETIME = DateTime.Now,
198
                    STATUS = 4
199
                };
200

    
201
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
202
                {
203
                    var docitems = _entity.DOCINFO.Where(x => x.PROJECT_NO == ProjectNo && x.DOCUMENT_ID == DocumentID);
204

    
205
                    if(docitems.Count() > 0)
206
                    {
207
                        addItem.DOCINFO_ID = docitems.First().ID;
208
                        result.Success = true;
209
                    }
210
                    else
211
                    {
212
                        result.Exception = "docInfo Not Found.";
213
                        result.Success = false;
214
                    }
215

    
216
                    var markupInfoItems = _entity.MARKUP_INFO.Where(x =>x.DOCINFO_ID == addItem.DOCINFO_ID);
217

    
218
                    if (markupInfoItems.Count() > 0)
219
                    {
220
                        addItem.MARKUPINFO_ID = markupInfoItems.First().ID;
221
                        result.Success = true;
222
                    }
223
                    else
224
                    {
225
                        result.Exception = "Markup Info Not Found.";
226
                        result.Success = false;
227
                    }
228
                }
229

    
230
                if (result.Success)
231
                {
232
                    using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
233
                    {
234
                        var finalList = _entity.FINAL_PDF.Where(final => final.ID == addItem.ID);
235

    
236
                        /// Insrt and Update
237
                        if (finalList.Count() == 0)
238
                        {
239
                            _entity.FINAL_PDF.AddObject(addItem);
240
                            _entity.SaveChanges();
241

    
242
                            result.FinalPDF = addItem;
243
                            result.Success = true;
244
                        }
245
                    }
246
                }
247
            }
248
            catch (Exception ex)
249
            {
250
                System.Diagnostics.Debug.WriteLine(ex);
251
                result.Success = false;
252
            }
253

    
254
            return result;
255
        }
256

    
257
        #region 생성자 & 소멸자
258
        public void MakeFinalPDF(object _FinalPDF)
259
        {
260
            DOCUMENT_ITEM documentItem;
261
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
262
            FinalItem = FinalPDF;
263

    
264

    
265
            string PdfFilePathRoot = null;
266
            string TestFile = System.IO.Path.GetTempFileName();
267

    
268
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
269
            try
270
            {
271
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
272
                {
273
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
274

    
275
                    if (_properties.Count() > 0)
276
                    {
277
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0)
278
                        {
279
                            SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : TileSourcePath Not Found.");
280
                            return;
281
                        }
282
                        else
283
                        {
284
                            PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
285
                        }
286

    
287
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).Count() == 0)
288
                        {
289
                            SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeLocal Not Found.");
290
                            return;
291
                        }
292
                        else
293
                        {
294
                            _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
295
                        }
296

    
297

    
298
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).Count() == 0)
299
                        {
300
                            SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeRemote Not Found.");
301
                            return;
302
                        }
303
                        else
304
                        {
305
                            _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
306
                        }
307
                    }
308
                    else
309
                    {
310
                        SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : Final PDF Properties Not Found.");
311
                        return;
312
                    }
313

    
314
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
315

    
316
                    if (finalList.Count() > 0)
317
                    {
318
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
319
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
320
                        _entity.SaveChanges();
321
                    }
322

    
323
                }
324
            }
325
            catch (Exception ex)
326
            {
327
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
328
                return;
329
            }
330
            #endregion
331

    
332
            #region 문서 복사
333
            try
334
            {
335
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
336
                {
337
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
338

    
339
                    if (_DOCINFO.Count() > 0)
340
                    {
341
                        DocInfoItem = _DOCINFO.First();
342

    
343
                        DocPageItem = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == DocInfoItem.ID).ToList();
344

    
345
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
346
                                         + (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5))
347
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
348

    
349
                        var infoItems = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == DocInfoItem.ID && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0);
350

    
351
                        if (infoItems.Count() == 0)
352
                        {
353
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
354
                        }
355
                        else
356
                        {
357
                            MarkupInfoItem = infoItems.First();
358

    
359
                            var markupInfoVerItems = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == MarkupInfoItem.ID).ToList();
360

    
361
                            if (markupInfoVerItems.Count() > 0)
362
                            {
363
                                var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First();
364

    
365
                                MarkupDataSet = _entity.MARKUP_DATA.Where(x => x.MARKUPINFO_VERSION_ID == markupInfoVerItem.ID).OrderBy(d => d.PAGENUMBER).ToList();
366
                            }
367
                            else
368
                            {
369
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
370
                            }
371
                        }
372

    
373
                        documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault();
374
                        if (documentItem == null)
375
                        {
376
                            throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
377
                        }
378

    
379
                        var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 
380

    
381
                        #region 파일 체크
382
                        if (_files.Count() == 1)
383
                        {
384
                            /// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정
385
                            //if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()))
386
                            //{
387
                            OriginFileName = _files.First().Name;
388
                            PdfFilePath = _files.First().CopyTo(TestFile, true);
389
                            StatusChange($"Copy File  file Count = 1 : {PdfFilePath}", 0);
390
                            //}
391
                            //else
392
                            //{
393
                            //    throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower());
394
                            //}
395
                        }
396
                        else if (_files.Count() > 1)
397
                        {
398
                            var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault();
399

    
400
                            if (originalFile == null)
401
                            {
402
                                throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
403
                            }
404
                            else
405
                            {
406
                                OriginFileName = originalFile.Name;
407
                                PdfFilePath = originalFile.CopyTo(TestFile, true);
408
                                StatusChange($"Copy File file Count  > 1 : {PdfFilePath}", 0);
409
                            }
410
                        }
411
                        else
412
                        {
413
                            throw new FileNotFoundException("PDF를 찾지 못하였습니다");
414
                        }
415
                        #endregion
416

    
417
                        #region 예외처리
418
                        if (PdfFilePath == null)
419
                        {
420
                            throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
421
                        }
422
                        if (!PdfFilePath.Exists)
423
                        {
424
                            throw new Exception("PDF원본이 존재하지 않습니다");
425
                        }
426
                        #endregion
427

    
428
                    }
429
                    else
430
                    {
431
                        throw new Exception("일치하는 DocInfo가 없습니다");
432
                    }
433
                }
434
            }
435
            catch (Exception ex)
436
            {
437
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
438
                {
439
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
440
                    //System.Diagnostics.Process process = new System.Diagnostics.Process();
441
                    //process.StartInfo.FileName = "cmd";
442
                    //process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
443
                    //process.Start();
444
                }
445
                else
446
                {
447
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
448
                }
449
            }
450
            #endregion
451

    
452
            try
453
            {
454

    
455
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
456
                {
457
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
458

    
459
                    if (finalList.Count() > 0)
460
                    {
461
                        //TestFile = SetFlattingPDF(TestFile);
462
                        //StatusChange($"SetFlattingPDF : {TestFile}", 0);
463

    
464
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
465

    
466
                        StatusChange($"SetStampInPDF : {TestFile}", 0);
467
                    }
468
                }
469
                if (EndFinal != null)
470
                {
471
                    EndFinal(this, new EndFinalEventArgs
472
                    {
473
                        FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name,
474
                        OriginPDFName = OriginFileName,
475
                        FinalPDFPath = FinalPDFPath.FullName,
476
                        Error = "",
477
                        Message = "",
478
                        FinalPDF = FinalPDF,
479
                    });
480
                }
481
            }
482
            catch (Exception ex)
483
            {
484
                SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message);
485
            }
486
        }
487
        #endregion
488

    
489
        #region PDF
490
        public static float scaleWidth = 0;
491
        public static float scaleHeight = 0;
492

    
493
        private string SetFlattingPDF(string tempFileInfo)
494
        {
495
            if (File.Exists(tempFileInfo))
496
            {
497
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
498

    
499
                PdfReader pdfReader = new PdfReader(tempFileInfo);
500

    
501
                for (int i = 1; i <= pdfReader.NumberOfPages; i++)
502
                {
503
                    var mediaBox = pdfReader.GetPageSize(i);
504
                    var cropbox = pdfReader.GetCropBox(i);
505

    
506
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
507
                    //{
508
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
509
                    //}
510
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
511

    
512
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
513
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
514
                    //scaleWidth = 2.0832634F;
515
                    //scaleHeight = 3.0F;
516

    
517
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
518
                    //강인구 수정
519
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
520
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
521
                    //{
522
                    //    var pageDict = pdfReader.GetPageN(i);
523
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
524
                    //}
525
                }
526

    
527
                var memStream = new MemoryStream();
528
                var stamper = new PdfStamper(pdfReader, memStream)
529
                {
530
                    FormFlattening = true,                     
531
                    //FreeTextFlattening = true,
532
                    //AnnotationFlattening = true,                     
533
                };
534
                
535
                stamper.Close();
536
                pdfReader.Close();
537
                var array = memStream.ToArray();
538
                File.Delete(tempFileInfo);
539
                File.WriteAllBytes(TestFile.FullName, array);
540

    
541
                return TestFile.FullName;
542
            }
543
            else
544
            {
545
                return tempFileInfo;
546
            }
547
        }
548

    
549
        public void flattenPdfFile(string src, ref string dest)
550
        {
551
            PdfReader reader = new PdfReader(src);
552
            var memStream = new MemoryStream();
553
            var stamper = new PdfStamper(reader, memStream)
554
            {
555
                FormFlattening = true,
556
                FreeTextFlattening = true,
557
                AnnotationFlattening = true,
558
            };
559

    
560
            stamper.Close();
561
            var array = memStream.ToArray();
562
            File.WriteAllBytes(dest, array);
563
        }
564

    
565
        public void StatusChange(string message,int CurrentPage)
566
        {
567
            if(StatusChanged != null)
568
            {
569
                //var sb = new StringBuilder();
570
                //sb.AppendLine(message);
571

    
572
                StatusChanged(this, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = message });
573
            }
574
        }
575

    
576
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
577
        {
578
            try
579
            {
580
        
581
                FileInfo tempFileInfo = new FileInfo(testFile);
582

    
583
                if (!Directory.Exists(_FinalPDFStorgeLocal))
584
                {
585
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
586
                }
587

    
588
                string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
589
          
590

    
591
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
592
                {
593
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
594

    
595
                    #region 코멘트 적용 + 커버시트
596
                    using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
597
                    {
598
                        StatusChange("comment Cover",0);
599

    
600
                        using (PdfReader pdfReader = new PdfReader(pdfStream))
601
                        { 
602
                            //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
603
                            Dictionary<string, object> bookmark;
604
                            List<Dictionary<string, object>> outlines;
605

    
606
                            outlines = new List<Dictionary<string, object>>();
607
                            List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
608

    
609
                            var dic = new Dictionary<string, object>();
610

    
611
                            foreach (var data in MarkupDataSet)
612
                            {
613
                                //StatusChange("MarkupDataSet", 0);
614

    
615
                                string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
616

    
617
                                string username = "";
618
                                string userdept = "";
619

    
620
                                using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
621
                                {
622
                                    var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid);
623

    
624
                                    if(memberlist.Count() > 0)
625
                                    {
626
                                        username = memberlist.First().NAME;
627
                                        userdept = memberlist.First().DEPARTMENT;
628
                                    }
629
                                }
630

    
631
                                bookmark = new Dictionary<string, object>();
632
                                bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
633
                                bookmark.Add("Page", data.PAGENUMBER + " Fit");
634
                                bookmark.Add("Action", "GoTo");
635
                                bookmark.Add("Kids", outlines);
636
                                root.Add(bookmark);
637
                            }
638

    
639
                            iTextSharp.text.Version.GetInstance();
640
                            using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
641
                            {
642
                                try
643
                                {
644
                                    if (pdfStamper.AcroFields != null && pdfStamper.AcroFields.GenerateAppearances != true)
645
                                    {
646
                                        pdfStamper.AcroFields.GenerateAppearances = true;
647
                                    }
648
                                }
649
                                catch (Exception ex)
650
                                {
651
                                    SetNotice(FinalItem.ID, "this pdf is not AcroForm.");
652
                                }
653

    
654
                                System.Drawing.Color _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
655
                                
656

    
657
                                string[] delimiterChars = { "|DZ|" };
658
                                string[] delimiterChars2 = { "|" };
659

    
660
                                //pdfStamper.FormFlattening = true; //이미 선처리 작업함
661
                                pdfStamper.SetFullCompression();
662
                                _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
663

    
664
                                StringBuilder strLog = new StringBuilder();
665
                                int lastPageNo = 0;
666

    
667
                                strLog.Append($"Write {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")} markup Count : {MarkupDataSet.Count()} / ");
668

    
669
                                foreach (var markupItem in MarkupDataSet)
670
                                {
671
                                    /// 2020.11.13 김태성
672
                                    /// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함.
673
                                    var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER);
674

    
675
                                    if (pageitems.Count() > 0)
676
                                    {
677
                                        var currentPage = pageitems.First();
678
                                        pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
679
                                        lastPageNo = markupItem.PAGENUMBER;
680
                                        //try
681
                                        //{
682

    
683
                                        //}
684
                                        //catch (Exception ex)
685
                                        //{
686
                                        //    SetNotice(finaldata.ID, $"GetPageSizeWithRotation Error PageNO : {markupItem.PAGENUMBER} " + ex.ToString());
687
                                        //}
688
                                        //finally
689
                                        //{
690
                                        //    pdfSize = new iTextSharp.text.Rectangle(0, 0, float.Parse(currentPage.PAGE_WIDTH), float.Parse(currentPage.PAGE_HEIGHT));
691
                                        //}
692

    
693
                                        mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
694
                                        var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
695

    
696
                                        /// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다
697
                                        if (cropBox != null &&
698
                                            (cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom))
699
                                        {
700
                                            PdfDictionary dict = pdfReader.GetPageN(markupItem.PAGENUMBER);
701

    
702
                                            PdfArray oNewMediaBox = new PdfArray();
703
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Left));
704
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Top));
705
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Right));
706
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Bottom));
707
                                            dict.Put(PdfName.MEDIABOX, oNewMediaBox);
708

    
709
                                            pdfSize = cropBox;
710
                                        }
711

    
712
                                        scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
713
                                        scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
714

    
715
                                        pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
716
                                        _entity.SaveChanges();
717

    
718
                                        string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
719

    
720
                                        PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
721
                                        strLog.Append($"{markupItem.PAGENUMBER}/");
722

    
723
                                        foreach (var data in markedData)
724
                                        {
725
                                            var item = JsonSerializerHelper.UnCompressString(data);
726
                                            var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
727

    
728
                                            try
729
                                            {
730
                                                switch (ControlT.Name)
731
                                                {
732
                                                    #region LINE
733
                                                    case "LineControl":
734
                                                        {
735
                                                            using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
736
                                                            {
737
                                                                DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
738
                                                            }
739
                                                        }
740
                                                        break;
741
                                                    #endregion
742
                                                    #region ArrowControlMulti
743
                                                    case "ArrowControl_Multi":
744
                                                        {
745
                                                            using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
746
                                                            {
747
                                                                DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
748
                                                            }
749
                                                        }
750
                                                        break;
751
                                                    #endregion
752
                                                    #region PolyControl
753
                                                    case "PolygonControl":
754
                                                        using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item))
755
                                                        {
756
                                                            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
757
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
758
                                                            var PaintStyle = control.PaintState;
759
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
760
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
761
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
762
                                                            double Opacity = control.Opac;
763
                                                            DoubleCollection DashSize = control.DashSize;
764

    
765
                                                            Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor,PaintStyle| PaintSet.Outline, Opacity);
766
                                                            //Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
767
                                                        }
768
                                                        break;
769
                                                    #endregion
770
                                                    #region ArcControl or ArrowArcControl
771
                                                    case "ArcControl":
772
                                                    case "ArrowArcControl":
773
                                                        {
774
                                                            using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
775
                                                            {
776
                                                                string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
777
                                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
778
                                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
779
                                                                Point MidPoint = GetPdfPointSystem(control.MidPoint);
780
                                                                DoubleCollection DashSize = control.DashSize;
781
                                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
782

    
783
                                                                var Opacity = control.Opac;
784
                                                                string UserID = control.UserID;
785
                                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
786
                                                                bool IsTransOn = control.IsTransOn;
787

    
788
                                                                if (control.IsTransOn)
789
                                                                {
790
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
791
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
792
                                                                }
793
                                                                else
794
                                                                {
795
                                                                    Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity);
796
                                                                }
797

    
798
                                                                if (ControlT.Name == "ArrowArcControl")
799
                                                                {
800
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
801
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
802
                                                                }
803
                                                            }
804
                                                        }
805
                                                        break;
806
                                                    #endregion
807
                                                    #region RectangleControl
808
                                                    case "RectangleControl":
809
                                                        using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
810
                                                        {
811
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
812
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
813
                                                            var PaintStyle = control.PaintState;
814
                                                            double Angle = control.Angle;
815
                                                            DoubleCollection DashSize = control.DashSize;
816
                                                            double Opacity = control.Opac;
817
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
818

    
819
                                                            Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
820
                                                        }
821
                                                        break;
822
                                                    #endregion
823
                                                    #region TriControl
824
                                                    case "TriControl":
825
                                                        using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
826
                                                        {
827
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
828
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
829
                                                            var PaintStyle = control.Paint;
830
                                                            double Angle = control.Angle;
831
                                                            //StrokeColor = _SetColor, //색상은 레드
832
                                                            DoubleCollection DashSize = control.DashSize;
833
                                                            double Opacity = control.Opac;
834
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
835

    
836
                                                            Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity);
837
                                                        }
838
                                                        break;
839
                                                    #endregion
840
                                                    #region CircleControl
841
                                                    case "CircleControl":
842
                                                        using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
843
                                                        {
844
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
845
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
846
                                                            var StartPoint = GetPdfPointSystem(control.StartPoint);
847
                                                            var EndPoint = GetPdfPointSystem(control.EndPoint);
848
                                                            var PaintStyle = control.PaintState;
849
                                                            double Angle = control.Angle;
850
                                                            DoubleCollection DashSize = control.DashSize;
851
                                                            double Opacity = control.Opac;
852
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
853
                                                            Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
854

    
855
                                                        }
856
                                                        break;
857
                                                    #endregion
858
                                                    #region RectCloudControl
859
                                                    case "RectCloudControl":
860
                                                        using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
861
                                                        {
862
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
863
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
864
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
865
                                                            double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
866

    
867
                                                            double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
868

    
869
                                                            var PaintStyle = control.PaintState;
870
                                                            double Opacity = control.Opac;
871
                                                            DoubleCollection DashSize = control.DashSize;
872

    
873
                                                            //드로잉 방식이 표현되지 않음
874
                                                            var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
875

    
876
                                                            double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
877
                                                            bool reverse = (area < 0);
878
                                                    
879
                                                            Controls_PDF.DrawSet_Cloud.DrawCloudRect(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
880
                                                        }
881
                                                        break;
882
                                                    #endregion
883
                                                    #region CloudControl
884
                                                    case "CloudControl":
885
                                                        using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
886
                                                        {
887
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
888
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
889
                                                            double Toler = control.Toler;
890
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
891
                                                            double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
892
                                                            var PaintStyle = control.PaintState;
893
                                                            double Opacity = control.Opac;
894
                                                            bool isTransOn = control.IsTrans;
895
                                                            bool isChain = control.IsChain;
896

    
897
                                                            DoubleCollection DashSize = control.DashSize;
898

    
899
                                                            if (isChain)
900
                                                            {
901
                                                                Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
902
                                                            }
903
                                                            else
904
                                                            {
905
                                                                if (isTransOn)
906
                                                                {
907
                                                                    double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
908
                                                                    bool reverse = (area < 0);
909

    
910
                                                                    if (PaintStyle == PaintSet.None)
911
                                                                    {
912
                                                                        Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
913
                                                                    }
914
                                                                    else
915
                                                                    {
916
                                                                        Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
917
                                                                    }
918
                                                                }
919
                                                                else
920
                                                                {
921
                                                                    Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
922
                                                                }
923
                                                            }
924
                                                        }
925
                                                        break;
926
                                                    #endregion
927
                                                    #region TEXT
928
                                                    case "TextControl":
929
                                                        using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
930
                                                        {
931
                                                            DrawTextBox(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
932
                                                        }
933
                                                        break;
934
                                                    #endregion
935
                                                    #region ArrowTextControl
936
                                                    case "ArrowTextControl":
937
                                                        using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item))
938
                                                        {
939
                                                            //using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
940
                                                            //{
941
                                                            //    textcontrol.Angle = control.Angle;
942
                                                            //    textcontrol.BoxH = control.BoxHeight;
943
                                                            //    textcontrol.BoxW = control.BoxWidth;
944
                                                            //    textcontrol.EndPoint = control.EndPoint;
945
                                                            //    textcontrol.FontColor = "#FFFF0000";
946
                                                            //    textcontrol.Name = "TextControl";
947
                                                            //    textcontrol.Opac = control.Opac;
948
                                                            //    textcontrol.PointSet = new List<Point>();
949
                                                            //    textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]);
950
                                                            //    textcontrol.StartPoint = control.StartPoint;
951
                                                            //    textcontrol.Text = control.ArrowText;
952
                                                            //    textcontrol.TransformPoint = control.TransformPoint;
953
                                                            //    textcontrol.UserID = null;
954
                                                            //    textcontrol.fontConfig = control.fontConfig;
955
                                                            //    textcontrol.isHighLight = control.isHighLight;
956
                                                            //    textcontrol.paintMethod = 1;
957

    
958
                                                            //    DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
959
                                                            //}
960

    
961
                                                            //using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
962
                                                            //{
963
                                                            //    linecontrol.Angle = control.Angle;
964
                                                            //    linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 });
965
                                                            //    linecontrol.EndPoint = control.EndPoint;
966
                                                            //    linecontrol.MidPoint = control.MidPoint;
967
                                                            //    linecontrol.Name = "ArrowControl_Multi";
968
                                                            //    linecontrol.Opac = control.Opac;
969
                                                            //    linecontrol.PointSet = control.PointSet;
970
                                                            //    linecontrol.SizeSet = control.SizeSet;
971
                                                            //    linecontrol.StartPoint = control.StartPoint;
972
                                                            //    linecontrol.StrokeColor = control.StrokeColor;
973
                                                            //    linecontrol.TransformPoint = control.TransformPoint;
974

    
975
                                                            //    DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
976
                                                            //}
977
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
978
                                                            Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
979
                                                            Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
980
                                                            Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
981
                                                            bool isUnderLine = false;
982
                                                            string Text = "";
983
                                                            double fontsize = 30;
984

    
985
                                                            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
986
                                                            Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
987
                                                            List<Point> tempPoint = new List<Point>();
988

    
989
                                                            double Angle = control.Angle;
990

    
991
                                                            if (Math.Abs(Angle).ToString() == "90")
992
                                                            {
993
                                                                Angle = 270;
994
                                                            }
995
                                                            else if (Math.Abs(Angle).ToString() == "270")
996
                                                            {
997
                                                                Angle = 90;
998
                                                            }
999

    
1000
                                                            var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
1001
                                                            tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
1002
                                                            tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
1003
                                                            tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
1004
                                                            tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
1005

    
1006
                                                            var newStartPoint = tempStartPoint;
1007
                                                            var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
1008
                                                            var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
1009

    
1010
                                                            //Point testPoint = tempEndPoint;
1011
                                                            //if (Angle != 0)
1012
                                                            //{
1013
                                                            //    testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed);
1014
                                                            //   //testPoint = Test(rect, newMidPoint);
1015
                                                            //}
1016

    
1017
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1018
                                                            System.Drawing.Color FontColor = _SetColor;
1019
                                                            bool isHighlight = control.isHighLight;
1020
                                                            double Opacity = control.Opac;
1021
                                                            PaintSet Paint = PaintSet.None;
1022

    
1023
                                                            switch (control.ArrowStyle)
1024
                                                            {
1025
                                                                case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
1026
                                                                    {
1027
                                                                        Paint = PaintSet.None;
1028
                                                                    }
1029
                                                                    break;
1030
                                                                case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
1031
                                                                    {
1032
                                                                        Paint = PaintSet.Hatch;
1033
                                                                    }
1034
                                                                    break;
1035
                                                                case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
1036
                                                                    {
1037
                                                                        Paint = PaintSet.Fill;
1038
                                                                    }
1039
                                                                    break;
1040
                                                                default:
1041
                                                                    break;
1042
                                                            }
1043
                                                            if (control.isHighLight) Paint |= PaintSet.Highlight;
1044

    
1045
                                                            if (Paint == PaintSet.Hatch)
1046
                                                            {
1047
                                                                Text = control.ArrowText;
1048
                                                            }
1049
                                                            else
1050
                                                            {
1051
                                                                Text = control.ArrowText;
1052
                                                            }
1053

    
1054
                                                            try
1055
                                                            {
1056
                                                                if (control.fontConfig.Count == 4)
1057
                                                                {
1058
                                                                    fontsize = Convert.ToDouble(control.fontConfig[3]);
1059
                                                                }
1060

    
1061
                                                                //강인구 수정(2018.04.17)
1062
                                                                var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1063

    
1064
                                                                FontStyle fontStyle = FontStyles.Normal;
1065
                                                                if (FontStyles.Italic == TextStyle)
1066
                                                                {
1067
                                                                    fontStyle = FontStyles.Italic;
1068
                                                                }
1069

    
1070
                                                                FontWeight fontWeight = FontWeights.Black;
1071

    
1072
                                                                var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1073
                                                                if (FontWeights.Bold == TextWeight)
1074
                                                                {
1075
                                                                    fontWeight = FontWeights.Bold;
1076
                                                                }
1077

    
1078
                                                                TextDecorationCollection decoration = TextDecorations.Baseline;
1079
                                                                if (control.fontConfig.Count() == 5)
1080
                                                                {
1081
                                                                    decoration = TextDecorations.Underline;
1082
                                                                }
1083

    
1084
                                                                if (control.isTrans)
1085
                                                                {
1086
                                                                    //인구 수정 Arrow Text Style적용 되도록 변경
1087
                                                                    Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
1088
                                                                    newStartPoint, tempMidPoint, newEndPoint, control.isFixed,
1089
                                                                    LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1090
                                                                }
1091
                                                                else
1092
                                                                {
1093
                                                                    if (control.isFixed)
1094
                                                                    {
1095
                                                                        var testP = new Point(0, 0);
1096
                                                                        if (control.isFixed)
1097
                                                                        {
1098
                                                                            if (tempPoint[1] == newEndPoint)
1099
                                                                            {
1100
                                                                                testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
1101
                                                                            }
1102
                                                                            else if (tempPoint[3] == newEndPoint)
1103
                                                                            {
1104
                                                                                testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
1105
                                                                            }
1106
                                                                            else if (tempPoint[0] == newEndPoint)
1107
                                                                            {
1108
                                                                                testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
1109
                                                                            }
1110
                                                                            else if (tempPoint[2] == newEndPoint)
1111
                                                                            {
1112
                                                                                testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
1113
                                                                            }
1114
                                                                        }
1115
                                                                        //인구 수정 Arrow Text Style적용 되도록 변경
1116
                                                                        Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
1117
                                                                            tempStartPoint, testP, tempEndPoint, control.isFixed,
1118
                                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
1119
                                                                        FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1120
                                                                    }
1121
                                                                    else
1122
                                                                    {
1123
                                                                        //인구 수정 Arrow Text Style적용 되도록 변경
1124
                                                                        Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
1125
                                                                            newStartPoint, tempMidPoint, tempEndPoint, control.isFixed,
1126
                                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1127
                                                                    }
1128
                                                                }
1129
                                                            }
1130
                                                            catch (Exception ex)
1131
                                                            {
1132
                                                                throw ex;
1133
                                                            }
1134

    
1135
                                                        }
1136
                                                        break;
1137
                                                    #endregion
1138
                                                    #region SignControl
1139
                                                    case "SignControl":
1140
                                                        using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1141
                                                        {
1142

    
1143
                                                            double Angle = control.Angle;
1144
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1145
                                                            Point TopRightPoint = GetPdfPointSystem(control.TR);
1146
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1147
                                                            Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1148
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1149
                                                            double Opacity = control.Opac;
1150
                                                            string UserNumber = control.UserNumber;
1151
                                                            Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1152
                                                        }
1153
                                                        break;
1154
                                                    #endregion
1155
                                                    #region MyRegion
1156
                                                    case "DateControl":
1157
                                                        using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1158
                                                        {
1159
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1160
                                                            string Text = control.Text;
1161
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1162
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1163
                                                            List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1164
                                                            System.Drawing.Color FontColor = _SetColor;
1165
                                                            double Angle = control.Angle;
1166
                                                            double Opacity = control.Opac;
1167
                                                            Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1168
                                                        }
1169
                                                        break;
1170
                                                    #endregion
1171
                                                    #region SymControlN (APPROVED)
1172
                                                    case "SymControlN":
1173
                                                        using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1174
                                                        {
1175
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1176
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1177
                                                            List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1178
                                                            System.Drawing.Color FontColor = _SetColor;
1179
                                                            double Angle = control.Angle;
1180
                                                            double Opacity = control.Opac;
1181

    
1182
                                                            var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
1183

    
1184
                                                            if (stamp.Count() > 0)
1185
                                                            {
1186
                                                                var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE);
1187

    
1188
                                                                var Contents = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP_CONTENTS");
1189
                                                                
1190
                                                                if (Contents?.Count() > 0)
1191
                                                                {
1192
                                                                    foreach (var content in Contents)
1193
                                                                    {
1194
                                                                        xamldata = xamldata.Replace(content.PROPERTY, System.Security.SecurityElement.Escape(content.VALUE));
1195
                                                                    }
1196
                                                                }
1197

    
1198
                                                                Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata);
1199
                                                            }
1200

    
1201
                                                            string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1202

    
1203
                                                        }
1204
                                                        break;
1205
                                                    case "SymControl":
1206
                                                        using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1207
                                                        {
1208
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1209
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1210
                                                            List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1211
                                                            System.Drawing.Color FontColor = _SetColor;
1212
                                                            double Angle = control.Angle;
1213
                                                            double Opacity = control.Opac;
1214

    
1215
                                                            string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", "");
1216
                                                            Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1217
                                                        }
1218
                                                        break;
1219
                                                    #endregion
1220
                                                    #region Image
1221
                                                    case "ImgControl":
1222
                                                        using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1223
                                                        {
1224
                                                            double Angle = control.Angle;
1225
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1226
                                                            Point TopRightPoint = GetPdfPointSystem(control.TR);
1227
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1228
                                                            Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1229
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1230
                                                            double Opacity = control.Opac;
1231
                                                            string FilePath = control.ImagePath;
1232
                                                            //Uri uri = new Uri(s.ImagePath);
1233

    
1234
                                                            Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1235
                                                        }
1236
                                                        break;
1237
                                                    #endregion
1238
                                                    default:
1239
                                                        StatusChange($"{ControlT.Name} Not Support", 0);
1240
                                                        break;
1241
                                                }
1242

    
1243
                                            }
1244
                                            catch (Exception ex)
1245
                                            {
1246
                                                StatusChange($"markupItem : {markupItem.ID}" + ex.ToString(), 0);
1247
                                            }
1248
                                            finally
1249
                                            {
1250
                                                if (ControlT?.Name != null)
1251
                                                {
1252
                                                    strLog.Append($"{ControlT.Name},");
1253
                                                }
1254
                                            }
1255
                                        }
1256

    
1257
                                    }
1258
                                }
1259

    
1260
                                if (StatusChanged != null)
1261
                                {
1262
                                    StatusChanged(this, new StatusChangedEventArgs { CurrentPage = lastPageNo, Message = strLog.ToString() });
1263
                                }
1264
                                //PdfFileSpecification pfs = PdfFileSpecification.FileEmbedded(pdfStamper.Writer, @"C:\Users\kts\Documents\업무\CARS\엑셀양식\F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", "F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", null);
1265
                                //pdfStamper.AddFileAttachment("F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", pfs);
1266

    
1267
                                pdfStamper.Outlines = root;
1268
                                pdfStamper.Close();
1269
                                pdfReader.Close();
1270
                            }
1271
                        }
1272
                    }
1273
                    #endregion
1274
                }
1275

    
1276
                if (tempFileInfo.Exists)
1277
                {
1278
#if !DEBUG
1279
                    tempFileInfo.Delete();
1280
#endif
1281
                }
1282

    
1283
                if (File.Exists(pdfFilePath))
1284
                {
1285
                    string destfilepath = null;
1286
                    try
1287
                    {
1288
                        FinalPDFPath = new FileInfo(pdfFilePath);
1289

    
1290
                        /// 정리 필요함. DB로 변경
1291
                        string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", "");
1292

    
1293
                        if(!string.IsNullOrEmpty(pdfmovepath))
1294
                        {
1295
                            _FinalPDFStorgeLocal = pdfmovepath;
1296
                        }
1297

    
1298
                        destfilepath = Path.Combine(_FinalPDFStorgeLocal, FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1299

    
1300
                        if (File.Exists(destfilepath))
1301
                            File.Delete(destfilepath);
1302

    
1303
                        File.Move(FinalPDFPath.FullName, destfilepath);
1304
                        FinalPDFPath = new FileInfo(destfilepath);
1305
                        File.Delete(pdfFilePath);
1306
                    }
1307
                    catch (Exception ex)
1308
                    {
1309
                        SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString());
1310
                    }
1311

    
1312
                    return true;
1313
                }
1314
            }
1315
            catch (Exception ex)
1316
            {
1317
                SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString());
1318
            }
1319
            return false;
1320
        }
1321

    
1322
        /// <summary>
1323
        /// kcom의 화살표방향과 틀려 추가함
1324
        /// </summary>
1325
        /// <param name="PageAngle"></param>
1326
        /// <param name="endP"></param>
1327
        /// <param name="ps">box Points</param>
1328
        /// <param name="IsFixed"></param>
1329
        /// <returns></returns>
1330
        private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed)
1331
        {
1332
            Point testP = endP;
1333

    
1334
            try
1335
            {
1336
                switch (Math.Abs(PageAngle).ToString())
1337
                {
1338
                    case "90":
1339
                        testP = new Point(endP.X + 50, endP.Y);
1340
                        break;
1341
                    case "270":
1342
                        testP = new Point(endP.X - 50, endP.Y);
1343
                        break;
1344
                }
1345

    
1346
                //20180910 LJY 각도에 따라.
1347
                switch (Math.Abs(PageAngle).ToString())
1348
                {
1349
                    case "90":
1350
                        if (IsFixed)
1351
                        {
1352
                            if (ps[0] == endP) //상단
1353
                            {
1354
                                testP = new Point(endP.X, endP.Y + 50);
1355
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1356
                            }
1357
                            else if (ps[1] == endP) //하단
1358
                            {
1359
                                testP = new Point(endP.X, endP.Y - 50);
1360
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1361
                            }
1362
                            else if (ps[2] == endP) //좌단
1363
                            {
1364
                                testP = new Point(endP.X - 50, endP.Y);
1365
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1366
                            }
1367
                            else if (ps[3] == endP) //우단
1368
                            {
1369
                                testP = new Point(endP.X + 50, endP.Y);
1370
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1371
                            }
1372
                        }
1373
                        break;
1374
                    case "270":
1375
                        if (IsFixed)
1376
                        {
1377
                            if (ps[0] == endP) //상단
1378
                            {
1379
                                testP = new Point(endP.X, endP.Y - 50);
1380
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1381
                            }
1382
                            else if (ps[1] == endP) //하단
1383
                            {
1384
                                testP = new Point(endP.X, endP.Y + 50);
1385
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1386
                            }
1387
                            else if (ps[2] == endP) //좌단
1388
                            {
1389
                                testP = new Point(endP.X + 50, endP.Y);
1390
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1391
                            }
1392
                            else if (ps[3] == endP) //우단
1393
                            {
1394
                                testP = new Point(endP.X - 50, endP.Y);
1395
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1396
                            }
1397
                        }
1398
                        break;
1399
                    default:
1400
                        if (IsFixed)
1401
                        {
1402

    
1403
                            if (ps[0] == endP) //상단
1404
                            {
1405
                                testP = new Point(endP.X, endP.Y - 50);
1406
                                //System.Diagnostics.Debug.WriteLine("상단");
1407
                            }
1408
                            else if (ps[1] == endP) //하단
1409
                            {
1410
                                testP = new Point(endP.X, endP.Y + 50);
1411
                                //System.Diagnostics.Debug.WriteLine("하단");
1412
                            }
1413
                            else if (ps[2] == endP) //좌단
1414
                            {
1415
                                testP = new Point(endP.X - 50, endP.Y);
1416
                                //System.Diagnostics.Debug.WriteLine("좌단");
1417
                            }
1418
                            else if (ps[3] == endP) //우단
1419
                            {
1420
                                testP = new Point(endP.X + 50, endP.Y);
1421
                                //System.Diagnostics.Debug.WriteLine("우단");
1422
                            }
1423
                        }
1424
                        break;
1425
                }
1426

    
1427
            }
1428
            catch (Exception)
1429
            {
1430
            }
1431

    
1432
            return testP;
1433
        }
1434

    
1435
        private Point Test(Rect rect,Point point)
1436
        {
1437
            Point result = new Point();
1438

    
1439
            Point newPoint = new Point();
1440

    
1441
            double oldNear = 0;
1442
            double newNear = 0;
1443

    
1444
            oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result);
1445

    
1446
            newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint);
1447

    
1448
            if (newNear < oldNear)
1449
            {
1450
                oldNear = newNear;
1451
                result = newPoint;
1452
            }
1453

    
1454
            newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint);
1455

    
1456
            if (newNear < oldNear)
1457
            {
1458
                oldNear = newNear;
1459
                result = newPoint;
1460
            }
1461

    
1462

    
1463
            newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint);
1464

    
1465
            if (newNear < oldNear)
1466
            {
1467
                oldNear = newNear;
1468
                result = newPoint;
1469
            }
1470

    
1471
            return result;
1472
        }
1473

    
1474
        private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor)
1475
        {
1476
            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1477
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1478
            Point MidPoint = GetPdfPointSystem(control.MidPoint);
1479
            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1480
            DoubleCollection DashSize = control.DashSize;
1481
            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1482
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
1483

    
1484
            double Opacity = control.Opac;
1485

    
1486
            if (EndPoint == MidPoint)
1487
            {
1488
                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1489
            }
1490
            else
1491
            {
1492
                Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity);
1493
            }
1494

    
1495
            Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity);
1496

    
1497
        }
1498

    
1499
        private void DrawLine(S_LineControl control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor)
1500
        {
1501
            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1502
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1503
            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1504
            DoubleCollection DashSize = control.DashSize;
1505
            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1506

    
1507
            var Opacity = control.Opac;
1508
            string UserID = control.UserID;
1509
            double Interval = control.Interval;
1510
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
1511
            Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, setColor, Opacity);
1512
            switch (control.LineStyleSet)
1513
            {
1514
                case LineStyleSet.ArrowLine:
1515
                    Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1516
                    break;
1517
                case LineStyleSet.CancelLine:
1518
                    {
1519
                        var x = Math.Abs((Math.Abs(control.StartPoint.X) - Math.Abs(control.EndPoint.X)));
1520
                        var y = Math.Abs((Math.Abs(control.StartPoint.Y) - Math.Abs(control.EndPoint.Y)));
1521

    
1522
                        Point newStartPoint = new Point();
1523
                        Point newEndPoint = new Point();
1524

    
1525
                        if (x > y)
1526
                        {
1527
                            newStartPoint = new Point(control.StartPoint.X, control.StartPoint.Y + control.Interval);
1528
                            newEndPoint = new Point(control.EndPoint.X, control.EndPoint.Y + control.Interval);
1529
                        }
1530
                        else
1531
                        {
1532
                            newStartPoint = new Point(control.StartPoint.X + control.Interval, control.StartPoint.Y);
1533
                            newEndPoint = new Point(control.EndPoint.X + control.Interval, control.EndPoint.Y);
1534
                        }
1535

    
1536
                        newStartPoint = GetPdfPointSystem(newStartPoint);
1537
                        newEndPoint = GetPdfPointSystem(newEndPoint);
1538

    
1539
                        Controls_PDF.DrawSet_Line.DrawLine(newStartPoint, newEndPoint, LineSize, contentByte, DashSize, setColor, Opacity);
1540
                    }
1541
                    break;
1542
                case LineStyleSet.TwinLine:
1543
                    {
1544
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1545
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1546
                    }
1547
                    break;
1548
                case LineStyleSet.DimLine:
1549
                    {
1550
                        Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1551
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1552
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1553
                    }
1554
                    break;
1555
                default:
1556
                    break;
1557
            }
1558

    
1559
        }
1560

    
1561
        private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,System.Drawing.Color setColor)
1562
        {
1563
            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1564
            string Text = control.Text;
1565

    
1566
            bool isUnderline = false;
1567
            control.BoxW -= scaleWidth;
1568
            control.BoxH -= scaleHeight;
1569
            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
1570
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1571
            Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
1572

    
1573
            List<Point> pointSet = new List<Point>();
1574
            pointSet.Add(StartPoint);
1575
            pointSet.Add(EndPoint);
1576
            
1577
            PaintSet paint = PaintSet.None;
1578
            switch (control.paintMethod)
1579
            {
1580
                case 1:
1581
                    {
1582
                        paint = PaintSet.Fill;
1583
                    }
1584
                    break;
1585
                case 2:
1586
                    {
1587
                        paint = PaintSet.Hatch;
1588
                    }
1589
                    break;
1590
                default:
1591
                    break;
1592
            }
1593
            if (control.isHighLight) paint |= PaintSet.Highlight;
1594

    
1595
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1596
            double TextSize = Convert.ToDouble(data2[1]);
1597
            System.Drawing.Color FontColor = setColor;
1598
            double Angle = control.Angle;
1599
            double Opacity = control.Opac;
1600
            FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]);
1601
            var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1602

    
1603
            FontStyle fontStyle = FontStyles.Normal;
1604
            if (FontStyles.Italic == TextStyle)
1605
            {
1606
                fontStyle = FontStyles.Italic;
1607
            }
1608

    
1609
            FontWeight fontWeight = FontWeights.Black;
1610

    
1611
            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1612
            //강인구 수정(2018.04.17)
1613
            if (FontWeights.Bold == TextWeight)
1614
            //if (FontWeights.ExtraBold == TextWeight)
1615
            {
1616
                fontWeight = FontWeights.Bold;
1617
            }
1618

    
1619
            TextDecorationCollection decoration = TextDecorations.Baseline;
1620
            if (control.fontConfig.Count() == 4)
1621
            {
1622
                decoration = TextDecorations.Underline;
1623
            }
1624

    
1625
            Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1626
        }
1627
    
1628

    
1629
        ~MarkupToPDF()
1630
        {
1631
            this.Dispose(false);
1632
        }
1633

    
1634
        private bool disposed;
1635

    
1636
        public void Dispose()
1637
        {
1638
            this.Dispose(true);
1639
            GC.SuppressFinalize(this);
1640
        }
1641

    
1642
        protected virtual void Dispose(bool disposing)
1643
        {
1644
            if (this.disposed) return;
1645
            if (disposing)
1646
            {
1647
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
1648
            }
1649
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
1650
            this.disposed = true;
1651
        }
1652

    
1653
#endregion
1654
    }
1655
}
클립보드 이미지 추가 (최대 크기: 500 MB)