프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 38d69491

이력 | 보기 | 이력해설 | 다운로드 (94.3 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
        public MarkupToPDF()
26
        {
27
        }
28

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

    
48
        private iTextSharp.text.Rectangle pdfSize { get; set; }
49
        private double pageW = 0;
50
        private double pageH = 0;
51

    
52
        //private const double zoomLevel = 3.0;
53
        private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음
54
        #endregion
55

    
56
        #region 메서드        
57
        public static bool IsLocalIPAddress(string host)
58
        {
59
            try
60
            {
61
                IPAddress[] hostIPs = Dns.GetHostAddresses(host);
62
                IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
63

    
64
                foreach (IPAddress hostIP in hostIPs)
65
                {
66
                    if (IPAddress.IsLoopback(hostIP)) return true;
67

    
68
                    foreach (IPAddress localIP in localIPs)
69
                    {
70
                        if (hostIP.Equals(localIP)) return true;
71
                    }
72
                }
73
            }
74
            catch { }
75
            return false;
76
        }
77

    
78
        private void SetNotice(string finalID, string message)
79
        {
80
            if (FinalMakeError != null)
81
            {
82
                FinalMakeError(this, new MakeFinalErrorArgs { FinalID = finalID, Message = message });
83
            }
84
        }
85

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

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

    
122
        public double GetPdfSize(double size)
123
        {
124
            return (size / scaleWidth);
125
        }
126

    
127
        public List<Point> GetPdfPointSystem(List<Point> point)
128
        {
129
            List<Point> dummy = new List<Point>();
130
            foreach (var item in point)
131
            {
132
                dummy.Add(GetPdfPointSystem(item));
133
            }
134
            return dummy;
135
        }
136

    
137
        public double returnAngle(Point start, Point end)
138
        {
139
            double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y);
140
            //angle *= -1;
141

    
142
            angle += 90;
143
            //if (angle < 0)
144
            //{
145
            //    angle = angle + 360;
146
            //}
147
            return angle;
148
        }
149

    
150
        #endregion
151

    
152
        public bool AddStamp(string stampData)
153
        {
154
            bool result = false;
155

    
156
            try
157
            {
158
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
159
                {
160
                    var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
161

    
162
                    if(stamp.Count() > 0)
163
                    {
164
                        var xamldata = Serialize.Core.JsonSerializerHelper.CompressStamp(stampData);
165

    
166
                        stamp.First().VALUE = xamldata;
167
                        _entity.SaveChanges();
168
                        result = true;
169
                    }
170
                }
171
            }
172
            catch (Exception)
173
            {
174

    
175
                throw;
176
            }
177

    
178
            return result;
179

    
180
        }
181

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

    
192
            AddFinalPDFResult result = new AddFinalPDFResult { Success = false };
193

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

    
205
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString()))
206
                {
207
                    var docitems = _entity.DOCINFO.Where(x => x.PROJECT_NO == ProjectNo && x.DOCUMENT_ID == DocumentID);
208

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

    
220
                    var markupInfoItems = _entity.MARKUP_INFO.Where(x =>x.DOCINFO_ID == addItem.DOCINFO_ID);
221

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

    
234
                if (result.Success)
235
                {
236
                    using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
237
                    {
238
                        var finalList = _entity.FINAL_PDF.Where(final => final.ID == addItem.ID);
239

    
240
                        /// Insrt and Update
241
                        if (finalList.Count() == 0)
242
                        {
243
                            _entity.FINAL_PDF.AddObject(addItem);
244
                            _entity.SaveChanges();
245

    
246
                            result.FinalPDF = addItem;
247
                            result.Success = true;
248
                        }
249
                    }
250
                }
251
            }
252
            catch (Exception ex)
253
            {
254
                System.Diagnostics.Debug.WriteLine(ex);
255
                result.Success = false;
256
            }
257

    
258
            return result;
259
        }
260

    
261
        #region 생성자 & 소멸자
262
        public void MakeFinalPDF(object _FinalPDF)
263
        {
264
            DOCUMENT_ITEM documentItem;
265
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
266
            FinalItem = FinalPDF;
267

    
268

    
269
            string PdfFilePathRoot = null;
270
            string TestFile = System.IO.Path.GetTempFileName();
271

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

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

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

    
301

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

    
318
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
319

    
320
                    if (finalList.Count() > 0)
321
                    {
322
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
323
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
324
                        _entity.SaveChanges();
325
                    }
326

    
327
                }
