프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
149
        #endregion
150

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

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

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

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

    
174
                throw;
175
            }
176

    
177
            return result;
178

    
179
        }
180

    
181
        #region 생성자 & 소멸자
182
        public void MakeFinalPDF(object _FinalPDF)
183
        {
184
            DOCUMENT_ITEM documentItem;
185
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
186
            FinalItem = FinalPDF;
187

    
188

    
189
            string PdfFilePathRoot = null;
190
            string TestFile = System.IO.Path.GetTempFileName();
191

    
192
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
193
            try
194
            {
195
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
196
                {
197
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
198

    
199
                    if (_properties.Count() > 0)
200
                    {
201
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0)
202
                        {
203
                            SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : TileSourcePath Not Found.");
204
                            return;
205
                        }
206
                        else
207
                        {
208
                            PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
209
                        }
210

    
211
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).Count() == 0)
212
                        {
213
                            SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeLocal Not Found.");
214
                            return;
215
                        }
216
                        else
217
                        {
218
                            _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
219
                        }
220

    
221

    
222
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).Count() == 0)
223
                        {
224
                            SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeRemote Not Found.");
225
                            return;
226
                        }
227
                        else
228
                        {
229
                            _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
230
                        }
231
                    }
232
                    else
233
                    {
234
                        SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : Final PDF Properties Not Found.");
235
                        return;
236
                    }
237

    
238
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
239

    
240
                    if (finalList.Count() > 0)
241
                    {
242
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
243
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
244
                        _entity.SaveChanges();
245
                    }
246

    
247
                }
248
            }
249
            catch (Exception ex)
250
            {
251
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
252
                return;
253
            }
254
            #endregion
255

    
256
            #region 문서 복사
257
            try
258
            {
259
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
260
                {
261
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
262

    
263
                    if (_DOCINFO.Count() > 0)
264
                    {
265
                        DocInfoItem = _DOCINFO.First();
266

    
267
                        DocPageItem = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == DocInfoItem.ID).ToList();
268

    
269
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
270
                                         + (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5))
271
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
272

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

    
275
                        if (infoItems.Count() == 0)
276
                        {
277
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
278
                        }
279
                        else
280
                        {
281
                            MarkupInfoItem = infoItems.First();
282

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

    
285
                            if (markupInfoVerItems.Count() > 0)
286
                            {
287
                                var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First();
288

    
289
                                MarkupDataSet = _entity.MARKUP_DATA.Where(x => x.MARKUPINFO_VERSION_ID == markupInfoVerItem.ID).OrderBy(d => d.PAGENUMBER).ToList();
290
                            }
291
                            else
292
                            {
293
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
294
                            }
295
                        }
296

    
297
                        documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault();
298
                        if (documentItem == null)
299
                        {
300
                            throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
301
                        }
302

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

    
305
                        #region 파일 체크
306
                        if (_files.Count() == 1)
307
                        {
308
                            /// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정
309
                            //if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()))
310
                            //{
311
                            OriginFileName = _files.First().Name;
312
                            PdfFilePath = _files.First().CopyTo(TestFile, true);
313
                            StatusChange($"Copy File  file Count = 1 : {PdfFilePath}", 0);
314
                            //}
315
                            //else
316
                            //{
317
                            //    throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower());
318
                            //}
319
                        }
320
                        else if (_files.Count() > 1)
321
                        {
322
                            var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault();
323

    
324
                            if (originalFile == null)
325
                            {
326
                                throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
327
                            }
328
                            else
329
                            {
330
                                OriginFileName = originalFile.Name;
331
                                PdfFilePath = originalFile.CopyTo(TestFile, true);
332
                                StatusChange($"Copy File file Count  > 1 : {PdfFilePath}", 0);
333
                            }
334
                        }
335
                        else
336
                        {
337
                            throw new FileNotFoundException("PDF를 찾지 못하였습니다");
338
                        }
339
                        #endregion
340

    
341
                        #region 예외처리
342
                        if (PdfFilePath == null)
343
                        {
344
                            throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
345
                        }
346
                        if (!PdfFilePath.Exists)
347
                        {
348
                            throw new Exception("PDF원본이 존재하지 않습니다");
349
                        }
350
                        #endregion
351

    
352
                    }
353
                    else
354
                    {
355
                        throw new Exception("일치하는 DocInfo가 없습니다");
356
                    }
357
                }
358
            }
359
            catch (Exception ex)
360
            {
361
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
362
                {
363
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
364
                    //System.Diagnostics.Process process = new System.Diagnostics.Process();
365
                    //process.StartInfo.FileName = "cmd";
366
                    //process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
367
                    //process.Start();
368
                }
369
                else
370
                {
371
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
372
                }
373
            }
374
            #endregion
375

    
376
            try
377
            {
378

    
379
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
380
                {
381
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
382
                    if (finalList.Count() > 0)
383
                    {
384
                        //TestFile = SetFlattingPDF(TestFile);
385
                        //StatusChange($"SetFlattingPDF : {TestFile}", 0);
386

    
387
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
388

    
389
                        StatusChange($"SetStampInPDF : {TestFile}", 0);
390
                    }
391
                }
392
                if (EndFinal != null)
393
                {
394
                    EndFinal(this, new EndFinalEventArgs
395
                    {
396
                        FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name,
397
                        OriginPDFName = OriginFileName,
398
                        FinalPDFPath = FinalPDFPath.FullName,
399
                        Error = "",
400
                        Message = "",
401
                        FinalPDF = FinalPDF,
402
                    });
403
                }
404
            }
