프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 1305c420

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
146
        #endregion
147

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

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

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

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

    
171
                throw;
172
            }
173

    
174
            return result;
175

    
176
        }
177

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

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

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

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

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

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

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

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

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

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

    
254
            return result;
255
        }
256

    
257
        #region 생성자 & 소멸자
258
        public EndFinalResult MakeFinalPDF(object _FinalPDF)
259
        {
260
            EndFinalResult result = new EndFinalResult();
261

    
262
            DOCUMENT_ITEM documentItem;
263
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
264
            FinalItem = FinalPDF;
265

    
266

    
267
            string PdfFilePathRoot = null;
268
            string TestFile = System.IO.Path.GetTempFileName();
269

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

    
277
                    if (_properties.Count() > 0)
278
                    {
279
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0)
280
                        {
281
                            result.Error = " TileSourcePath Not Found.";
282
                        }
283
                        else
284
                        { 
285
                            PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
286
                        }
287

    
288
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).Count() == 0)
289
                        {
290
                            result.Error = " FinalPDFStorgeLocal Not Found.";
291
                        }
292
                        else
293
                        {
294
                            _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
295
                        }
296

    
297

    
298
                        if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).Count() == 0)
299
                        {
300
                            result.Error = " FinalPDFStorgeRemote Not Found.";
301
                        }
302
                        else
303
                        {
304
                            _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
305
                        }
306
                    }
307
                    else
308
                    {
309
                        result.Error = " Final PDF Properties Not Found.";
310
                    }
311

    
312
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
313

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

    
321
                }
322
            }
323
            catch (Exception ex)
324
            {
325
                result.Error = " 프로퍼티 에러." + ex.ToString();
326
            }
327

    
328
            if(result.Error != null)
329
            {
330
                return result;
331
            }
332

    
333
            #endregion
334

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

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

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

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

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

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

    
362
                            var markupInfoVerItems = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == MarkupInfoItem.ID).ToList();
363
                            
364
                            if (markupInfoVerItems.Count() > 0)
365
                            {
366
                                var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First();
367

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

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

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

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

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

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

    
455

    
456
            if (result.Error != null)
457
            {
458
                return result;
459
            }
460

    
461
            #endregion
462

    
463
            try
464
            {
465

    
466
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
467
                {
468
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
469

    
470
                    if (finalList.Count() > 0)
471
                    {
472
                        //TestFile = SetFlattingPDF(TestFile);
473
                        //StatusChange($"SetFlattingPDF : {TestFile}", 0);
474

    
475
                       if(SetStampInPDF(FinalItem, TestFile, MarkupInfoItem))
476
                        {
477
                            StatusChange($"finish : {TestFile}", 0);
478
                        }
479
                        else
480
                        {
481
                            StatusChange($"stamp Error", 0);
482
                        }
483

    
484
                    }
485
                }
486

    
487
                result.FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name;
488
                result.OriginPDFName = OriginFileName;
489
                result.FinalPDFPath = FinalPDFPath.FullName;
490
                result.Error = "";
491
                result.Message = "";
492
            }
493
            catch (Exception ex)
494
            {
495
                SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message);
496
            }
497

    
498
            return result;
499
        }
500
        #endregion
501

    
502
        #region PDF
503
        public static float scaleWidth = 0;
504
        public static float scaleHeight = 0;
505

    
506
        private string SetFlattingPDF(string tempFileInfo)
507
        {
508
            if (File.Exists(tempFileInfo))
509
            {
510
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
511

    
512
                PdfReader pdfReader = new PdfReader(tempFileInfo);
513

    
514
                for (int i = 1; i <= pdfReader.NumberOfPages; i++)
515
                {
516
                    var mediaBox = pdfReader.GetPageSize(i);
517
                    var cropbox = pdfReader.GetCropBox(i);
518

    
519
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
520
                    //{
521
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
522
                    //}
523
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
524

    
525
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
526
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
527
                    //scaleWidth = 2.0832634F;
528
                    //scaleHeight = 3.0F;
529

    
530
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
531
                    //강인구 수정
532
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
533
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
534
                    //{
535
                    //    var pageDict = pdfReader.GetPageN(i);
536
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
537
                    //}
538
                }
539

    
540
                var memStream = new MemoryStream();
541
                var stamper = new PdfStamper(pdfReader, memStream)
542
                {
543
                    FormFlattening = true,                     
544
                    //FreeTextFlattening = true,
545
                    //AnnotationFlattening = true,                     
546
                };
547
                
548
                stamper.Close();
549
                pdfReader.Close();
550
                var array = memStream.ToArray();
551
                File.Delete(tempFileInfo);
552
                File.WriteAllBytes(TestFile.FullName, array);
553

    
554
                return TestFile.FullName;
555
            }
556
            else
557
            {
558
                return tempFileInfo;
559
            }
560
        }
