프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 6a19b48d

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

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

    
21
namespace MarkupToPDF
22
{
23
    public class MarkupToPDF : IDisposable
24
    {
25
        public MarkupToPDF()
26
        {
27
        }
28

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

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

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

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

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

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

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

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

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

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

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

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

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

    
149
        #endregion
150

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

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

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

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

    
174
                throw;
175
            }
176

    
177
            return result;
178

    
179
        }
180

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

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

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

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

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

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

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

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

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

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

    
257
            return result;
258
        }
259

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

    
267

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

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

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

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

    
300

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

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

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

    
326
                }
327
            }
328
            catch (Exception ex)
329
            {
330
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
331
                return;
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
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
441
                {
442
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
443
                    //System.Diagnostics.Process process = new System.Diagnostics.Process();
444
                    //process.StartInfo.FileName = "cmd";
445
                    //process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
446
                    //process.Start();
447
                }
448
                else
449
                {
450
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
451
                }
452
            }
453
            #endregion
454

    
455
            try
456
            {
457

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

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

    
467
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
468

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

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

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

    
502
                PdfReader pdfReader = new PdfReader(tempFileInfo);
503

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
713
                                            pdfSize = cropBox;
714
                                        }
715

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
901
                                                            DoubleCollection DashSize = control.DashSize;
902

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

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

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

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

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

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

    
993
                                                            double Angle = control.Angle;
994

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

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

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

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

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

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

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

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

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

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

    
1074
                                                                FontWeight fontWeight = FontWeights.Black;
1075

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1261
                                    }
1262
                                }
1263

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1436
            return testP;
1437
        }
1438

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

    
1443
            Point newPoint = new Point();
1444

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

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

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

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

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

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

    
1466

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

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

    
1475
            return result;
1476
        }
1477

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

    
1488
            double Opacity = control.Opac;
1489

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

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

    
1501
        }
1502

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

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

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

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

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

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

    
1563
        }
1564

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

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

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

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

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

    
1613
            FontWeight fontWeight = FontWeights.Black;
1614

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

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

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

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

    
1638
        private bool disposed;
1639

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

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

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