405
            catch (Exception ex)
406
            {
407
                SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message);
408
            }
409
        }
410
        #endregion
411

    
412
        #region PDF
413
        public static float scaleWidth { get; set; } = 0;
414
        public static float scaleHeight { get; set; } = 0;
415

    
416
        private string SetFlattingPDF(string tempFileInfo)
417
        {
418
            if (File.Exists(tempFileInfo))
419
            {
420
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
421

    
422
                PdfReader pdfReader = new PdfReader(tempFileInfo);
423

    
424
                for (int i = 1; i <= pdfReader.NumberOfPages; i++)
425
                {
426
                    var mediaBox = pdfReader.GetPageSize(i);
427
                    var cropbox = pdfReader.GetCropBox(i);
428

    
429
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
430
                    //{
431
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
432
                    //}
433
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
434

    
435
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
436
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
437
                    //scaleWidth = 2.0832634F;
438
                    //scaleHeight = 3.0F;
439

    
440
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
441
                    //강인구 수정
442
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
443
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
444
                    //{
445
                    //    var pageDict = pdfReader.GetPageN(i);
446
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
447
                    //}
448
                }
449

    
450
                var memStream = new MemoryStream();
451
                var stamper = new PdfStamper(pdfReader, memStream)
452
                {
453
                    FormFlattening = true,                     
454
                    //FreeTextFlattening = true,
455
                    //AnnotationFlattening = true,                     
456
                };
457
                
458
                stamper.Close();
459
                pdfReader.Close();
460
                var array = memStream.ToArray();
461
                File.Delete(tempFileInfo);
462
                File.WriteAllBytes(TestFile.FullName, array);
463

    
464
                return TestFile.FullName;
465
            }
466
            else
467
            {
468
                return tempFileInfo;
469
            }
470
        }
471

    
472
        public void flattenPdfFile(string src, ref string dest)
473
        {
474
            PdfReader reader = new PdfReader(src);
475
            var memStream = new MemoryStream();
476
            var stamper = new PdfStamper(reader, memStream)
477
            {
478
                FormFlattening = true,
479
                FreeTextFlattening = true,
480
                AnnotationFlattening = true,
481
            };
482

    
483
            stamper.Close();
484
            var array = memStream.ToArray();
485
            File.WriteAllBytes(dest, array);
486
        }
487

    
488
        public void StatusChange(string message,int CurrentPage)
489
        {
490
            if(StatusChanged != null)
491
            {
492
                //var sb = new StringBuilder();
493
                //sb.AppendLine(message);
494

    
495
                StatusChanged(this, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = message });
496
            }
497
        }
498

    
499
        /// <summary>
500
        /// PDF에 Markup 데이터를 쓴다.
501
        /// </summary>
502
        /// <param name="finaldata"></param>
503
        /// <param name="testFile"></param>
504
        /// <param name="markupInfo"></param>
505
        /// <returns></returns>