561

    
562
        public void flattenPdfFile(string src, ref string dest)
563
        {
564
            PdfReader reader = new PdfReader(src);
565
            var memStream = new MemoryStream();
566
            var stamper = new PdfStamper(reader, memStream)
567
            {
568
                FormFlattening = true,
569
                FreeTextFlattening = true,
570
                AnnotationFlattening = true,
571
            };
572

    
573
            stamper.Close();
574
            var array = memStream.ToArray();
575
            File.WriteAllBytes(dest, array);
576
        }
577

    
578
        public void StatusChange(string message,int CurrentPage)
579
        {
580
            if(StatusChanged != null)
581
            {
582
                //var sb = new StringBuilder();
583
                //sb.AppendLine(message);
584

    
585
                StatusChanged(this, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = message });
586
            }
587
        }
588

    
589
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
590
        {
591
            try
592
            {
593
        
594
                FileInfo tempFileInfo = new FileInfo(testFile);
595

    
596
                if (!Directory.Exists(_FinalPDFStorgeLocal))
597
                {
598
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
599
                }
600
                string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
601
          
602

    
603
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
604
                {
605
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
606

    
607
                    #region 코멘트 적용 + 커버시트
608
                    using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
609
                    {
610
                        StatusChange("comment Cover",0);
611
                        
612
                        PdfReader pdfReader = new PdfReader(pdfStream);
613
                        //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
614
                        Dictionary<string, object> bookmark;
615
                        List<Dictionary<string, object>> outlines;
616

    
617
                        outlines = new List<Dictionary<string, object>>();
618
                        List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
619

    
620
                        var dic = new Dictionary<string, object>();
621

    
622
                        foreach (var data in MarkupDataSet)
623
                        {
624
                            //StatusChange("MarkupDataSet", 0);
625

    
626
                            string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
627

    
628
                            string username = "";
629
                            string userdept = "";
630

    
631
                            using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
632
                            {
633
                                var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid);
634

    
635
                                if(memberlist.Count() > 0)
636
                                {
637
                                    username = memberlist.First().NAME;
638
                                    userdept = memberlist.First().DEPARTMENT;
639
                                }
640
                            }
641

    
642
                            bookmark = new Dictionary<string, object>();
643
                            bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
644
                            bookmark.Add("Page", data.PAGENUMBER + " Fit");
645
                            bookmark.Add("Action", "GoTo");
646
                            bookmark.Add("Kids", outlines);
647
                            root.Add(bookmark);
648
                        }
649

    
650

    
651
                        using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
652
                        {
653
                            AcroFields pdfFormFields = pdfStamper.AcroFields;
654

    
655
                            try
656
                            {
657
                                if (pdfFormFields.GenerateAppearances != true)
658
                                {
659
                                    pdfFormFields.GenerateAppearances = true;
660
                                }
661
                            }
662
                            catch (Exception ex)
663
                            {
664
                                SetNotice(FinalItem.ID, "this pdf is not AcroForm.");
665
                            }
666

    
667
                            var _SetColor = new SolidColorBrush(Colors.Red);
668

    
669
                            string[] delimiterChars = { "|DZ|" };
670
                            string[] delimiterChars2 = { "|" };
671

    
672
                            //pdfStamper.FormFlattening = true; //이미 선처리 작업함
673
                            pdfStamper.SetFullCompression();
674
                            _SetColor = new SolidColorBrush(Colors.Red);
675

    
676
                            StringBuilder strLog = new StringBuilder();
677
                            int lastPageNo = 0;
678

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

    
681
                            foreach (var markupItem in MarkupDataSet)
682
                            {
683
                                /// 2020.11.13 김태성
684
                                /// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함.
685
                                var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER);
686

    
687
                                if(pageitems.Count() > 0)
688
                                {
689
                                    var currentPage = pageitems.First();
690
                                    pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
691
                                    lastPageNo = markupItem.PAGENUMBER;
692
                                    //try
693
                                    //{
694

    
695
                                    //}
696
                                    //catch (Exception ex)
697
                                    //{
698
                                    //    SetNotice(finaldata.ID, $"GetPageSizeWithRotation Error PageNO : {markupItem.PAGENUMBER} " + ex.ToString());
699
                                    //}
700
                                    //finally
701
                                    //{
702
                                    //    pdfSize = new iTextSharp.text.Rectangle(0, 0, float.Parse(currentPage.PAGE_WIDTH), float.Parse(currentPage.PAGE_HEIGHT));
703
                                    //}
704

    
705
                                    mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
706
                                    var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
707

    
708
                                    /// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다
709
                                    if (cropBox != null &&
710
                                        (cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom))
711
                                    {
712
                                        PdfDictionary dict = pdfReader.GetPageN(markupItem.PAGENUMBER);
713

    
714
                                        PdfArray oNewMediaBox = new PdfArray();
715
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Left));
716
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Top));
717
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Right));
718
                                        oNewMediaBox.Add(new PdfNumber(cropBox.Bottom));
