프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ ff665e73

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

1
using IFinalPDF;
2
using iTextSharp.text.pdf;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Serialize.Core;
7
using MarkupToPDF.Serialize.S_Control;
8
using Markus.Fonts;
9
using System;
10
using System.Collections.Generic;
11
using System.Configuration;
12
using System.IO;
13
using System.Linq;
14
using System.Net;
15
using System.Runtime.InteropServices;
16
using System.Text;
17
using System.Web;
18
using System.Windows;
19
using System.Windows.Media;
20

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
146
        #endregion
147

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

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

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

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

    
171
                throw;
172
            }
173

    
174
            return result;
175

    
176
        }
177

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

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

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

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

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

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

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

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

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

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

    
254
            return result;
255
        }
256

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

    
264

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

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

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

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

    
297

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

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

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

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

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

    
339
                    if (_DOCINFO.Count() > 0)
340
                    {
341
                        DocInfoItem = _DOCINFO.FirstOrDefault();
342
                        DocPageItem = DocInfoItem.DOCPAGE.ToList();
343

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

    
348
                        MarkupInfoItem = DocInfoItem.MARKUP_INFO.Where(data => data.CONSOLIDATE == 1 && data.AVOID_CONSOLIDATE == 0 && data.PART_CONSOLIDATE == 0).FirstOrDefault();
349

    
350
                        if (MarkupInfoItem == null)
351
                        {
352
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
353
                        }
354
                        else
355
                        {
356
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0)
357
                            {
358
                                MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d => d.PAGENUMBER).ToList();
359
                            }
360
                            else
361
                            {
362
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
363
                            }
364
                        }
365

    
366
                        documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault();
367
                        if (documentItem == null)
368
                        {
369
                            throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
370
                        }
371

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

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

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

    
410
                        #region 예외처리
411
                        if (PdfFilePath == null)
412
                        {
413
                            throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
414
                        }
415
                        if (!PdfFilePath.Exists)
416
                        {
417
                            throw new Exception("PDF원본이 존재하지 않습니다");
418
                        }
419
                        #endregion
420
                        
421
                    }
422
                    else
423
                    {
424
                        throw new Exception("일치하는 DocInfo가 없습니다");
425
                    }
426
                }
427
            }
428
            catch (Exception ex)
429
            {
430
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
431
                {
432
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
433
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
434
                    process.StartInfo.FileName = "cmd";
435
                    process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
436
                    process.Start();
437
                }
438
                else
439
                {
440
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
441
                }
442
            }
443
            #endregion
444

    
445
            try