506
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
507
        {
508
            try
509
            {
510
                FileInfo tempFileInfo = new FileInfo(testFile);
511

    
512
                if (!Directory.Exists(_FinalPDFStorgeLocal))
513
                {
514
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
515
                }
516

    
517
                string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
518
          
519

    
520
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
521
                {
522
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
523

    
524
                    #region 코멘트 적용 + 커버시트
525
                    using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
526
                    {
527
                        StatusChange("comment Cover",0);
528

    
529
                        using (PdfReader pdfReader = new PdfReader(pdfStream))
530
                        { 
531
                            //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
532
                            Dictionary<string, object> bookmark;
533
                            List<Dictionary<string, object>> outlines;
534

    
535
                            outlines = new List<Dictionary<string, object>>();
536
                            List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
537

    
538
                            var dic = new Dictionary<string, object>();
539

    
540
                            #region  북마크 생성
541
                            foreach (var data in MarkupDataSet)
542
                            {
543
                                //StatusChange("MarkupDataSet", 0);
544

    
545
                                string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
546

    
547
                                string username = "";
548
                                string userdept = "";
549

    
550
                                using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
551
                                {
552
                                    var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid);
553

    
554
                                    if(memberlist.Any())
555
                                    {
556
                                        username = memberlist[0].NAME;
557
                                        userdept = memberlist[0].DEPARTMENT;
558
                                    }
559
                                }
560

    
561
                                bookmark = new Dictionary<string, object>();
562
                                bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
563
                                bookmark.Add("Page", data.PAGENUMBER + " Fit");
564
                                bookmark.Add("Action", "GoTo");
565
                                bookmark.Add("Kids", outlines);
566
                                root.Add(bookmark);
567
                            }
568
                            #endregion
569

    
570
                            iTextSharp.text.Version.GetInstance();
571

    
572
                            using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
573
                            {
574
                                try
575
                                {
576
                                    if (pdfStamper.AcroFields != null && pdfStamper.AcroFields.GenerateAppearances != true)
577
                                    {
578
                                        pdfStamper.AcroFields.GenerateAppearances = true;
579
                                    }
580
                                }
581
                                catch (Exception ex)
582
                                {
583
                                    SetNotice(FinalItem.ID, "this pdf is not AcroForm.");
584
                                }
585

    
586
                                #region Markup 색상을 설정한다.(DB에 값이 있으면 DB 값으로 설정한다.)
587
                                System.Drawing.Color _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
588
                                #endregion
589

    
590
                                string[] delimiterChars = { "|DZ|" };
591
                                string[] delimiterChars2 = { "|" };
592

    
593
                                //pdfStamper.FormFlattening = true; //이미 선처리 작업함
594
                                pdfStamper.SetFullCompression();
595
                                _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red);
596

    
597
                                StringBuilder strLog = new StringBuilder();
598
                                int lastPageNo = 0;
599

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

    
602
                                var groups = MarkupDataSet.GroupBy(x => x.PAGENUMBER);
603
                                foreach (var group in groups)
604
                                {
605
                                    int PageNumber = group.Key;
606
                                    #region ZIndex 값으로 정렬한다.
607
                                    var items = new List<Tuple<string, S_BaseControl>>();
608
                                    foreach (var item in group)
609
                                    {
610
                                        var tokens = item.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries).ToList();
611
                                        items.AddRange(tokens.ConvertAll(x =>
612
                                        {
613
                                            var str = JsonSerializerHelper.UnCompressString(x);
614
                                            var control = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(str);
615
                                            return new Tuple<string, S_BaseControl>(str, control);
616
                                        }));
617
                                    }
618

    
619
                                    var ordered = items.OrderBy(x => x.Item2.ZIndex);
620
                                    #endregion
621

    
622
                                    foreach (var order in ordered)
623
                                    {
624
                                        /// 2020.11.13 김태성
625
                                        /// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함.
626
                                        var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == PageNumber);
627
                                        if (pageitems.Any())
628
                                        {
629
                                            var currentPage = pageitems.First();
630
                                            pdfSize = pdfReader.GetPageSizeWithRotation(PageNumber);
631
                                            lastPageNo = PageNumber;
632

    
633
                                            mediaBox = pdfReader.GetPageSize(PageNumber);
634
                                            var cropBox = pdfReader.GetCropBox(PageNumber);
635

    
636
                                            /// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다
637
                                            if (cropBox != null &&
638
                                                (cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom))
639
                                            {
640
                                                PdfDictionary dict = pdfReader.GetPageN(PageNumber);
641

    
642
                                                PdfArray oNewMediaBox = new PdfArray();
643
                                                oNewMediaBox.Add(new PdfNumber(cropBox.Left));
644
                                                oNewMediaBox.Add(new PdfNumber(cropBox.Top));
645
                                                oNewMediaBox.Add(new PdfNumber(cropBox.Right));
646
                                                oNewMediaBox.Add(new PdfNumber(cropBox.Bottom));
647
                                                dict.Put(PdfName.MEDIABOX, oNewMediaBox);
648

    
649
                                                pdfSize = cropBox;
650
                                            }
651

    
652
                                            scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
653
                                            scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
654

    
655
                                            pdfLink.CURRENT_PAGE = PageNumber;
656
                                            _entity.SaveChanges();
657

    
658
                                            PdfContentByte contentByte = pdfStamper.GetOverContent(PageNumber);
659
                                            var item = order.Item1;
660
                                            var ControlT = order.Item2;
661

    
662
                                            try
663
                                            {
664
                                                switch (ControlT.Name)
665
                                                {
666
                                                    #region LINE
667
                                                    case "LineControl":
668
                                                        {
669
                                                            using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
670
                                                            {
671
                                                                DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
672
                                                            }
673
                                                        }
674
                                                        break;
675
                                                    #endregion
676
                                                    #region ArrowControlMulti
677
                                                    case "ArrowControl_Multi":
678
                                                        {
679
                                                            using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
680
                                                            {
681
                                                                DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
682
                                                            }
683
                                                        }
684
                                                        break;
685
                                                    #endregion
686
                                                    #region PolyControl
687
                                                    case "PolygonControl":
688
                                                        using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item))
689
                                                        {
690
                                                            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
691
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
692
                                                            var PaintStyle = control.PaintState;
693
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
694
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
695
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
696
                                                            double Opacity = control.Opac;
697
                                                            DoubleCollection DashSize = control.DashSize;
698

    
699
                                                            Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity);
700
                                                            //Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
701
                                                        }
702
                                                        break;
703
                                                    #endregion
704
                                                    #region ArcControl or ArrowArcControl
705
                                                    case "ArcControl":
706
                                                    case "ArrowArcControl":
707
                                                        {
708
                                                            using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
709
                                                            {
710
                                                                string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
711
                                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
712
                                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
713
                                                                Point MidPoint = GetPdfPointSystem(control.MidPoint);
714
                                                                DoubleCollection DashSize = control.DashSize;
715
                                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
716

    
717
                                                                var Opacity = control.Opac;
718
                                                                string UserID = control.UserID;
719
                                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
720
                                                                bool IsTransOn = control.IsTransOn;
721

    
722
                                                                if (control.IsTransOn)
723
                                                                {
724
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
725
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
726
                                                                }
727
                                                                else
728
                                                                {
729
                                                                    Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity);
730
                                                                }
731

    
732
                                                                if (ControlT.Name == "ArrowArcControl")
733
                                                                {
734
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
735
                                                                    Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
736
                                                                }
737
                                                            }
738
                                                        }
739
                                                        break;
740
                                                    #endregion
741
                                                    #region RectangleControl
742
                                                    case "RectangleControl":
743
                                                        using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
744
                                                        {
745
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
746
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
747
                                                            var PaintStyle = control.PaintState;
748
                                                            double Angle = control.Angle;
749
                                                            DoubleCollection DashSize = control.DashSize;
750
                                                            double Opacity = control.Opac;
751
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
752

    
753
                                                            Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
754
                                                        }
755
                                                        break;
756
                                                    #endregion
757
                                                    #region TriControl
758
                                                    case "TriControl":
759
                                                        using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
760
                                                        {
761
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
762
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
763
                                                            var PaintStyle = control.Paint;
764
                                                            double Angle = control.Angle;
765
                                                            //StrokeColor = _SetColor, //색상은 레드
766
                                                            DoubleCollection DashSize = control.DashSize;
767
                                                            double Opacity = control.Opac;
768
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
769

    
770
                                                            Controls_PDF.DrawSet_Shape.DrawTriangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity);
771
                                                        }
772
                                                        break;
773
                                                    #endregion
774
                                                    #region CircleControl
775
                                                    case "CircleControl":
776
                                                        using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
777
                                                        {
778
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
779
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
780
                                                            var StartPoint = GetPdfPointSystem(control.StartPoint);
781
                                                            var EndPoint = GetPdfPointSystem(control.EndPoint);
782
                                                            var PaintStyle = control.PaintState;
783
                                                            double Angle = control.Angle;
784
                                                            DoubleCollection DashSize = control.DashSize;
785
                                                            double Opacity = control.Opac;
786
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
787
                                                            Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
788

    
789
                                                        }
790
                                                        break;
791
                                                    #endregion
792
                                                    #region RectCloudControl
793
                                                    case "RectCloudControl":
794
                                                        using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
795
                                                        {
796
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
797
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
798
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
799
                                                            double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
800

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

    
803
                                                            var PaintStyle = control.PaintState;
804
                                                            double Opacity = control.Opac;
805
                                                            DoubleCollection DashSize = control.DashSize;
806

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

    
810
                                                            double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
811
                                                            bool reverse = (area < 0);
812

    
813
                                                            Controls_PDF.DrawSet_Cloud.DrawCloudRect(PointSet, LineSize, (int)rotate, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
814
                                                        }
815
                                                        break;
816
                                                    #endregion
817
                                                    #region CloudControl
818
                                                    case "CloudControl":
819
                                                        using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
820
                                                        {
821
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
822
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
823
                                                            double Toler = control.Toler;
824
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
825
                                                            double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
826
                                                            var PaintStyle = control.PaintState;
827
                                                            double Opacity = control.Opac;
828
                                                            bool isTransOn = control.IsTrans;
829
                                                            bool isChain = control.IsChain;
830

    
831
                                                            DoubleCollection DashSize = control.DashSize;
832

    
833
                                                            if (isChain)
834
                                                            {
835
                                                                Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
836
                                                            }
837
                                                            else
838
                                                            {
839
                                                                if (isTransOn)
840
                                                                {
841
                                                                    double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
842
                                                                    bool reverse = (area < 0);
843

    
844
                                                                    if (PaintStyle == PaintSet.None)
845
                                                                    {
846
                                                                        Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
847
                                                                    }
848
                                                                    else
849
                                                                    {
850
                                                                        Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
851
                                                                    }
852
                                                                }
853
                                                                else
854
                                                                {
855
                                                                    Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
856
                                                                }
857
                                                            }
858
                                                        }
859
                                                        break;
860
                                                    #endregion
861
                                                    #region TEXT
862
                                                    case "TextControl":
863
                                                        using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
864
                                                        {
865
                                                            DrawTextBox(control, contentByte, delimiterChars, delimiterChars2, _SetColor);
866
                                                        }
867
                                                        break;
868
                                                    #endregion
869
                                                    #region ArrowTextControl
870
                                                    case "ArrowTextControl":
871
                                                        using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item))
872
                                                        {
873
                                                            //using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
874
                                                            //{
875
                                                            //    textcontrol.Angle = control.Angle;
876
                                                            //    textcontrol.BoxH = control.BoxHeight;
877
                                                            //    textcontrol.BoxW = control.BoxWidth;
878
                                                            //    textcontrol.EndPoint = control.EndPoint;
879
                                                            //    textcontrol.FontColor = "#FFFF0000";
880
                                                            //    textcontrol.Name = "TextControl";
881
                                                            //    textcontrol.Opac = control.Opac;
882
                                                            //    textcontrol.PointSet = new List<Point>();
883
                                                            //    textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]);
884
                                                            //    textcontrol.StartPoint = control.StartPoint;
885
                                                            //    textcontrol.Text = control.ArrowText;
886
                                                            //    textcontrol.TransformPoint = control.TransformPoint;
887
                                                            //    textcontrol.UserID = null;
888
                                                            //    textcontrol.fontConfig = control.fontConfig;
889
                                                            //    textcontrol.isHighLight = control.isHighLight;
890
                                                            //    textcontrol.paintMethod = 1;
891

    
892
                                                            //    DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
893
                                                            //}
894

    
895
                                                            //using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
896
                                                            //{
897
                                                            //    linecontrol.Angle = control.Angle;
898
                                                            //    linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 });
899
                                                            //    linecontrol.EndPoint = control.EndPoint;
900
                                                            //    linecontrol.MidPoint = control.MidPoint;
901
                                                            //    linecontrol.Name = "ArrowControl_Multi";
902
                                                            //    linecontrol.Opac = control.Opac;
903
                                                            //    linecontrol.PointSet = control.PointSet;
904
                                                            //    linecontrol.SizeSet = control.SizeSet;
905
                                                            //    linecontrol.StartPoint = control.StartPoint;
906
                                                            //    linecontrol.StrokeColor = control.StrokeColor;
907
                                                            //    linecontrol.TransformPoint = control.TransformPoint;
908

    
909
                                                            //    DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
910
                                                            //}
911
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
912
                                                            Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
913
                                                            Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
914
                                                            Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
915
                                                            bool isUnderLine = false;
916
                                                            string Text = "";
917
                                                            double fontsize = 30;
918

    
919
                                                            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
920
                                                            Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
921
                                                            List<Point> tempPoint = new List<Point>();
922

    
923
                                                            double Angle = control.Angle;
924

    
925
                                                            if (Math.Abs(Angle).ToString() == "90")
926
                                                            {
927
                                                                Angle = 270;
928
                                                            }
929
                                                            else if (Math.Abs(Angle).ToString() == "270")
930
                                                            {
931
                                                                Angle = 90;
932
                                                            }
933

    
934
                                                            var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
935
                                                            tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
936
                                                            tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
937
                                                            tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
938
                                                            tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
939

    
940
                                                            var newStartPoint = tempStartPoint;
941
                                                            var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
942
                                                            var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
943

    
944
                                                            //Point testPoint = tempEndPoint;
945
                                                            //if (Angle != 0)
946
                                                            //{
947
                                                            //    testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed);
948
                                                            //   //testPoint = Test(rect, newMidPoint);
949
                                                            //}
950

    
951
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
952
                                                            System.Drawing.Color FontColor = _SetColor;
953
                                                            bool isHighlight = control.isHighLight;
954
                                                            double Opacity = control.Opac;
955
                                                            PaintSet Paint = PaintSet.None;
956

    
957
                                                            switch (control.ArrowStyle)
958
                                                            {
959
                                                                case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
960
                                                                    {
961
                                                                        Paint = PaintSet.None;
962
                                                                    }
963
                                                                    break;
964
                                                                case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
965
                                                                    {
966
                                                                        Paint = PaintSet.Hatch;
967
                                                                    }
968
                                                                    break;
969
                                                                case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
970
                                                                    {
971
                                                                        Paint = PaintSet.Fill;
972
                                                                    }
973
                                                                    break;
974
                                                                default:
975
                                                                    break;
976
                                                            }
977
                                                            if (control.isHighLight) Paint |= PaintSet.Highlight;
978

    
979
                                                            if (Paint == PaintSet.Hatch)
980
                                                            {
981
                                                                Text = control.ArrowText;
982
                                                            }
983
                                                            else
984
                                                            {
985
                                                                Text = control.ArrowText;
986
                                                            }
987

    
988
                                                            try
989
                                                            {
990
                                                                if (control.fontConfig.Count == 4)
991
                                                                {
992
                                                                    fontsize = Convert.ToDouble(control.fontConfig[3]);
993
                                                                }
994

    
995
                                                                //강인구 수정(2018.04.17)
996
                                                                var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
997

    
998
                                                                FontStyle fontStyle = FontStyles.Normal;
999
                                                                if (FontStyles.Italic == TextStyle)
1000
                                                                {
1001
                                                                    fontStyle = FontStyles.Italic;
1002
                                                                }
1003

    
1004
                                                                FontWeight fontWeight = FontWeights.Black;
1005

    
1006
                                                                var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1007
                                                                if (FontWeights.Bold == TextWeight)
1008
                                                                {
1009
                                                                    fontWeight = FontWeights.Bold;
1010
                                                                }
1011

    
1012
                                                                TextDecorationCollection decoration = TextDecorations.Baseline;
1013
                                                                if (control.fontConfig.Count() == 5)
1014
                                                                {
1015
                                                                    decoration = TextDecorations.Underline;
1016
                                                                }
1017

    
1018
                                                                if (control.isTrans)
1019
                                                                {
1020
                                                                    //인구 수정 Arrow Text Style적용 되도록 변경
1021
                                                                    Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
1022
                                                                    newStartPoint, tempMidPoint, newEndPoint, control.isFixed,
1023
                                                                    LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1024
                                                                }
1025
                                                                else
1026
                                                                {
1027
                                                                    if (control.isFixed)
1028
                                                                    {
1029
                                                                        var testP = new Point(0, 0);
1030
                                                                        if (control.isFixed)
1031
                                                                        {
1032
                                                                            if (tempPoint[1] == newEndPoint)
1033
                                                                            {
1034
                                                                                testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
1035
                                                                            }
1036
                                                                            else if (tempPoint[3] == newEndPoint)
1037
                                                                            {
1038
                                                                                testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
1039
                                                                            }
1040
                                                                            else if (tempPoint[0] == newEndPoint)
1041
                                                                            {
1042
                                                                                testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
1043
                                                                            }
1044
                                                                            else if (tempPoint[2] == newEndPoint)
1045
                                                                            {
1046
                                                                                testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
1047
                                                                            }
1048
                                                                        }
1049
                                                                        //인구 수정 Arrow Text Style적용 되도록 변경
1050
                                                                        Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
1051
                                                                            tempStartPoint, testP, tempEndPoint, control.isFixed,
1052
                                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
1053
                                                                        FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1054
                                                                    }
1055
                                                                    else
1056
                                                                    {
1057
                                                                        //인구 수정 Arrow Text Style적용 되도록 변경
1058
                                                                        Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
1059
                                                                            newStartPoint, tempMidPoint, tempEndPoint, control.isFixed,
1060
                                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1061
                                                                    }
1062
                                                                }
1063
                                                            }
1064
                                                            catch (Exception ex)
1065
                                                            {
1066
                                                                throw ex;
1067
                                                            }
1068

    
1069
                                                        }
1070
                                                        break;
1071
                                                    #endregion
1072
                                                    #region SignControl
1073
                                                    case "SignControl":
1074
                                                        using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1075
                                                        {
1076

    
1077
                                                            double Angle = control.Angle;
1078
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1079
                                                            Point TopRightPoint = GetPdfPointSystem(control.TR);
1080
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1081
                                                            Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1082
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1083
                                                            double Opacity = control.Opac;
1084
                                                            string UserNumber = control.UserNumber;
1085
                                                            Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1086
                                                        }
1087
                                                        break;
1088
                                                    #endregion
1089
                                                    #region MyRegion
1090
                                                    case "DateControl":
1091
                                                        using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1092
                                                        {
1093
                                                            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1094
                                                            string Text = control.Text;
1095
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1096
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1097
                                                            List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1098
                                                            System.Drawing.Color FontColor = _SetColor;
1099
                                                            double Angle = control.Angle;
1100
                                                            double Opacity = control.Opac;
1101
                                                            Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1102
                                                        }
1103
                                                        break;
1104
                                                    #endregion
1105
                                                    #region SymControlN (APPROVED)
1106
                                                    case "SymControlN":
1107
                                                        using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1108
                                                        {
1109
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1110
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1111
                                                            List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1112
                                                            System.Drawing.Color FontColor = _SetColor;
1113
                                                            double Angle = control.Angle;
1114
                                                            double Opacity = control.Opac;
1115

    
1116
                                                            var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
1117

    
1118
                                                            if (stamp.Count() > 0)
1119
                                                            {
1120
                                                                var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE);
1121

    
1122
                                                                var Contents = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP_CONTENTS");
1123

    
1124
                                                                if (Contents?.Count() > 0)
1125
                                                                {
1126
                                                                    foreach (var content in Contents)
1127
                                                                    {
1128
                                                                        xamldata = xamldata.Replace(content.PROPERTY, System.Security.SecurityElement.Escape(content.VALUE));
1129
                                                                    }
1130
                                                                }
1131

    
1132
                                                                Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata);
1133
                                                            }