719
                                        dict.Put(PdfName.MEDIABOX, oNewMediaBox);
720

    
721
                                        pdfSize = cropBox;
722
                                    }
723

    
724
                                    scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
725
                                    scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
726

    
727
                                    pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
728
                                    _entity.SaveChanges();
729

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

    
732
                                    PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
733
                                    strLog.Append($"{markupItem.PAGENUMBER}/");
734

    
735
                                    foreach (var data in markedData)
736
                                    {
737
                                        var item = JsonSerializerHelper.UnCompressString(data);
738
                                        var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
739

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

    
776
                                                        Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
777
                                                    }
778
                                                    break;
779
                                                #endregion
780
                                                #region ArcControl or ArrowArcControl
781
                                                case "ArcControl":
782
                                                case "ArrowArcControl":
783
                                                    {
784
                                                        using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
785
                                                        {
786
                                                            string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
787
                                                            Point StartPoint = GetPdfPointSystem(control.StartPoint);
788
                                                            Point EndPoint = GetPdfPointSystem(control.EndPoint);
789
                                                            Point MidPoint = GetPdfPointSystem(control.MidPoint);
790
                                                            DoubleCollection DashSize = control.DashSize;
791
                                                            List<Point> PointSet = GetPdfPointSystem(control.PointSet);
792

    
793
                                                            var Opacity = control.Opac;
794
                                                            string UserID = control.UserID;
795
                                                            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
796
                                                            bool IsTransOn = control.IsTransOn;
797

    
798
                                                            if (control.IsTransOn)
799
                                                            {
800
                                                                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
801
                                                                Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
802
                                                            }
803
                                                            else
804
                                                            {
805
                                                                Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
806
                                                            }
807

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

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

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

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

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

    
879
                                                        var PaintStyle = control.PaintState;
880
                                                        double Opacity = control.Opac;
881
                                                        DoubleCollection DashSize = control.DashSize;
882

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

    
886
                                                        double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
887
                                                        bool reverse = (area < 0);
888
                                                        if (PaintStyle == PaintSet.None)
889
                                                        {
890
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
891
                                                        }
892
                                                        else
893
                                                        {
894
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
895
                                                        }
896
                                                    }
897
                                                    break;
898
                                                #endregion
899
                                                #region CloudControl
900
                                                case "CloudControl":
901
                                                    using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
902
                                                    {
903
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
904
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
905
                                                        double Toler = control.Toler;
906
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
907
                                                        double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
908
                                                        var PaintStyle = control.PaintState;
909
                                                        double Opacity = control.Opac;
910
                                                        bool isTransOn = control.IsTrans;
911
                                                        bool isChain = control.IsChain;
912

    
913
                                                        DoubleCollection DashSize = control.DashSize;
914

    
915
                                                        if (isChain)
916
                                                        {
917
                                                            Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
918
                                                        }
919
                                                        else
920
                                                        {
921
                                                            if (isTransOn)
922
                                                            {
923
                                                                double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
924
                                                                bool reverse = (area < 0);
925

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

    
974
                                                        //    DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
975
                                                        //}
976

    
977
                                                        //using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
978
                                                        //{
979
                                                        //    linecontrol.Angle = control.Angle;
980
                                                        //    linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 });
981
                                                        //    linecontrol.EndPoint = control.EndPoint;
982
                                                        //    linecontrol.MidPoint = control.MidPoint;
983
                                                        //    linecontrol.Name = "ArrowControl_Multi";
984
                                                        //    linecontrol.Opac = control.Opac;
985
                                                        //    linecontrol.PointSet = control.PointSet;
986
                                                        //    linecontrol.SizeSet = control.SizeSet;
987
                                                        //    linecontrol.StartPoint = control.StartPoint;
988
                                                        //    linecontrol.StrokeColor = control.StrokeColor;
989
                                                        //    linecontrol.TransformPoint = control.TransformPoint;
990

    
991
                                                        //    DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor);
992
                                                        //}
993
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
994
                                                        Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
995
                                                        Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
996
                                                        Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
997
                                                        bool isUnderLine = false;
998
                                                        string Text = "";
999
                                                        double fontsize = 30;
1000

    
1001
                                                        System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
1002
                                                        Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
1003
                                                        List<Point> tempPoint = new List<Point>();
1004

    
1005
                                                        double Angle = control.Angle;
1006

    
1007
                                                        if (Math.Abs(Angle).ToString() == "90")
1008
                                                        {
1009
                                                            Angle = 270;
1010
                                                        }
1011
                                                        else if (Math.Abs(Angle).ToString() == "270")
1012
                                                        {
1013
                                                            Angle = 90;
1014
                                                        }
1015

    
1016
                                                        var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
1017
                                                        tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
1018
                                                        tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
1019
                                                        tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
1020
                                                        tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
1021

    
1022
                                                        var newStartPoint = tempStartPoint;
1023
                                                        var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
1024
                                                        var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
1025

    
1026
                                                        //Point testPoint = tempEndPoint;
1027
                                                        //if (Angle != 0)
1028
                                                        //{
1029
                                                        //    testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed);
1030
                                                        //   //testPoint = Test(rect, newMidPoint);
1031
                                                        //}
1032

    
1033
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1034
                                                        SolidColorBrush FontColor = _SetColor;
1035
                                                        bool isHighlight = control.isHighLight;
1036
                                                        double Opacity = control.Opac;
1037
                                                        PaintSet Paint = PaintSet.None;
1038

    
1039
                                                        switch (control.ArrowStyle)
1040
                                                        {
1041
                                                            case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
1042
                                                                {
1043
                                                                    Paint = PaintSet.None;
1044
                                                                }
1045
                                                                break;
1046
                                                            case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
1047
                                                                {
1048
                                                                    Paint = PaintSet.Hatch;
1049
                                                                }
1050
                                                                break;
1051
                                                            case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
1052
                                                                {
1053
                                                                    Paint = PaintSet.Fill;
1054
                                                                }
1055
                                                                break;
1056
                                                            default:
1057
                                                                break;
1058
                                                        }
1059
                                                        if (control.isHighLight) Paint |= PaintSet.Highlight;
1060

    
1061
                                                        if (Paint == PaintSet.Hatch)
1062
                                                        {
1063
                                                            Text = control.ArrowText;
1064
                                                        }
1065
                                                        else
1066
                                                        {
1067
                                                            Text = control.ArrowText;
1068
                                                        }
1069

    
1070
                                                        try
1071
                                                        {
1072
                                                            if (control.fontConfig.Count == 4)
1073
                                                            {
1074
                                                                fontsize = Convert.ToDouble(control.fontConfig[3]);
1075
                                                            }
1076

    
1077
                                                            //강인구 수정(2018.04.17)
1078
                                                            var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1079

    
1080
                                                            FontStyle fontStyle = FontStyles.Normal;
1081
                                                            if (FontStyles.Italic == TextStyle)
1082
                                                            {
1083
                                                                fontStyle = FontStyles.Italic;
1084
                                                            }
1085

    
1086
                                                            FontWeight fontWeight = FontWeights.Black;
1087

    
1088
                                                            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1089
                                                            if (FontWeights.Bold == TextWeight)
1090
                                                            {
1091
                                                                fontWeight = FontWeights.Bold;
1092
                                                            }
1093

    
1094
                                                            TextDecorationCollection decoration = TextDecorations.Baseline;
1095
                                                            if (control.fontConfig.Count() == 5)
1096
                                                            {
1097
                                                                decoration = TextDecorations.Underline;
1098
                                                            }
1099

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

    
1151
                                                    }
1152
                                                    break;
1153
                                                #endregion
1154
                                                #region SignControl
1155
                                                case "SignControl":
1156
                                                    using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1157
                                                    {
1158

    
1159
                                                        double Angle = control.Angle;
1160
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1161
                                                        Point TopRightPoint = GetPdfPointSystem(control.TR);
1162
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1163
                                                        Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1164
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1165
                                                        double Opacity = control.Opac;
1166
                                                        string UserNumber = control.UserNumber;
1167
                                                        Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1168
                                                    }
1169
                                                    break;
1170
                                                #endregion
1171
                                                #region MyRegion
1172
                                                case "DateControl":
1173
                                                    using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1174
                                                    {
1175
                                                        string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1176
                                                        string Text = control.Text;
1177
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1178
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1179
                                                        List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1180
                                                        SolidColorBrush FontColor = _SetColor;
1181
                                                        double Angle = control.Angle;
1182
                                                        double Opacity = control.Opac;
1183
                                                        Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1184
                                                    }
1185
                                                    break;
1186
                                                #endregion
1187
                                                #region SymControlN (APPROVED)
1188
                                                case "SymControlN":
1189
                                                    using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1190
                                                    {
1191
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
1192
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
1193
                                                        List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1194
                                                        SolidColorBrush FontColor = _SetColor;
1195
                                                        double Angle = control.Angle;
1196
                                                        double Opacity = control.Opac;
1197

    
1198
                                                        var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP");
1199

    
1200
                                                        if (stamp.Count() > 0)
1201
                                                        {
1202
                                                            var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE);
1203

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

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

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

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

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

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

    
1263
                                }
1264
                            }
1265

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1437
            return testP;
1438
        }
1439

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

    
1444
            Point newPoint = new Point();
1445

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

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

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

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

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

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

    
1467

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

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

    
1476
            return result;
1477
        }
1478

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

    
1489
            double Opacity = control.Opac;
1490

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

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

    
1502
        }