446
            {
447

    
448
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
449
                {
450
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
451

    
452
                    if (finalList.Count() > 0)
453
                    {
454
                        //TestFile = SetFlattingPDF(TestFile);
455
                        //StatusChange($"SetFlattingPDF : {TestFile}", 0);
456

    
457
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
458

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

    
482
        #region PDF
483
        public static float scaleWidth = 0;
484
        public static float scaleHeight = 0;
485

    
486
        private string SetFlattingPDF(string tempFileInfo)
487
        {
488
            if (File.Exists(tempFileInfo))
489
            {
490
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
491

    
492
                PdfReader pdfReader = new PdfReader(tempFileInfo);
493

    
494
                for (int i = 1; i <= pdfReader.NumberOfPages; i++)
495
                {
496
                    var mediaBox = pdfReader.GetPageSize(i);
497
                    var cropbox = pdfReader.GetCropBox(i);
498

    
499
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
500
                    //{
501
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
502
                    //}
503
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
504

    
505
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
506
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
507
                    //scaleWidth = 2.0832634F;
508
                    //scaleHeight = 3.0F;
509

    
510
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
511
                    //강인구 수정
512
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
513
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
514
                    //{
515
                    //    var pageDict = pdfReader.GetPageN(i);
516
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
517
                    //}
518
                }
519

    
520
                var memStream = new MemoryStream();
521
                var stamper = new PdfStamper(pdfReader, memStream)
522
                {
523
                    FormFlattening = true,                     
524
                    //FreeTextFlattening = true,
525
                    //AnnotationFlattening = true,                     
526
                };
527
                
528
                stamper.Close();
529
                pdfReader.Close();
530
                var array = memStream.ToArray();
531
                File.Delete(tempFileInfo);
532
                File.WriteAllBytes(TestFile.FullName, array);
533

    
534
                return TestFile.FullName;
535
            }
536
            else
537
            {
538
                return tempFileInfo;
539
            }
540
        }
541

    
542
        public void flattenPdfFile(string src, ref string dest)
543
        {
544
            PdfReader reader = new PdfReader(src);
545
            var memStream = new MemoryStream();
546
            var stamper = new PdfStamper(reader, memStream)
547
            {
548
                FormFlattening = true,
549
                FreeTextFlattening = true,
550
                AnnotationFlattening = true,
551
            };
552

    
553
            stamper.Close();
554
            var array = memStream.ToArray();
555
            File.WriteAllBytes(dest, array);
556
        }
557

    
558
        public void StatusChange(string message,int CurrentPage)
559
        {
560
            if(StatusChanged != null)
561
            {
562
                var sb = new StringBuilder();
563
                sb.AppendLine(message);
564

    
565
                StatusChanged(null, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = sb.ToString() });
566
            }
567
        }
568

    
569
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
570
        {
571
            try
572
            {
573
        
574
                FileInfo tempFileInfo = new FileInfo(testFile);
575

    
576
                if (!Directory.Exists(_FinalPDFStorgeLocal))
577
                {
578
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
579
                }
580
                string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
581
          
582

    
583
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
584
                {
585
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
586

    
587
                    #region 코멘트 적용 + 커버시트
588
                    using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
589
                    {
590
                        StatusChange("comment Cover",0);
591
                        
592
                        PdfReader pdfReader = new PdfReader(pdfStream);
593
                        //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
594
                        Dictionary<string, object> bookmark;
595
                        List<Dictionary<string, object>> outlines;
596

    
597
                        outlines = new List<Dictionary<string, object>>();
598
                        List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
599

    
600
                        var dic = new Dictionary<string, object>();
601

    
602
                        foreach (var data in MarkupDataSet)
603
                        {
604
                            StatusChange("MarkupDataSet", 0);
605

    
606
                            string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
607

    
608
                            string username = "";
609
                            string userdept = "";
610

    
611
                            using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
612
                            {
613
                                var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid);
614

    
615
                                if(memberlist.Count() > 0)
616
                                {
617
                                    username = memberlist.First().NAME;
618
                                    userdept = memberlist.First().DEPARTMENT;
619
                                }
620
                            }
621

    
622
                            bookmark = new Dictionary<string, object>();
623
                            bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
624
                            bookmark.Add("Page", data.PAGENUMBER + " Fit");
625
                            bookmark.Add("Action", "GoTo");
626
                            bookmark.Add("Kids", outlines);
627
                            root.Add(bookmark);
628
                        }
629

    
630

    
631
                        using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
632
                        {
633
                            AcroFields pdfFormFields = pdfStamper.AcroFields;
634

    
635
                            try
636
                            {
637
                                if (pdfFormFields.GenerateAppearances != true)
638
                                {
639
                                    pdfFormFields.GenerateAppearances = true;
640
                                }
641
                            }
642
                            catch (Exception ex)
643
                            {
644
                                SetNotice(FinalItem.ID, "this pdf is not AcroForm.");
645
                            }
646

    
647
                            var _SetColor = new SolidColorBrush(Colors.Red);
648

    
649
                            string[] delimiterChars = { "|DZ|" };
650
                            string[] delimiterChars2 = { "|" };
651

    
652
                            //pdfStamper.FormFlattening = true; //이미 선처리 작업함
653
                            pdfStamper.SetFullCompression();
654
                            _SetColor = new SolidColorBrush(Colors.Red);
655

    
656
                            foreach (var markupItem in MarkupDataSet)
657
                            {
658
                                /// 2020.11.13 김태성
659
                                /// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함.
660
                                var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER);
661

    
662
                                if(pageitems.Count() > 0)
663
                                {
664
                                    var currentPage = pageitems.First();
665
                                    pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
666
                                    //try
667
                                    //{
668
                        
669
                                    //}
670
                                    //catch (Exception ex)
671
                                    //{
672
                                    //    SetNotice(finaldata.ID, $"GetPageSizeWithRotation Error PageNO : {markupItem.PAGENUMBER} " + ex.ToString());
673
                                    //}
674
                                    //finally
675
                                    //{
676
                                    //    pdfSize = new iTextSharp.text.Rectangle(0, 0, float.Parse(currentPage.PAGE_WIDTH), float.Parse(currentPage.PAGE_HEIGHT));
677
                                    //}
678

    
679
                                    mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
680
                                    var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
681

    
682
                                    /// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다
683
                                    if (cropBox != null &&
684
                                        (cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom))
685
                                    {
686
                                        PdfDictionary dict = pdfReader.GetPageN(markupItem.PAGENUMBER);
687

    
688
                                        PdfArray oNewMediaBox = new PdfArray();
689
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Left));
690
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Top));
691
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Right));
692
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Bottom));
693
                                        dict.Put(PdfName.MEDIABOX, oNewMediaBox);