1134

    
1135
                                                            string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1136

    
1137
                                                        }
1138
                                                        break;
1139
                                                    case "SymControl":
1140
                                                        using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1141
                                                        {
1142
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1143
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1144
                                                            List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1145
                                                            System.Drawing.Color FontColor = _SetColor;
1146
                                                            double Angle = control.Angle;
1147
                                                            double Opacity = control.Opac;
1148

    
1149
                                                            string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", "");
1150
                                                            Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1151
                                                        }
1152
                                                        break;
1153
                                                    #endregion
1154
                                                    #region Image
1155
                                                    case "ImgControl":
1156
                                                        using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1157
                                                        {
1158
                                                            double Angle = control.Angle;
1159
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1160
                                                            Point TopRightPoint = GetPdfPointSystem(control.TR);
1161
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1162
                                                            Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1163
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1164
                                                            double Opacity = control.Opac;
1165
                                                            string FilePath = control.ImagePath;
1166
                                                            //Uri uri = new Uri(s.ImagePath);
1167

    
1168
                                                            Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1169
                                                        }
1170
                                                        break;
1171
                                                    #endregion
1172
                                                    default:
1173
                                                        StatusChange($"{ControlT.Name} Not Support", 0);
1174
                                                        break;
1175
                                                }
1176

    
1177
                                            }