1503

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

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

    
1527
                        if (x > y)
1528
                        {
1529
                            StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
1530
                            EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
1531
                            Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, setColor, Opacity);
1532
                        }
1533
                    }
1534
                    break;
1535
                case LineStyleSet.TwinLine:
1536
                    {
1537
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1538
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1539
                    }
1540
                    break;
1541
                case LineStyleSet.DimLine:
1542
                    {
1543
                        Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1544
                        Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity);
1545
                        Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity);
1546
                    }
1547
                    break;
1548
                default:
1549
                    break;
1550
            }
1551

    
1552
        }
1553

    
1554
        private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,SolidColorBrush setColor)
1555
        {
1556
            string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1557
            string Text = control.Text;
1558

    
1559
            bool isUnderline = false;
1560
            control.BoxW -= scaleWidth;
1561
            control.BoxH -= scaleHeight;
1562
            System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
1563
            Point StartPoint = GetPdfPointSystem(control.StartPoint);
1564
            Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
1565

    
1566
            List<Point> pointSet = new List<Point>();
1567
            pointSet.Add(StartPoint);
1568
            pointSet.Add(EndPoint);
1569

    
1570
            PaintSet paint = PaintSet.None;
1571
            switch (control.paintMethod)
1572
            {
1573
                case 1:
1574
                    {
1575
                        paint = PaintSet.Fill;
1576
                    }
1577
                    break;
1578
                case 2:
1579
                    {
1580
                        paint = PaintSet.Hatch;
1581
                    }
1582
                    break;
1583
                default:
1584
                    break;
1585
            }
1586
            if (control.isHighLight) paint |= PaintSet.Highlight;
1587

    
1588
            double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
1589
            double TextSize = Convert.ToDouble(data2[1]);
1590
            SolidColorBrush FontColor = setColor;
1591
            double Angle = control.Angle;
1592
            double Opacity = control.Opac;
1593
            FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]);