694

    
695
                                        pdfSize = cropBox;
696
                                    }
697

    
698
                                    scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
699
                                    scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
700

    
701
                                    pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
702
                                    _entity.SaveChanges();
703

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

    
706
                                    PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
707

    
708
                                    foreach (var data in markedData)
709
                                    {
710
                                        var item = JsonSerializerHelper.UnCompressString(data);
711
                                        var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
712

    
713
                                        try
714
                                        {
715
                                            switch (ControlT.Name)
716
                                            {
717
                                                #region LINE
718
                                                case "LineControl":
719
                                                    {
720
                                                        using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
721
                                                        {
722
                                                            DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
723
                                                        }
724
                                                    }
725
                                                    break;
726
                                                #endregion
727
                                                #region ArrowControlMulti
728
                                                case "ArrowControl_Multi":
729
                                                    {
730
                                                        using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
731
                                                        {
732
                                                            DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
733
                                                        }
734
                                                    }
735
                                                    break;
736
                                                #endregion
737
                                                #region PolyControl
738
                                                case "PolygonControl":
739
                                                    using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item))
740
                                                    {
741
                                                        string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
742
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
743
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
744
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
745
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
746
                                                        double Opacity = control.Opac;
747
                                                        DoubleCollection DashSize = control.DashSize;
748

    
749
                                                        Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
750
                                                    }
751
                                                    break;
752
                                                #endregion
753
                                                #region ArcControl or ArrowArcControl
754
                                                case "ArcControl":
755
                                                case "ArrowArcControl":
756
                                                    {
757
                                                        using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
758
                                                        {
759
                                                            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
760
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
761
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
762
                                                            Point MidPoint = GetPdfPointSystem(control.MidPoint);
763
                                                            DoubleCollection DashSize = control.DashSize;
764
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
765

    
766
                                                            var Opacity = control.Opac;
767
                                                            string UserID = control.UserID;
768
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
769
                                                            bool IsTransOn = control.IsTransOn;
770

    
771
                                                            if (control.IsTransOn)
772
                                                            {
773
                                                                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
774
                                                                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
775
                                                            }
776
                                                            else
777
                                                            {
778
                                                                Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
779
                                                            }
780

    
781
                                                            if (ControlT.Name == "ArrowArcControl")
782
                                                            {
783
                                                                Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
784
                                                                Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
785
                                                            }
786
                                                        }
787
                                                    }
788
                                                    break;
789
                                                #endregion
790
                                                #region RectangleControl
791
                                                case "RectangleControl":
792
                                                    using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
793
                                                    {
794
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
795
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
796
                                                        var PaintStyle = control.PaintState;
797
                                                        double Angle = control.Angle;
798
                                                        DoubleCollection DashSize = control.DashSize;
799
                                                        double Opacity = control.Opac;
800
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
801

    
802
                                                        Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
803
                                                    }
804
                                                    break;
805
                                                #endregion
806
                                                #region TriControl
807
                                                case "TriControl":
808
                                                    using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
809
                                                    {
810
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
811
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
812
                                                        var PaintStyle = control.Paint;
813
                                                        double Angle = control.Angle;
814
                                                        //StrokeColor = _SetColor, //색상은 레드
815
                                                        DoubleCollection DashSize = control.DashSize;
816
                                                        double Opacity = control.Opac;
817
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
818

    
819
                                                        Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
820
                                                    }
821
                                                    break;
822
                                                #endregion
823
                                                #region CircleControl
824
                                                case "CircleControl":
825
                                                    using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
826
                                                    {
827
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
828
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
829
                                                        var StartPoint = GetPdfPointSystem(control.StartPoint);
830
                                                        var EndPoint = GetPdfPointSystem(control.EndPoint);
831
                                                        var PaintStyle = control.PaintState;
832
                                                        double Angle = control.Angle;
833
                                                        DoubleCollection DashSize = control.DashSize;
834
                                                        double Opacity = control.Opac;
835
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
836
                                                        Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
837

    
838
                                                    }
839
                                                    break;
840
                                                #endregion
841
                                                #region RectCloudControl
842
                                                case "RectCloudControl":
843
                                                    using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
844
                                                    {
845
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
846
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
847
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
848
                                                        double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
849

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

    
852
                                                        var PaintStyle = control.PaintState;
853
                                                        double Opacity = control.Opac;
854
                                                        DoubleCollection DashSize = control.DashSize;
855

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

    
859
                                                        double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
860
                                                        bool reverse = (area < 0);
861
                                                        if (PaintStyle == PaintSet.None)
862
                                                        {
863
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
864
                                                        }
865
                                                        else
866
                                                        {
867
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
868
                                                        }
869
                                                    }
870
                                                    break;
871
                                                #endregion
872
                                                #region CloudControl
873
                                                case "CloudControl":
874
                                                    using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
875
                                                    {
876
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
877
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
878
                                                        double Toler = control.Toler;
879
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
880
                                                        double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
881
                                                        var PaintStyle = control.PaintState;
882
                                                        double Opacity = control.Opac;
883
                                                        bool isTransOn = control.IsTrans;
884
                                                        bool isChain = control.IsChain;
885

    
886
                                                        DoubleCollection DashSize = control.DashSize;
887

    
888
                                                        if (isChain)
889
                                                        {
890
                                                            Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
891
                                                        }
892
                                                        else
893
                                                        {
894
                                                            if (isTransOn)
895
                                                            {
896
                                                                double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
897
                                                                bool reverse = (area < 0);
898

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

    
947
                                                        //    DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
948
                                                        //}
949

    
950
                                                        //using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
951
                                                        //{
952
                                                        //    linecontrol.Angle = control.Angle;
953
                                                        //    linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 });
954
                                                        //    linecontrol.EndPoint = control.EndPoint;
955
                                                        //    linecontrol.MidPoint = control.MidPoint;
956
                                                        //    linecontrol.Name = "ArrowControl_Multi";
957
                                                        //    linecontrol.Opac = control.Opac;
958
                                                        //    linecontrol.PointSet = control.PointSet;
959
                                                        //    linecontrol.SizeSet = control.SizeSet;
960
                                                        //    linecontrol.StartPoint = control.StartPoint;
961
                                                        //    linecontrol.StrokeColor = control.StrokeColor;
962
                                                        //    linecontrol.TransformPoint = control.TransformPoint;
963

    
964
                                                        //    DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
965
                                                        //}
966
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
967
                                                        Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
968
                                                        Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
969
                                                        Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
970
                                                        bool isUnderLine = false;
971
                                                        string Text = "";
972
                                                        double fontsize = 30;
973

    
974
                                                        System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
975
                                                        Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
976
                                                        List<Point> tempPoint = new List<Point>();
977

    
978
                                                        double Angle = control.Angle;
979

    
980
                                                        if (Math.Abs(Angle).ToString() == "90")
981
                                                        {
982
                                                            Angle = 270;
983
                                                        }
984
                                                        else if (Math.Abs(Angle).ToString() == "270")
985
                                                        {
986
                                                            Angle = 90;
987
                                                        }
988

    
989
                                                        var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
990
                                                        tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
991
                                                        tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
992
                                                        tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
993
                                                        tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
994

    
995
                                                        var newStartPoint = tempStartPoint;
996
                                                        var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
997
                                                        var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
998

    
999
                                                        //Point testPoint = tempEndPoint;
1000
                                                        //if (Angle != 0)
1001
                                                        //{
1002
                                                        //    testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed);
1003
                                                        //   //testPoint = Test(rect, newMidPoint);
1004
                                                        //}
1005

    
1006
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1007
                                                        SolidColorBrush FontColor = _SetColor;
1008
                                                        bool isHighlight = control.isHighLight;
1009
                                                        double Opacity = control.Opac;
1010
                                                        PaintSet Paint = PaintSet.None;
1011

    
1012
                                                        switch (control.ArrowStyle)
1013
                                                        {
1014
                                                            case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
1015
                                                                {
1016
                                                                    Paint = PaintSet.None;
1017
                                                                }
1018
                                                                break;
1019
                                                            case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
1020
                                                                {
1021
                                                                    Paint = PaintSet.Hatch;
1022
                                                                }
1023
                                                                break;
1024
                                                            case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
1025
                                                                {
1026
                                                                    Paint = PaintSet.Fill;
1027
                                                                }
1028
                                                                break;
1029
                                                            default:
1030
                                                                break;
1031
                                                        }
1032
                                                        if (control.isHighLight) Paint |= PaintSet.Highlight;
1033

    
1034
                                                        if (Paint == PaintSet.Hatch)
1035
                                                        {
1036
                                                            Text = control.ArrowText;
1037
                                                        }
1038
                                                        else
1039
                                                        {
1040
                                                            Text = control.ArrowText;
1041
                                                        }
1042

    
1043
                                                        try
1044
                                                        {
1045
                                                            if (control.fontConfig.Count == 4)
1046
                                                            {
1047
                                                                fontsize = Convert.ToDouble(control.fontConfig[3]);
1048
                                                            }
1049

    
1050
                                                            //강인구 수정(2018.04.17)
1051
                                                            var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1052

    
1053
                                                            FontStyle fontStyle = FontStyles.Normal;
1054
                                                            if (FontStyles.Italic == TextStyle)
1055
                                                            {
1056
                                                                fontStyle = FontStyles.Italic;
1057
                                                            }
1058

    
1059
                                                            FontWeight fontWeight = FontWeights.Black;
1060

    
1061
                                                            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1062
                                                            if (FontWeights.Bold == TextWeight)
1063
                                                            {
1064
                                                                fontWeight = FontWeights.Bold;
1065
                                                            }
1066

    
1067
                                                            TextDecorationCollection decoration = TextDecorations.Baseline;
1068
                                                            if (control.fontConfig.Count() == 5)
1069
                                                            {
1070
                                                                decoration = TextDecorations.Underline;
1071
                                                            }
1072

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

    
1124
                                                    }
1125
                                                    break;
1126
                                                #endregion
1127
                                                #region SignControl
1128
                                                case "SignControl":
1129
                                                    using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1130
                                                    {
1131

    
1132
                                                        double Angle = control.Angle;
1133
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1134
                                                        Point TopRightPoint = GetPdfPointSystem(control.TR);
1135
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1136
                                                        Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1137
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1138
                                                        double Opacity = control.Opac;
1139
                                                        string UserNumber = control.UserNumber;
1140
                                                        Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1141
                                                    }
1142
                                                    break;
1143
                                                #endregion
1144
                                                #region MyRegion
1145
                                                case "DateControl":
1146
                                                    using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1147
                                                    {
1148
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1149
                                                        string Text = control.Text;
1150
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1151
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1152
                                                        List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1153
                                                        SolidColorBrush FontColor = _SetColor;
1154
                                                        double Angle = control.Angle;
1155
                                                        double Opacity = control.Opac;
1156
                                                        Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1157
                                                    }
1158
                                                    break;
1159
                                                #endregion
1160
                                                #region SymControlN (APPROVED)
1161
                                                case "SymControlN":
1162
                                                    using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1163
                                                    {
1164
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1165
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1166
                                                        List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1167
                                                        SolidColorBrush FontColor = _SetColor;
1168
                                                        double Angle = control.Angle;
1169
                                                        double Opacity = control.Opac;
1170

    
1171
                                                        var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
1172

    
1173
                                                        if (stamp.Count() > 0)
1174
                                                        {
1175
                                                            var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE);
1176

    
1177
                                                            Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata);
1178
                                                        }
1179

    
1180
                                                        string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1181

    
1182
                                                    }
1183
                                                    break;
1184
                                                case "SymControl":
1185
                                                    using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1186
                                                    {
1187
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1188
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1189
                                                        List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1190
                                                        SolidColorBrush FontColor = _SetColor;
1191
                                                        double Angle = control.Angle;
1192
                                                        double Opacity = control.Opac;
1193

    
1194
                                                        string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", "");
1195
                                                        Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1196
                                                    }
1197
                                                    break;
1198
                                                #endregion
1199
                                                #region Image
1200
                                                case "ImgControl":
1201
                                                    using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1202
                                                    {
1203
                                                        double Angle = control.Angle;
1204
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1205
                                                        Point TopRightPoint = GetPdfPointSystem(control.TR);
1206
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1207
                                                        Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1208
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1209
                                                        double Opacity = control.Opac;
1210
                                                        string FilePath = control.ImagePath;
1211
                                                        //Uri uri = new Uri(s.ImagePath);
1212

    
1213
                                                        Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1214
                                                    }
1215
                                                    break;
1216
                                                #endregion
1217
                                                default:
1218
                                                    StatusChange($"{ControlT.Name} Not Support", 0);
1219
                                                    break;
1220
                                            }
1221

    
1222
                                        }