1178
                                            catch (Exception ex)
1179
                                            {
1180
                                                StatusChange($"markupItem : {ControlT.Name}" + ex.ToString(), 0);
1181
                                            }
1182
                                            finally
1183
                                            {
1184
                                                //if (ControlT?.Name != null)
1185
                                                //{
1186
                                                //    strLog.Append($"{ControlT.Name},");
1187
                                                //}
1188
                                            }
1189
                                        }
1190
                                    }
1191
                                }
1192

    
1193
                                if (StatusChanged != null)
1194
                                {
1195
                                    StatusChanged(this, new StatusChangedEventArgs { CurrentPage = lastPageNo, Message = "" });
1196
                                }
1197
                                //PdfFileSpecification pfs = PdfFileSpecification.FileEmbedded(pdfStamper.Writer, @"C:\Users\kts\Documents\업무\CARS\엑셀양식\F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", "F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", null);
1198
                                //pdfStamper.AddFileAttachment("F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", pfs);
1199

    
1200
                                pdfStamper.Outlines = root;
1201
                                pdfStamper.Close();
1202
                                pdfReader.Close();
1203
                            }
1204
                        }
1205
                    }
1206
                    #endregion
1207
                }
1208

    
1209
                if (tempFileInfo.Exists)
1210
                {
1211
#if !DEBUG
1212
                    tempFileInfo.Delete();
1213
#endif
1214
                }