328
            }
329
            catch (Exception ex)
330
            {
331
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
332
                return;
333
            }
334
            #endregion
335

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

    
343
                    if (_DOCINFO.Count() > 0)
344
                    {
345
                        DocInfoItem = _DOCINFO.First();
346

    
347
                        DocPageItem = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == DocInfoItem.ID).ToList();
348

    
349
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
350
                                         + (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5))
351
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
352

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

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

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

    
365
                            if (markupInfoVerItems.Count() > 0)
366
                            {
367
                                var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First();
368

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

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

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

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

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

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

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

    
456
            try
457
            {
458

    
459
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
460
                {
461
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
462

    
463
                    if (finalList.Count() > 0)
464
                    {
465
                        //TestFile = SetFlattingPDF(TestFile);
466
                        //StatusChange($"SetFlattingPDF : {TestFile}", 0);
467

    
468
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
469

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

    
493
        #region PDF
494
        public static float scaleWidth = 0;
495
        public static float scaleHeight = 0;
496

    
497
        private string SetFlattingPDF(string tempFileInfo)
498
        {
499
            if (File.Exists(tempFileInfo))
500
            {
501
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
502

    
503
                PdfReader pdfReader = new PdfReader(tempFileInfo);
504

    
505
                for (int i = 1; i <= pdfReader.NumberOfPages; i++)
506
                {
507
                    var mediaBox = pdfReader.GetPageSize(i);
508
                    var cropbox = pdfReader.GetCropBox(i);
509

    
510
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
511
                    //{
512
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
513
                    //}
514
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
515

    
516
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
517
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
518
                    //scaleWidth = 2.0832634F;
519
                    //scaleHeight = 3.0F;
520

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

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

    
545
                return TestFile.FullName;
546
            }
547
            else
548
            {
549
                return tempFileInfo;
550
            }
551
        }
552

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

    
564
            stamper.Close();
565
            var array = memStream.ToArray();
566
            File.WriteAllBytes(dest, array);
567
        }
568

    
569
        public void StatusChange(string message,int CurrentPage)
570
        {
571
            if(StatusChanged != null)
572
            {
573
                //var sb = new StringBuilder();
574
                //sb.AppendLine(message);
575

    
576
                StatusChanged(this, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = message });
577
            }
578
        }
579

    
580
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
581
        {
582
            try
583
            {
584
        
585
                FileInfo tempFileInfo = new FileInfo(testFile);
586

    
587
                if (!Directory.Exists(_FinalPDFStorgeLocal))
588
                {
589
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
590
                }
591

    
592
                string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
593
          
594

    
595
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
596
                {
597
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
598

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

    
604
                        using (PdfReader pdfReader = new PdfReader(pdfStream))
605
                        { 
606
                            //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
607
                            Dictionary<string, object> bookmark;
608
                            List<Dictionary<string, object>> outlines;
609

    
610
                            outlines = new List<Dictionary<string, object>>();
611
                            List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
612

    
613
                            var dic = new Dictionary<string, object>();
614

    
615
                            foreach (var data in MarkupDataSet)
616
                            {
617
                                //StatusChange("MarkupDataSet", 0);
618

    
619
                                string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
620

    
621
                                string username = "";
622
                                string userdept = "";
623

    
624
                                using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
625
                                {
626
                                    var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid);
627

    
628
                                    if(memberlist.Count() > 0)
629
                                    {
630
                                        username = memberlist.First().NAME;
631
                                        userdept = memberlist.First().DEPARTMENT;
632
                                    }
633
                                }
634

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

    
643
                            iTextSharp.text.Version.GetInstance();
644

    
645
                            using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
646
                            {
647
                                try
648
                                {
649
                                    if (pdfStamper.AcroFields != null && pdfStamper.AcroFields.GenerateAppearances != true)
650
                                    {
651
                                        pdfStamper.AcroFields.GenerateAppearances = true;
652
                                    }
653
                                }
654
                                catch (Exception ex)
655
                                {
656
                                    SetNotice(FinalItem.ID, "this pdf is not AcroForm.");
657
                                }
658

    
659
                                System.Drawing.Color _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
660
                                
661

    
662
                                string[] delimiterChars = { "|DZ|" };
663
                                string[] delimiterChars2 = { "|" };
664

    
665
                                //pdfStamper.FormFlattening = true; //이미 선처리 작업함
666
                                pdfStamper.SetFullCompression();
667
                                _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
668

    
669
                                StringBuilder strLog = new StringBuilder();
670
                                int lastPageNo = 0;
671

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

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

    
680
                                    if (pageitems.Count() > 0)
681
                                    {
682
                                        var currentPage = pageitems.First();
683
                                        pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
684
                                        lastPageNo = markupItem.PAGENUMBER;
685
                                        //try
686
                                        //{
687

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

    
698
                                        mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
699
                                        var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
700

    
701
                                        /// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다
702
                                        if (cropBox != null &&
703
                                            (cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom))
704
                                        {
705
                                            PdfDictionary dict = pdfReader.GetPageN(markupItem.PAGENUMBER);
706

    
707
                                            PdfArray oNewMediaBox = new PdfArray();
708
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Left));
709
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Top));
710
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Right));
711
                                            oNewMediaBox.Add(new PdfNumber(cropBox.Bottom));
712
                                            dict.Put(PdfName.MEDIABOX, oNewMediaBox);
713

    
714
                                            pdfSize = cropBox;
715
                                        }
716

    
717
                                        scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
718
                                        scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
719

    
720
                                        pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
721
                                        _entity.SaveChanges();
722

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

    
725
                                        PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
726
                                        //strLog.Append($"p.{markupItem.PAGENUMBER}:{markupItem.DATA_TYPE}/");
727

    
728
                                        foreach (var data in markedData)
729
                                        {
730
                                            var item = JsonSerializerHelper.UnCompressString(data);
731
                                            var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
732

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

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

    
788
                                                                var Opacity = control.Opac;
789
                                                                string UserID = control.UserID;
790
                                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
791
                                                                bool IsTransOn = control.IsTransOn;
792

    
793
                                                                if (control.IsTransOn)
794
                                                                {
795
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
796
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
797
                                                                }
798
                                                                else
799
                                                                {
800
                                                                    Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity);
801
                                                                }
802

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

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

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

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

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

    
874
                                                            var PaintStyle = control.PaintState;
875
                                                            double Opacity = control.Opac;
876
                                                            DoubleCollection DashSize = control.DashSize;
877

    
878
                                                            //드로잉 방식이 표현되지 않음
879
                                                            var rotate = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
880

    
881
                                                            double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
882
                                                            bool reverse = (area < 0);
883

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

    
902
                                                            DoubleCollection DashSize = control.DashSize;
903

    
904
                                                            if (isChain)
905
                                                            {
906
                                                                Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
907
                                                            }
908
                                                            else
909
                                                            {
910
                                                                if (isTransOn)
911
                                                                {
912
                                                                    double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
913
                                                                    bool reverse = (area < 0);
914

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

    
963
                                                            //    DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
964
                                                            //}
965

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

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

    
990
                                                            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
991
                                                            Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
992
                                                            List<Point> tempPoint = new List<Point>();
993

    
994
                                                            double Angle = control.Angle;
995

    
996
                                                            if (Math.Abs(Angle).ToString() == "90")
997
                                                            {
998
                                                                Angle = 270;
999
                                                            }
1000
                                                            else if (Math.Abs(Angle).ToString() == "270")
1001
                                                            {
1002
                                                                Angle = 90;
1003
                                                            }
1004

    
1005
                                                            var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
1006
                                                            tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
1007
                                                            tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
1008
                                                            tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
1009
                                                            tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
1010

    
1011
                                                            var newStartPoint = tempStartPoint;
1012
                                                            var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
1013
                                                            var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
1014

    
1015
                                                            //Point testPoint = tempEndPoint;
1016
                                                            //if (Angle != 0)
1017
                                                            //{
1018
                                                            //    testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed);
1019
                                                            //   //testPoint = Test(rect, newMidPoint);
1020
                                                            //}
1021

    
1022
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1023
                                                            System.Drawing.Color FontColor = _SetColor;
1024
                                                            bool isHighlight = control.isHighLight;
1025
                                                            double Opacity = control.Opac;
1026
                                                            PaintSet Paint = PaintSet.None;
1027

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

    
1050
                                                            if (Paint == PaintSet.Hatch)
1051
                                                            {
1052
                                                                Text = control.ArrowText;
1053
                                                            }
1054
                                                            else
1055
                                                            {
1056
                                                                Text = control.ArrowText;
1057
                                                            }
1058

    
1059
                                                            try
1060
                                                            {
1061
                                                                if (control.fontConfig.Count == 4)
1062
                                                                {
1063
                                                                    fontsize = Convert.ToDouble(control.fontConfig[3]);
1064
                                                                }
1065

    
1066
                                                                //강인구 수정(2018.04.17)
1067
                                                                var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1068

    
1069
                                                                FontStyle fontStyle = FontStyles.Normal;
1070
                                                                if (FontStyles.Italic == TextStyle)
1071
                                                                {
1072
                                                                    fontStyle = FontStyles.Italic;
1073
                                                                }
1074

    
1075
                                                                FontWeight fontWeight = FontWeights.Black;
1076

    
1077
                                                                var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1078
                                                                if (FontWeights.Bold == TextWeight)
1079
                                                                {
1080
                                                                    fontWeight = FontWeights.Bold;
1081
                                                                }
1082

    
1083
                                                                TextDecorationCollection decoration = TextDecorations.Baseline;
1084
                                                                if (control.fontConfig.Count() == 5)
1085
                                                                {
1086
                                                                    decoration = TextDecorations.Underline;
1087
                                                                }
1088

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

    
1140
                                                        }
1141
                                                        break;
1142
                                                    #endregion
1143
                                                    #region SignControl
1144
                                                    case "SignControl":
1145
                                                        using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1146
                                                        {
1147

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

    
1187
                                                            var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
1188

    
1189
                                                            if (stamp.Count() > 0)
1190
                                                            {
1191
                                                                var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE);
1192

    
1193
                                                                var Contents = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP_CONTENTS");
1194
                                                                
1195
                                                                if (Contents?.Count() > 0)
1196
                                                                {
1197
                                                                    foreach (var content in Contents)
1198
                                                                    {
1199
                                                                        xamldata = xamldata.Replace(content.PROPERTY, System.Security.SecurityElement.Escape(content.VALUE));
1200
                                                                    }
1201
                                                                }
1202

    
1203
                                                                Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata);
1204
                                                            }
1205

    
1206
                                                            string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1207

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

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

    
1239
                                                            Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1240
                                                        }
1241
                                                        break;
1242
                                                    #endregion
1243
                                                    default:
1244
                                                        StatusChange($"{ControlT.Name} Not Support", 0);
1245
                                                        break;
1246
                                                }
1247

    
1248
                                            }
1249
                                            catch (Exception ex)
1250
                                            {
1251
                                                StatusChange($"markupItem : {markupItem.ID}" + ex.ToString(), 0);
1252
                                            }
1253
                                            finally
1254
                                            {
1255
                                                //if (ControlT?.Name != null)
1256
                                                //{
1257
                                                //    strLog.Append($"{ControlT.Name},");
1258
                                                //}
1259
                                            }
1260
                                        }