1223
                                        catch (Exception ex)
1224
                                        {
1225
                                            StatusChange($"markupItem : {markupItem.ID}" + ex.ToString(), 0);
1226
                                        }
1227
                                    }
1228
                                }
1229

    
1230
                            }
1231
                            pdfStamper.Outlines = root;
1232
                            pdfStamper.Close();
1233
                            pdfReader.Close();
1234
                        }
1235
                    }
1236
                    #endregion
1237
                }
1238
                if (tempFileInfo.Exists)
1239
                {
1240
                    tempFileInfo.Delete();
1241
                }
1242

    
1243
                if (File.Exists(pdfFilePath))
1244
                {
1245
                    string destfilepath = null;
1246
                    try
1247
                    {
1248
                        FinalPDFPath = new FileInfo(pdfFilePath);
1249

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

    
1253
                        if(!string.IsNullOrEmpty(pdfmovepath))
1254
                        {
1255
                            _FinalPDFStorgeLocal = pdfmovepath;
1256
                        }
1257

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

    
1260
                        if (File.Exists(destfilepath))
1261
                            File.Delete(destfilepath);
1262

    
1263
                        File.Move(FinalPDFPath.FullName, destfilepath);
1264
                        FinalPDFPath = new FileInfo(destfilepath);
1265
                        File.Delete(pdfFilePath);
1266
                    }
1267
                    catch (Exception ex)
1268
                    {
1269
                        SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString());
1270
                    }