1215

    
1216
                if (File.Exists(pdfFilePath))
1217
                {
1218
                    string destfilepath = null;
1219
                    try
1220
                    {
1221
                        FinalPDFPath = new FileInfo(pdfFilePath);
1222

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

    
1226
                        if(!string.IsNullOrEmpty(pdfmovepath))
1227
                        {
1228
                            _FinalPDFStorgeLocal = pdfmovepath;
1229
                        }
1230

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

    
1233
                        if (File.Exists(destfilepath))
1234
                            File.Delete(destfilepath);
1235

    
1236
                        File.Move(FinalPDFPath.FullName, destfilepath);
1237
                        FinalPDFPath = new FileInfo(destfilepath);
1238
                        File.Delete(pdfFilePath);
1239
                    }
1240
                    catch (Exception ex)
1241
                    {
1242
                        SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString());
1243
                    }
1244

    
1245
                    return true;
1246
                }
1247
            }
1248
            catch (Exception ex)
1249
            {
1250
                SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString());
1251
            }
1252
            return false;
1253
        }
1254

    
1255
        /// <summary>
1256
        /// kcom의 화살표방향과 틀려 추가함
1257
        /// </summary>
1258
        /// <param name="PageAngle"></param>
1259
        /// <param name="endP"></param>
1260
        /// <param name="ps">box Points</param>