1261

    
1262
                                    }
1263
                                }
1264

    
1265
                                if (StatusChanged != null)
1266
                                {
1267
                                    StatusChanged(this, new StatusChangedEventArgs { CurrentPage = lastPageNo, Message = "" });
1268
                                }
1269
                                //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);
1270
                                //pdfStamper.AddFileAttachment("F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", pfs);
1271

    
1272
                                pdfStamper.Outlines = root;
1273
                                pdfStamper.Close();
1274
                                pdfReader.Close();
1275
                            }
1276
                        }
1277
                    }
1278
                    #endregion
1279
                }
1280

    
1281
                if (tempFileInfo.Exists)
1282
                {
1283
#if !DEBUG
1284
                    tempFileInfo.Delete();
1285
#endif
1286
                }
1287

    
1288
                if (File.Exists(pdfFilePath))
1289
                {
1290
                    string destfilepath = null;
1291
                    try
1292
                    {
1293
                        FinalPDFPath = new FileInfo(pdfFilePath);
1294

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

    
1298
                        if(!string.IsNullOrEmpty(pdfmovepath))
1299
                        {
1300
                            _FinalPDFStorgeLocal = pdfmovepath;
1301
                        }
1302

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

    
1305
                        if (File.Exists(destfilepath))
1306
                            File.Delete(destfilepath);
1307

    
1308
                        File.Move(FinalPDFPath.FullName, destfilepath);
1309
                        FinalPDFPath = new FileInfo(destfilepath);
1310
                        File.Delete(pdfFilePath);
1311
                    }
1312
                    catch (Exception ex)
1313
                    {
1314
                        SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString());
1315
                    }