1271

    
1272
                    return true;
1273
                }
1274
            }
1275
            catch (Exception ex)
1276
            {
1277
                SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString());
1278
            }
1279
            return false;
1280
        }
1281

    
1282
        /// <summary>
1283
        /// kcom의 화살표방향과 틀려 추가함
1284
        /// </summary>
1285
        /// <param name="PageAngle"></param>
1286
        /// <param name="endP"></param>
1287
        /// <param name="ps">box Points</param>
1288
        /// <param name="IsFixed"></param>
1289
        /// <returns></returns>
1290
        private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed)
1291
        {
1292
            Point testP = endP;
1293

    
1294
            try
1295
            {
1296
                switch (Math.Abs(PageAngle).ToString())
1297
                {
1298
                    case "90":
1299
                        testP = new Point(endP.X + 50, endP.Y);
1300
                        break;
1301
                    case "270":
1302
                        testP = new Point(endP.X - 50, endP.Y);
1303
                        break;
1304
                }
1305

    
1306
                //20180910 LJY 각도에 따라.
1307
                switch (Math.Abs(PageAngle).ToString())
1308
                {
1309
                    case "90":
1310
                        if (IsFixed)
1311
                        {
1312
                            if (ps[0] == endP) //상단
1313
                            {
1314
                                testP = new Point(endP.X, endP.Y + 50);
1315
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1316
                            }
1317
                            else if (ps[1] == endP) //하단
1318
                            {
1319
                                testP = new Point(endP.X, endP.Y - 50);
1320
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1321
                            }
1322
                            else if (ps[2] == endP) //좌단
1323
                            {
1324
                                testP = new Point(endP.X - 50, endP.Y);
1325
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1326
                            }
1327
                            else if (ps[3] == endP) //우단
1328
                            {
1329
                                testP = new Point(endP.X + 50, endP.Y);
1330
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1331
                            }
1332
                        }
1333
                        break;
1334
                    case "270":
1335
                        if (IsFixed)
1336
                        {
1337
                            if (ps[0] == endP) //상단
1338
                            {
1339
                                testP = new Point(endP.X, endP.Y - 50);
1340
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1341
                            }
1342
                            else if (ps[1] == endP) //하단
1343
                            {
1344
                                testP = new Point(endP.X, endP.Y + 50);
1345
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1346
                            }
1347
                            else if (ps[2] == endP) //좌단
1348
                            {
1349
                                testP = new Point(endP.X + 50, endP.Y);
1350
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1351
                            }
1352
                            else if (ps[3] == endP) //우단
1353
                            {
1354
                                testP = new Point(endP.X - 50, endP.Y);
1355
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1356
                            }
1357
                        }
1358
                        break;
1359
                    default:
1360
                        if (IsFixed)
1361
                        {
1362

    
1363
                            if (ps[0] == endP) //상단
1364
                            {
1365
                                testP = new Point(endP.X, endP.Y - 50);
1366
                                //System.Diagnostics.Debug.WriteLine("상단");
1367
                            }
1368
                            else if (ps[1] == endP) //하단
1369
                            {
1370
                                testP = new Point(endP.X, endP.Y + 50);
1371
                                //System.Diagnostics.Debug.WriteLine("하단");
1372
                            }
1373
                            else if (ps[2] == endP) //좌단
1374
                            {
1375
                                testP = new Point(endP.X - 50, endP.Y);
1376
                                //System.Diagnostics.Debug.WriteLine("좌단");
1377
                            }
1378
                            else if (ps[3] == endP) //우단
1379
                            {
1380
                                testP = new Point(endP.X + 50, endP.Y);
1381
                                //System.Diagnostics.Debug.WriteLine("우단");
1382
                            }
1383
                        }
1384
                        break;
1385
                }
1386

    
1387
            }
1388
            catch (Exception)
1389
            {
1390
            }
1391

    
1392
            return testP;
1393
        }