1261
        /// <param name="IsFixed"></param>
1262
        /// <returns></returns>
1263
        private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed)
1264
        {
1265
            Point testP = endP;
1266

    
1267
            try
1268
            {
1269
                switch (Math.Abs(PageAngle).ToString())
1270
                {
1271
                    case "90":
1272
                        testP = new Point(endP.X + 50, endP.Y);
1273
                        break;
1274
                    case "270":
1275
                        testP = new Point(endP.X - 50, endP.Y);
1276
                        break;
1277
                }
1278

    
1279
                //20180910 LJY 각도에 따라.
1280
                switch (Math.Abs(PageAngle).ToString())
1281
                {
1282
                    case "90":
1283
                        if (IsFixed)
1284
                        {
1285
                            if (ps[0] == endP) //상단
1286
                            {
1287
                                testP = new Point(endP.X, endP.Y + 50);
1288
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1289
                            }
1290
                            else if (ps[1] == endP) //하단
1291
                            {
1292
                                testP = new Point(endP.X, endP.Y - 50);
1293
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1294
                            }
1295
                            else if (ps[2] == endP) //좌단
1296
                            {
1297
                                testP = new Point(endP.X - 50, endP.Y);
1298
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1299
                            }
1300
                            else if (ps[3] == endP) //우단
1301
                            {
1302
                                testP = new Point(endP.X + 50, endP.Y);
1303
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1304
                            }
1305
                        }
1306
                        break;
1307
                    case "270":
1308
                        if (IsFixed)
1309
                        {
1310
                            if (ps[0] == endP) //상단
1311
                            {
1312
                                testP = new Point(endP.X, endP.Y - 50);
1313
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1314
                            }
1315
                            else if (ps[1] == endP) //하단
1316
                            {
1317
                                testP = new Point(endP.X, endP.Y + 50);
1318
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1319
                            }
1320
                            else if (ps[2] == endP) //좌단
1321
                            {
1322
                                testP = new Point(endP.X + 50, endP.Y);
1323
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1324
                            }
1325
                            else if (ps[3] == endP) //우단
1326
                            {
1327
                                testP = new Point(endP.X - 50, endP.Y);
1328
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1329
                            }
1330
                        }
1331
                        break;
1332
                    default:
1333
                        if (IsFixed)
1334
                        {
1335

    
1336
                            if (ps[0] == endP) //상단
1337
                            {
1338
                                testP = new Point(endP.X, endP.Y - 50);
1339
                                //System.Diagnostics.Debug.WriteLine("상단");
1340
                            }
1341
                            else if (ps[1] == endP) //하단
1342
                            {
1343
                                testP = new Point(endP.X, endP.Y + 50);
1344
                                //System.Diagnostics.Debug.WriteLine("하단");
1345
                            }
1346
                            else if (ps[2] == endP) //좌단
1347
                            {
1348
                                testP = new Point(endP.X - 50, endP.Y);
1349
                                //System.Diagnostics.Debug.WriteLine("좌단");
1350
                            }
1351
                            else if (ps[3] == endP) //우단
1352
                            {
1353
                                testP = new Point(endP.X + 50, endP.Y);
1354
                                //System.Diagnostics.Debug.WriteLine("우단");
1355
                            }
1356
                        }
1357
                        break;
1358
                }
1359

    
1360
            }
1361
            catch (Exception)
1362
            {
1363
            }
1364

    
1365
            return testP;
1366
        }
1367

    
1368
        private Point Test(Rect rect,Point point)
1369
        {
1370
            Point result = new Point();
1371

    
1372
            Point newPoint = new Point();
1373

    
1374
            double oldNear = 0;
1375
            double newNear = 0;
1376

    
1377
            oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result);
1378

    
1379
            newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint);
1380

    
1381
            if (newNear < oldNear)
1382
            {
1383
                oldNear = newNear;
1384
                result = newPoint;
1385
            }
1386

    
1387
            newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint);
1388

    
1389
            if (newNear < oldNear)
1390
            {
1391
                oldNear = newNear;
1392
                result = newPoint;
1393
            }
1394

    
1395

    
1396
            newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint);
1397

    
1398
            if (newNear < oldNear)
1399
            {
1400
                oldNear = newNear;
1401
                result = newPoint;
1402
            }
1403

    
1404
            return result;
1405
        }
1406

    
1407
        private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor)