1316

    
1317
                    return true;
1318
                }
1319
            }
1320
            catch (Exception ex)
1321
            {
1322
                SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString());
1323
            }
1324
            return false;
1325
        }
1326

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

    
1339
            try
1340
            {
1341
                switch (Math.Abs(PageAngle).ToString())
1342
                {
1343
                    case "90":
1344
                        testP = new Point(endP.X + 50, endP.Y);
1345
                        break;
1346
                    case "270":
1347
                        testP = new Point(endP.X - 50, endP.Y);
1348
                        break;
1349
                }
1350

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

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

    
1432
            }
1433
            catch (Exception)
1434
            {
1435
            }
1436

    
1437
            return testP;
1438
        }
1439

    
1440
        private Point Test(Rect rect,Point point)
1441
        {
1442
            Point result = new Point();
1443

    
1444
            Point newPoint = new Point();
1445

    
1446
            double oldNear = 0;
1447
            double newNear = 0;
1448

    
1449
            oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result);
1450

    
1451
            newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint);
1452

    
1453
            if (newNear < oldNear)
1454
            {
1455
                oldNear = newNear;
1456
                result = newPoint;
1457
            }
1458

    
1459
            newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint);
1460

    
1461
            if (newNear < oldNear)
1462
            {
1463
                oldNear = newNear;
1464
                result = newPoint;
1465
            }