1394

    
1395
        private Point Test(Rect rect,Point point)
1396
        {
1397
            Point result = new Point();
1398

    
1399
            Point newPoint = new Point();
1400

    
1401
            double oldNear = 0;
1402
            double newNear = 0;
1403

    
1404
            oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result);
1405

    
1406
            newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint);
1407

    
1408
            if (newNear < oldNear)
1409
            {
1410
                oldNear = newNear;
1411
                result = newPoint;
1412
            }
1413

    
1414
            newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint);
1415

    
1416
            if (newNear < oldNear)
1417
            {
1418
                oldNear = newNear;
1419
                result = newPoint;
1420
            }
1421

    
1422

    
1423
            newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint);
1424

    
1425
            if (newNear < oldNear)
1426
            {
1427
                oldNear = newNear;
1428
                result = newPoint;
1429
            }
1430

    
1431
            return result;
1432
        }
1433

    
1434
        private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, SolidColorBrush setColor)
1435
        {
1436
            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1437
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1438
            Point MidPoint = GetPdfPointSystem(control.MidPoint);
1439
            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1440
            DoubleCollection DashSize = control.DashSize;
1441
            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1442
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
1443

    
1444
            double Opacity = control.Opac;
1445

    
1446
            if (EndPoint == MidPoint)
1447
            {
1448
                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1449
            }
1450
            else
1451
            {
1452
                Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity);
1453
            }