1594
            var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
1595

    
1596
            FontStyle fontStyle = FontStyles.Normal;
1597
            if (FontStyles.Italic == TextStyle)
1598
            {
1599
                fontStyle = FontStyles.Italic;
1600
            }
1601

    
1602
            FontWeight fontWeight = FontWeights.Black;
1603

    
1604
            var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
1605
            //강인구 수정(2018.04.17)
1606
            if (FontWeights.Bold == TextWeight)
1607
            //if (FontWeights.ExtraBold == TextWeight)
1608
            {
1609
                fontWeight = FontWeights.Bold;
1610
            }
1611

    
1612
            TextDecorationCollection decoration = TextDecorations.Baseline;
1613
            if (control.fontConfig.Count() == 4)
1614
            {
1615
                decoration = TextDecorations.Underline;
1616
            }
1617

    
1618
            Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
1619
        }
1620
    
1621

    
1622
        ~MarkupToPDF()
1623
        {
1624
            this.Dispose(false);
1625
        }
1626

    
1627
        private bool disposed;
1628

    
1629
        public void Dispose()
1630
        {
1631
            this.Dispose(true);
1632
            GC.SuppressFinalize(this);
1633
        }
1634

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

    
1646
#endregion
1647
    }
1648
}
클립보드 이미지 추가 (최대 크기: 500 MB)