1408
        {
1409
            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1410
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1411
            Point MidPoint = GetPdfPointSystem(control.MidPoint);
1412
            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1413
            DoubleCollection DashSize = control.DashSize;
1414
            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1415
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
1416

    
1417
            double Opacity = control.Opac;
1418

    
1419
            if (EndPoint == MidPoint)
1420
            {
1421
                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1422
            }
1423
            else
1424
            {
1425
                Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity);
1426
            }
1427

    
1428
            Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity);
1429

    
1430
        }
1431

    
1432
        private void DrawLine(S_LineControl control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor)
1433
        {
1434
            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1435
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1436
            Point EndPoint = GetPdfPointSystem(control.EndPoint);
1437
            DoubleCollection DashSize = control.DashSize;
1438
            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1439

    
1440
            var Opacity = control.Opac;
1441
            string UserID = control.UserID;
1442
            double Interval = control.Interval;
1443
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
1444
            Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, setColor, Opacity);
1445
            switch (control.LineStyleSet)
1446
            {
1447
                case LineStyleSet.ArrowLine:
1448
                    Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1449
                    break;
1450
                case LineStyleSet.CancelLine:
1451
                    {
1452
                        var x = Math.Abs((Math.Abs(control.StartPoint.X) - Math.Abs(control.EndPoint.X)));
1453
                        var y = Math.Abs((Math.Abs(control.StartPoint.Y) - Math.Abs(control.EndPoint.Y)));
1454

    
1455
                        Point newStartPoint = new Point();
1456
                        Point newEndPoint = new Point();
1457

    
1458
                        if (x > y)
1459
                        {
1460
                            newStartPoint = new Point(control.StartPoint.X, control.StartPoint.Y + control.Interval);
1461
                            newEndPoint = new Point(control.EndPoint.X, control.EndPoint.Y + control.Interval);
1462
                        }
1463
                        else
1464
                        {
1465
                            newStartPoint = new Point(control.StartPoint.X + control.Interval, control.StartPoint.Y);
1466
                            newEndPoint = new Point(control.EndPoint.X + control.Interval, control.EndPoint.Y);
1467
                        }
1468

    
1469
                        newStartPoint = GetPdfPointSystem(newStartPoint);
1470
                        newEndPoint = GetPdfPointSystem(newEndPoint);
1471

    
1472
                        Controls_PDF.DrawSet_Line.DrawLine(newStartPoint, newEndPoint, LineSize, contentByte, DashSize, setColor, Opacity);
1473
                    }
1474
                    break;
1475
                case LineStyleSet.TwinLine:
1476
                    {
1477
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1478
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1479
                    }
1480
                    break;
1481
                case LineStyleSet.DimLine:
1482
                    {
1483
                        Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1484
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1485
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1486
                    }
1487
                    break;
1488
                default:
1489
                    break;
1490
            }
1491

    
1492
        }
1493

    
1494
        private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,System.Drawing.Color setColor)
1495
        {
1496
            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1497
            string Text = control.Text;
1498

    
1499
            bool isUnderline = false;
1500
            control.BoxW -= scaleWidth;
1501
            control.BoxH -= scaleHeight;
1502
            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
1503
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1504
            Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
1505

    
1506
            List<Point> pointSet = new List<Point>();
1507
            pointSet.Add(StartPoint);
1508
            pointSet.Add(EndPoint);
1509
            
1510
            PaintSet paint = PaintSet.None;
1511
            switch (control.paintMethod)
1512
            {
1513
                case 1:
1514
                    {
1515
                        paint = PaintSet.Fill;
1516
                    }
1517
                    break;
1518
                case 2:
1519
                    {
1520
                        paint = PaintSet.Hatch;
1521
                    }
1522
                    break;
1523
                default:
1524
                    break;
1525
            }
1526
            if (control.isHighLight) paint |= PaintSet.Highlight;
1527

    
1528
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1529
            double TextSize = Convert.ToDouble(data2[1]);
1530
            System.Drawing.Color FontColor = setColor;
1531
            double Angle = control.Angle;
1532
            double Opacity = control.Opac;
1533
            FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]);
1534
            var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1535

    
1536
            FontStyle fontStyle = FontStyles.Normal;
1537
            if (FontStyles.Italic == TextStyle)
1538
            {
1539
                fontStyle = FontStyles.Italic;
1540
            }
1541

    
1542
            FontWeight fontWeight = FontWeights.Black;
1543

    
1544
            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1545
            //강인구 수정(2018.04.17)
1546
            if (FontWeights.Bold == TextWeight)
1547
            //if (FontWeights.ExtraBold == TextWeight)
1548
            {
1549
                fontWeight = FontWeights.Bold;
1550
            }
1551

    
1552
            TextDecorationCollection decoration = TextDecorations.Baseline;
1553
            if (control.fontConfig.Count() == 4)
1554
            {
1555
                decoration = TextDecorations.Underline;
1556
            }
1557

    
1558
            Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1559
        }
1560
    
1561

    
1562
        ~MarkupToPDF()
1563
        {
1564
            this.Dispose(false);
1565
        }
1566

    
1567
        private bool disposed;
1568

    
1569
        public void Dispose()
1570
        {
1571
            this.Dispose(true);
1572
            GC.SuppressFinalize(this);
1573
        }
1574

    
1575
        protected virtual void Dispose(bool disposing)
1576
        {
1577
            if (this.disposed) return;
1578
            if (disposing)
1579
            {
1580
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
1581
            }
1582
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
1583
            this.disposed = true;
1584
        }
1585

    
1586
#endregion
1587
    }
1588
}
클립보드 이미지 추가 (최대 크기: 500 MB)