1454

    
1455
            Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity);
1456

    
1457
        }
1458

    
1459
        private void DrawLine(S_LineControl control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, SolidColorBrush setColor)
1460
        {
1461
            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1462
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1463
            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1464
            DoubleCollection DashSize = control.DashSize;
1465
            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1466

    
1467
            var Opacity = control.Opac;
1468
            string UserID = control.UserID;
1469
            double Interval = control.Interval;
1470
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
1471
            Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, setColor, Opacity);
1472
            switch (control.LineStyleSet)
1473
            {
1474
                case LineStyleSet.ArrowLine:
1475
                    Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1476
                    break;
1477
                case LineStyleSet.CancelLine:
1478
                    {
1479
                        var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X)));
1480
                        var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y)));
1481

    
1482
                        if (x > y)
1483
                        {
1484
                            StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
1485
                            EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
1486
                            Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, setColor, Opacity);
1487
                        }
1488
                    }
1489
                    break;
1490
                case LineStyleSet.TwinLine:
1491
                    {
1492
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1493
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1494
                    }
1495
                    break;
1496
                case LineStyleSet.DimLine:
1497
                    {
1498
                        Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1499
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1500
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1501
                    }
1502
                    break;
1503
                default:
1504
                    break;
1505
            }
1506

    
1507
        }