1466

    
1467

    
1468
            newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint);
1469

    
1470
            if (newNear < oldNear)
1471
            {
1472
                oldNear = newNear;
1473
                result = newPoint;
1474
            }
1475

    
1476
            return result;
1477
        }
1478

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

    
1489
            double Opacity = control.Opac;
1490

    
1491
            if (EndPoint == MidPoint)
1492
            {
1493
                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1494
            }
1495
            else
1496
            {
1497
                Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity);
1498
            }
1499

    
1500
            Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity);
1501

    
1502
        }
1503

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

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

    
1527
                        Point newStartPoint = new Point();
1528
                        Point newEndPoint = new Point();
1529

    
1530
                        if (x > y)
1531
                        {
1532
                            newStartPoint = new Point(control.StartPoint.X, control.StartPoint.Y + control.Interval);
1533
                            newEndPoint = new Point(control.EndPoint.X, control.EndPoint.Y + control.Interval);
1534
                        }
1535
                        else
1536
                        {
1537
                            newStartPoint = new Point(control.StartPoint.X + control.Interval, control.StartPoint.Y);
1538
                            newEndPoint = new Point(control.EndPoint.X + control.Interval, control.EndPoint.Y);
1539
                        }
1540

    
1541
                        newStartPoint = GetPdfPointSystem(newStartPoint);
1542
                        newEndPoint = GetPdfPointSystem(newEndPoint);
1543

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

    
1564
        }
1565

    
1566
        private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,System.Drawing.Color setColor)
1567
        {
1568
            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1569
            string Text = control.Text;
1570

    
1571
            bool isUnderline = false;
1572
            control.BoxW -= scaleWidth;
1573
            control.BoxH -= scaleHeight;
1574
            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
1575
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1576
            Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
1577

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

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

    
1608
            FontStyle fontStyle = FontStyles.Normal;
1609
            if (FontStyles.Italic == TextStyle)
1610
            {
1611
                fontStyle = FontStyles.Italic;
1612
            }
1613

    
1614
            FontWeight fontWeight = FontWeights.Black;
1615

    
1616
            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1617
            //강인구 수정(2018.04.17)
1618
            if (FontWeights.Bold == TextWeight)
1619
            //if (FontWeights.ExtraBold == TextWeight)
1620
            {
1621
                fontWeight = FontWeights.Bold;
1622
            }
1623

    
1624
            TextDecorationCollection decoration = TextDecorations.Baseline;
1625
            if (control.fontConfig.Count() == 4)
1626
            {
1627
                decoration = TextDecorations.Underline;
1628
            }
1629

    
1630
            Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1631
        }
1632
    
1633

    
1634
        ~MarkupToPDF()
1635
        {
1636
            this.Dispose(false);
1637
        }
1638

    
1639
        private bool disposed;
1640

    
1641
        public void Dispose()
1642
        {
1643
            this.Dispose(true);
1644
            GC.SuppressFinalize(this);
1645
        }
1646

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

    
1658
#endregion
1659
    }
1660
}
클립보드 이미지 추가 (최대 크기: 500 MB)