1508

    
1509
        private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,SolidColorBrush setColor)
1510
        {
1511
            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1512
            string Text = control.Text;
1513

    
1514
            bool isUnderline = false;
1515
            control.BoxW -= scaleWidth;
1516
            control.BoxH -= scaleHeight;
1517
            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
1518
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1519
            Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
1520

    
1521
            List<Point> pointSet = new List<Point>();
1522
            pointSet.Add(StartPoint);
1523
            pointSet.Add(EndPoint);
1524

    
1525
            PaintSet paint = PaintSet.None;
1526
            switch (control.paintMethod)
1527
            {
1528
                case 1:
1529
                    {
1530
                        paint = PaintSet.Fill;
1531
                    }
1532
                    break;
1533
                case 2:
1534
                    {
1535
                        paint = PaintSet.Hatch;
1536
                    }
1537
                    break;
1538
                default:
1539
                    break;
1540
            }
1541
            if (control.isHighLight) paint |= PaintSet.Highlight;
1542

    
1543
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1544
            double TextSize = Convert.ToDouble(data2[1]);
1545
            SolidColorBrush FontColor = setColor;
1546
            double Angle = control.Angle;
1547
            double Opacity = control.Opac;
1548
            FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]);
1549
            var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1550

    
1551
            FontStyle fontStyle = FontStyles.Normal;
1552
            if (FontStyles.Italic == TextStyle)
1553
            {
1554
                fontStyle = FontStyles.Italic;
1555
            }
1556

    
1557
            FontWeight fontWeight = FontWeights.Black;
1558

    
1559
            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1560
            //강인구 수정(2018.04.17)
1561
            if (FontWeights.Bold == TextWeight)
1562
            //if (FontWeights.ExtraBold == TextWeight)
1563
            {
1564
                fontWeight = FontWeights.Bold;
1565
            }
1566

    
1567
            TextDecorationCollection decoration = TextDecorations.Baseline;
1568
            if (control.fontConfig.Count() == 4)
1569
            {
1570
                decoration = TextDecorations.Underline;
1571
            }
1572

    
1573
            Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1574
        }
1575
    
1576

    
1577
        ~MarkupToPDF()
1578
        {
1579
            this.Dispose(false);
1580
        }
1581

    
1582
        private bool disposed;
1583

    
1584
        public void Dispose()
1585
        {
1586
            this.Dispose(true);
1587
            GC.SuppressFinalize(this);
1588
        }
1589

    
1590
        protected virtual void Dispose(bool disposing)
1591
        {
1592
            if (this.disposed) return;
1593
            if (disposing)
1594
            {
1595
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
1596
            }
1597
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
1598
            this.disposed = true;
1599
        }
1600

    
1601
        #endregion
1602
    }
1603
}
클립보드 이미지 추가 (최대 크기: 500 MB)