프로젝트

일반

사용자정보

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

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

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

1
using IFinalPDF;
2
using iTextSharp.text.pdf;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
5
using MarkupToPDF.Common;
6
using MarkupToPDF.Controls.Common;
7
using MarkupToPDF.Serialize.Core;
8
using MarkupToPDF.Serialize.S_Control;
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
        #region 초기 데이터
26
        private static iTextSharp.text.Rectangle mediaBox;
27
        private FileInfo PdfFilePath = null;
28
        private FileInfo FinalPDFPath = null;
29
        private string _FinalPDFStorgeLocal = null;
30
        private string _FinalPDFStorgeRemote = null;
31
        private string OriginFileName = null;
32
        public FINAL_PDF FinalItem;
33
        public CommonLib.MARKUS_API.DOCINFO DocInfoItem = null;
34
        public List<CommonLib.MARKUS_API.DOCPAGE> DocPageItem = null;
35
        public CommonLib.MARKUS_API.MARKUP_INFO MarkupInfoItem = null;
36
        public List<CommonLib.MARKUS_API.MARKUP_DATA> MarkupDataSet = null;
37
        //private string _PrintPDFStorgeLocal = null;
38
        //private string _PrintPDFStorgeRemote = null;
39
        public event EventHandler<MakeFinalErrorArgs> FinalMakeError;
40
        public event EventHandler<EndFinalEventArgs> EndFinal;
41

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

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

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

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

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

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

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

    
102
        public Point GetPdfPointSystem(Point point)
103
        {
104
            point = new Point(point.X + pdfSize.Left * scaleWidth, point.Y - pdfSize.Bottom * scaleHeight);
105
            return new Point((float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight));
106
        }
107

    
108
        public double GetPdfSize(double size)
109
        {
110
            return (size / scaleWidth);
111
        }
112

    
113
        public List<Point> GetPdfPointSystem(List<Point> point) 
114
        {
115
            List<Point> dummy = new List<Point>();
116
            foreach (var item in point)
117
            {
118
                dummy.Add(GetPdfPointSystem(item));
119
            }
120
            return dummy;
121
        }
122

    
123
        public double returnAngle(Point start, Point end)
124
        {
125
            double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y);
126
            //angle *= -1;
127

    
128
            angle += 90;
129
            //if (angle < 0)
130
            //{
131
            //    angle = angle + 360;
132
            //}
133
            return angle;
134
        }
135

    
136
        #endregion
137

    
138
        #region 생성자 & 소멸자
139
        public void MakeFinalPDF(object _FinalPDF)
140
        {
141
            
142
            CommonLib.MARKUS_API.DOCUMENT_ITEM documentItem;
143
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
144
            FinalItem = FinalPDF;
145

    
146

    
147
            string PdfFilePathRoot = null;
148
            string TestFile = System.IO.Path.GetTempFileName();
149

    
150
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
151
            try
152
            {
153
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
154
                {
155
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
156

    
157
                    if (_properties.Count () > 0)
158
                    {
159
                        PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
160
                        _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
161
                        _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
162
                    }
163
                    else
164
                    {
165
                        SetNotice(FinalPDF.ID, "프로퍼티를 가지고 올 수 없습니다.");
166
                        return;
167
                    }
168

    
169
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
170

    
171
                    if (finalList.Count() > 0)
172
                    {
173
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
174
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
175
                        _entity.SaveChanges(); 
176
                    }
177
                }
178
            }
179
            catch (Exception ex)
180
            {
181
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
182
                return;
183
            }
184
            #endregion
185

    
186
            #region 문서 복사
187
            try
188
            {
189
                using (DataController dc = new DataController())
190
                {
191
                    //var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
192
                    string project_no = FinalPDF.PROJECT_NO;
193
                    string docinfo_id = FinalPDF.DOCINFO_ID;
194

    
195
                    var _DOCINFO = dc.GetDocInfo(project_no, docinfo_id);
196
                    if (_DOCINFO != null)
197
                    {
198
                        DocInfoItem = _DOCINFO;
199
                        DocPageItem = dc.GetDocpage(project_no, docinfo_id);
200

    
201
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
202
                                         + (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString()
203
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
204

    
205
                        MarkupInfoItem = dc.GetMarkupInfo(project_no, docinfo_id);                            
206

    
207
                        if (MarkupInfoItem == null)
208
                        {
209
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
210
                        }
211
                        else
212
                        {
213
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count() > 0)
214
                            {
215
                                MarkupDataSet = dc.GetMarkupData(project_no, docinfo_id);
216
                            }
217
                            else
218
                            {
219
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
220
                            }
221
                        }
222
                        documentItem = dc.GetDocumentItem(project_no, DocInfoItem.DOCUMENT_ID);
223
                        if (documentItem == null)
224
                        {
225
                            throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
226
                        }
227
                        var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 
228

    
229
                        #region 파일 체크
230
                        if (_files.Count() == 1)
231
                        {
232
                            if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()))
233
                            {
234
                                OriginFileName = _files.First().Name;
235
                                PdfFilePath = _files.First().CopyTo(TestFile, true);
236
                            }
237
                            else
238
                            {
239
                                throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower());
240
                            }
241
                        }
242
                        else if (_files.Count() > 1)
243
                        {
244
                            var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault();
245

    
246
                            if (originalFile == null)
247
                            {
248
                                throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
249
                            }
250
                            else
251
                            {
252
                                OriginFileName = originalFile.Name;
253
                                PdfFilePath = originalFile.CopyTo(TestFile, true);
254
                            }
255
                        }
256
                        else
257
                        {
258
                            throw new Exception("PDF를 찾지 못하였습니다");
259
                        }
260
                        #endregion
261

    
262
                        #region 예외처리
263
                        if (PdfFilePath == null)
264
                        {
265
                            throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
266
                        }
267
                        if (!PdfFilePath.Exists)
268
                        {
269
                            throw new Exception("PDF원본이 존재하지 않습니다");
270
                        }
271
                        #endregion
272
                    }
273
                    else
274
                    {
275
                        throw new Exception("일치하는 DocInfo가 없습니다");
276
                    }
277
                }
278
                    
279
                
280
            }
281
            catch (Exception ex)
282
            {
283
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
284
                {
285
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
286
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
287
                    process.StartInfo.FileName = "cmd";
288
                    process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
289
                    process.Start();
290
                }
291
                else
292
                {
293
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
294
                }
295
            }
296
            #endregion
297

    
298
            try
299
            {
300

    
301
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
302
                {
303
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
304

    
305
                    if (finalList.Count() > 0)
306
                    {
307
                        TestFile = SetFlattingPDF(TestFile);
308
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.Insert;
309
                        //_entity.SaveChanges();
310

    
311
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
312
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.PdfStamp;
313
                        //_entity.SaveChanges();
314
                    }
315
                }
316
                    if (EndFinal != null)
317
                    {
318
                        EndFinal(this, new EndFinalEventArgs
319
                        {
320
                            OriginPDFName = OriginFileName,
321
                            FinalPDFPath = FinalPDFPath.FullName,
322
                            Error = "",
323
                            Message = "",
324
                            FinalPDF = FinalPDF,
325
                        });
326
                    }
327
            }
328
            catch (Exception ex)
329
            {
330

    
331
                throw;
332
            }
333
        }
334
        #endregion
335

    
336
        #region PDF
337
        float scaleWidth = 0;
338
        float scaleHeight = 0;
339

    
340
         
341
        private string SetFlattingPDF(string tempFileInfo)
342
        {
343
            if (File.Exists(tempFileInfo))
344
            {
345
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
346

    
347
                PdfReader pdfReader = new PdfReader(tempFileInfo);
348
                for (int i = 1; i < pdfReader.NumberOfPages; i++)
349
                {
350
                    var mediaBox = pdfReader.GetPageSize(i);
351
                    var cropbox = pdfReader.GetCropBox(i);
352

    
353
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
354
                    //{
355
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
356
                    //}
357
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
358

    
359
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
360
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
361
                    //scaleWidth = 2.0832634F;
362
                    //scaleHeight = 3.0F;
363

    
364
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
365
                    //강인구 수정
366
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
367
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
368
                    //{
369
                    //    var pageDict = pdfReader.GetPageN(i);
370
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
371
                    //}
372
                }
373

    
374
                var memStream = new MemoryStream();
375
                var stamper = new PdfStamper(pdfReader, memStream)
376
                {
377
                    FormFlattening = true,
378
                    FreeTextFlattening = true,
379
                    AnnotationFlattening = true,
380
                };
381

    
382
                stamper.Close();
383
                pdfReader.Close();
384
                var array = memStream.ToArray();
385
                File.Delete(tempFileInfo);
386
                File.WriteAllBytes(TestFile.FullName, array);
387

    
388
                return TestFile.FullName;
389
            }
390
            else
391
            {
392
                return tempFileInfo;
393
            }
394
        }
395

    
396
        public void flattenPdfFile(string src, ref string dest)
397
        {
398
            PdfReader reader = new PdfReader(src);
399
            var memStream = new MemoryStream();
400
            var stamper = new PdfStamper(reader, memStream)
401
            {
402
                FormFlattening = true,
403
                FreeTextFlattening = true,
404
                AnnotationFlattening = true,
405
            };
406

    
407
            stamper.Close();
408
            var array = memStream.ToArray();
409
            File.WriteAllBytes(dest, array);
410
        }
411
        
412
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, CommonLib.MARKUS_API.MARKUP_INFO markupInfo)
413
        {
414
            string pdfFilePath = null;
415
            
416
            FileInfo tempFileInfo = new FileInfo(testFile);
417

    
418
            if (!Directory.Exists(_FinalPDFStorgeLocal))
419
            {
420
                Directory.CreateDirectory(_FinalPDFStorgeLocal);
421
            }
422
            pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name;
423
            
424
            using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
425
            {
426
                FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
427

    
428
                #region 코멘트 적용 + 커버시트
429
                using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
430
                {
431
                    PdfReader pdfReader = new PdfReader(pdfStream);
432
                    //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
433
                    Dictionary<string, object> bookmark;
434
                    List<Dictionary<string, object>> outlines;
435
                    outlines = new List<Dictionary<string, object>>();
436
                    List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
437

    
438
                    var dic = new Dictionary<string, object>();
439
                    foreach (var data in MarkupDataSet)
440
                    {
441
                        
442
                        string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
443
                        string username = string.Empty;
444
                        string userdept = string.Empty;
445
                        using (DataController dataController = new DataController())
446
                        {
447
                            var member = dataController.GetMemberInfo(markupInfo.DOCINFO.PROJECT_NO, userid);
448
                            username = member.NAME;
449
                            userdept = member.DEPARTMENT;
450
                        }                        
451
                        
452
                        bookmark = new Dictionary<string, object>();
453
                        bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
454
                        bookmark.Add("Page", data.PAGENUMBER + " Fit");
455
                        bookmark.Add("Action", "GoTo");
456
                        bookmark.Add("Kids", outlines);
457
                        root.Add(bookmark);
458
                    }
459

    
460

    
461
                    using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
462
                    {
463
                        var _SetColor = new SolidColorBrush(Colors.Red);
464
                        
465
                        string[] delimiterChars = { "|DZ|" };
466
                        string[] delimiterChars2 = { "|" };
467

    
468
                        //pdfStamper.FormFlattening = true; //이미 선처리 작업함
469
                        pdfStamper.SetFullCompression();
470
                        _SetColor = new SolidColorBrush(Colors.Red);
471

    
472
                        foreach (var markupItem in MarkupDataSet)
473
                        {
474
                            pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
475
                            var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault();
476

    
477
                            mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
478
                            var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
479

    
480
                            //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
481
                            //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
482
                            
483
                            //강인구 테스트
484
                            scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
485
                            scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
486

    
487
                            if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
488
                            {
489
                                mediaBox = cropBox;
490
                            }
491
                            
492
                            pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
493
                            _entity.SaveChanges();
494

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

    
497
                            PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
498

    
499
                            
500
                            foreach (var data in markedData)
501
                            {
502
                                
503
                                var item = JsonSerializerHelper.UnCompressString(data);
504
                                //item = data.Replace("H", "_h");
505
                                var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
506

    
507
                                try
508
                                {
509
                                    switch (ControlT.Name)
510
                                    {
511
                                        #region LINE
512
                                        case "LineControl":
513
                                            {
514
                                                using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
515
                                                {
516
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
517
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
518
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
519
                                                    DoubleCollection DashSize = control.DashSize;
520
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
521

    
522
                                                    var Opacity = control.Opac;
523
                                                    string UserID = control.UserID;
524
                                                    double Interval = control.Interval;
525
                                                    double LineSize = Convert.ToDouble(InnerData.First());
526
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
527
                                                    switch (control.LineStyleSet)
528
                                                    {
529
                                                        //case LineStyleSet.SingleLine:
530
                                                        //    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
531
                                                        //    break;
532
                                                        case LineStyleSet.ArrowLine:
533
                                                            //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
534
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
535
                                                            break;
536
                                                        case LineStyleSet.CancelLine:
537
                                                            {
538
                                                                var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X)));
539
                                                                var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y)));
540

    
541
                                                                if (x > y)
542
                                                                {
543
                                                                    StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
544
                                                                    EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
545
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity);
546
                                                                }
547
                                                            }
548
                                                            break;
549
                                                        case LineStyleSet.TwinLine:
550
                                                            {
551
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
552
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
553
                                                                //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
554
                                                            }
555
                                                            break;
556
                                                        case LineStyleSet.DimLine:
557
                                                            {
558
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
559
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
560
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
561
                                                            }
562
                                                            break;
563
                                                        default:
564
                                                            break;
565
                                                    }
566

    
567
                                                    
568
                                                }
569
                                            }
570
                                            break;
571
                                        #endregion
572
                                        #region ArrowControlMulti
573
                                        case "ArrowControl_Multi":
574
                                            {
575
                                                using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
576
                                                {
577
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
578
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
579
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
580
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
581
                                                    DoubleCollection DashSize = control.DashSize;
582
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
583
                                                    double LineSize = Convert.ToDouble(InnerData.First());
584

    
585
                                                    double Opacity = control.Opac;
586

    
587
                                                    if (EndPoint == MidPoint)
588
                                                    {
589
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
590
                                                    }
591
                                                    else
592
                                                    {
593
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
594
                                                    }
595

    
596
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
597

    
598
                                                }
599
                                            }
600
                                            break;
601
                                        #endregion
602
                                        #region PolyControl
603
                                        case "PolygonControl":
604
                                         using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize <S_PolyControl>(item))
605
                                         {
606
                                                string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
607
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
608
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
609
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
610
                                                double LineSize = Convert.ToDouble(InnerData.First());
611
                                                double Opacity = control.Opac;
612
                                                DoubleCollection DashSize = control.DashSize;
613

    
614
                                                Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
615
                                            }
616
                                        break;
617
                                        #endregion
618
                                        #region ArcControl
619
                                        case "ArcControl":
620
                                            {
621
                                                using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
622
                                                {
623
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
624
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
625
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
626
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
627
                                                    DoubleCollection DashSize = control.DashSize;
628
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
629

    
630
                                                    var Opacity = control.Opac;
631
                                                    string UserID = control.UserID;
632
                                                    double LineSize = Convert.ToDouble(InnerData.First());
633
                                                    bool IsTransOn = control.IsTransOn;
634

    
635
                                                    if (control.IsTransOn)
636
                                                    {
637
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
638
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
639
                                                    }
640
                                                    else
641
                                                    {
642
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
643
                                                    }
644

    
645
                                                }
646
                                            }
647
                                            break;
648
                                        #endregion
649
                                        #region RectangleControl
650
                                        case "RectangleControl":
651
                                        using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
652
                                        {
653
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
654
                                                double LineSize = Convert.ToDouble(data2.First());
655
                                                var PaintStyle = control.PaintState;
656
                                                double Angle = control.Angle;
657
                                                DoubleCollection DashSize = control.DashSize;
658
                                                double Opacity = control.Opac;
659
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
660
                                                
661
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
662
                                        }
663
                                        break;
664
                                        #endregion
665
                                        #region TriControl
666
                                        case "TriControl":
667
                                        using (S_TriControl control  = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
668
                                        {
669
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
670
                                                double LineSize = Convert.ToDouble(data2.First());
671
                                                var PaintStyle = control.Paint;
672
                                                double Angle = control.Angle;
673
                                                //StrokeColor = _SetColor, //색상은 레드
674
                                                DoubleCollection DashSize = control.DashSize;
675
                                                double Opacity = control.Opac;
676
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
677

    
678
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
679
                                            }
680
                                        break;
681
                                        #endregion
682
                                        #region CircleControl
683
                                        case "CircleControl":                                            
684
                                            using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
685
                                            {
686
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
687
                                                double LineSize = Convert.ToDouble(data2.First());
688
                                                var StartPoint = GetPdfPointSystem(control.StartPoint);
689
                                                var EndPoint = GetPdfPointSystem(control.EndPoint);
690
                                                var PaintStyle = control.PaintState;
691
                                                double Angle = control.Angle;
692
                                                DoubleCollection DashSize = control.DashSize;
693
                                                double Opacity = control.Opac;
694
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
695
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
696

    
697
                                            }
698
                                        break;
699
                                        #endregion
700
                                        #region RectCloudControl
701
                                        case "RectCloudControl":
702
                                            using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
703
                                            {
704
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
705
                                                double LineSize = Convert.ToDouble(data2.First());
706
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
707
                                                //double ArcLength = 30;
708
                                                double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
709

    
710

    
711
                                                double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength;
712

    
713
                                                var PaintStyle = control.PaintState;
714
                                                double Opacity = control.Opac;
715
                                                DoubleCollection DashSize = control.DashSize;
716

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

    
720
                                                double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
721
                                                bool reverse = (area < 0);
722
                                                if (PaintStyle == PaintSet.None)
723
                                                {
724
                                                    Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
725
                                                }
726
                                                else
727
                                                {
728
                                                    Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
729
                                                }
730
                                            }
731
                                            break;
732
                                        #endregion
733
                                        #region CloudControl
734
                                        case "CloudControl":
735
                                            using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
736
                                            {
737
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
738
                                                double LineSize = Convert.ToDouble(data2.First());
739
                                                double Toler = control.Toler;
740
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
741
                                                double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength;
742
                                                var PaintStyle = control.PaintState;
743
                                                double Opacity = control.Opac;
744
                                                bool isTransOn = control.IsTrans;
745
                                                bool isChain = control.IsChain;
746

    
747
                                                DoubleCollection DashSize = control.DashSize;
748

    
749
                                                if (isChain)
750
                                                {
751
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
752
                                                }
753
                                                else
754
                                                {
755
                                                    if (isTransOn)
756
                                                    {
757
                                                        double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
758
                                                        bool reverse = (area < 0);
759

    
760
                                                        if (PaintStyle == PaintSet.None)
761
                                                        {
762
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
763
                                                        }
764
                                                        else
765
                                                        {
766
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
767
                                                        }
768
                                                    }
769
                                                    else
770
                                                    {
771
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
772
                                                    }
773
                                                }
774
                                            }
775
                                        break;
776
                                        #endregion
777
                                        #region TEXT
778
                                        case "TextControl":
779
                                            using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
780
                                            {
781
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
782
                                                string Text = control.Text;
783

    
784
                                                bool isUnderline = false;
785
                                                control.BoxW -= scaleWidth;
786
                                                control.BoxH -= scaleHeight;
787
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
788
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
789
                                                Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
790

    
791
                                                List<Point> pointSet = new List<Point>();
792
                                                pointSet.Add(StartPoint);
793
                                                pointSet.Add(EndPoint);
794

    
795
                                                PaintSet paint = PaintSet.None;
796
                                                switch (control.paintMethod)
797
                                                {
798
                                                    case 1:
799
                                                        {
800
                                                            paint = PaintSet.Fill;
801
                                                        }
802
                                                        break;
803
                                                    case 2:
804
                                                        {
805
                                                            paint = PaintSet.Hatch;
806
                                                        }
807
                                                        break;
808
                                                    default:
809
                                                        break;
810
                                                }
811
                                                if (control.isHighLight) paint |= PaintSet.Highlight;
812

    
813
                                                double LineSize = Convert.ToDouble(data2.First());
814
                                                double TextSize = Convert.ToDouble(data2[1]);
815
                                                SolidColorBrush FontColor = _SetColor;
816
                                                double Angle = control.Angle;
817
                                                double Opacity = control.Opac;
818
                                                FontFamily fontfamilly = new FontFamily(control.fontConfig[0]);
819
                                                var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
820

    
821
                                                FontStyle fontStyle = FontStyles.Normal;
822
                                                if (FontStyles.Italic == TextStyle)
823
                                                {
824
                                                    fontStyle = FontStyles.Italic;
825
                                                }
826

    
827
                                                FontWeight fontWeight = FontWeights.Black;
828

    
829
                                                var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
830
                                                //강인구 수정(2018.04.17)
831
                                                if (FontWeights.Bold == TextWeight)
832
                                                //if (FontWeights.ExtraBold == TextWeight)
833
                                                {
834
                                                    fontWeight = FontWeights.Bold;
835
                                                }
836

    
837
                                                TextDecorationCollection decoration = TextDecorations.Baseline;
838
                                                if (control.fontConfig.Count() == 4)
839
                                                {
840
                                                    decoration = TextDecorations.Underline;
841
                                                }
842

    
843
                                                if (LineSize <= 3)
844
                                                {
845
                                                    LineSize = 3;
846
                                                }
847

    
848
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
849
                                            }
850
                                            break;
851
                                        #endregion
852
                                        #region ArrowTextControl
853
                                        case "ArrowTextControl":
854
                                            using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item))
855
                                            {
856
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
857
                                                Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
858
                                                Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
859
                                                Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
860
                                                bool isUnderLine = false;
861
                                                string Text = "";
862
                                                double fontsize = 30;
863

    
864
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
865
                                                Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
866
                                                List<Point> tempPoint = new List<Point>();
867

    
868
                                                var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
869

    
870
                                                tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
871
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
872
                                                tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
873
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
874
                                                double Angle = control.Angle;
875
                                                var newStartPoint = tempStartPoint;
876
                                                var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
877
                                                var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
878

    
879
                                                double LineSize = Convert.ToDouble(data2.First());
880
                                                SolidColorBrush FontColor = _SetColor;
881
                                                bool isHighlight = control.isHighLight;
882
                                                double Opacity = control.Opac;
883
                                                PaintSet Paint = PaintSet.None;
884

    
885
                                                switch (control.ArrowStyle)
886
                                                {
887
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
888
                                                        {
889
                                                            Paint = PaintSet.None;
890
                                                        }
891
                                                        break;
892
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
893
                                                        {
894
                                                            Paint = PaintSet.Hatch;
895
                                                        }
896
                                                        break;
897
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
898
                                                        {
899
                                                            Paint = PaintSet.Fill;
900
                                                        }
901
                                                        break;
902
                                                    default:
903
                                                        break;
904
                                                }
905
                                                if (control.isHighLight) Paint |= PaintSet.Highlight;
906

    
907
                                                if (Paint == PaintSet.Hatch)
908
                                                {
909
                                                    Text = control.ArrowText;
910
                                                }
911
                                                else
912
                                                {
913
                                                    Text = control.ArrowText;
914
                                                }
915

    
916
                                                try
917
                                                {
918
                                                    if (control.fontConfig.Count == 4)
919
                                                    {
920
                                                        fontsize = Convert.ToDouble(control.fontConfig[3]);
921
                                                    }
922

    
923
                                                    //강인구 수정(2018.04.17)
924
                                                    var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
925

    
926
                                                    FontStyle fontStyle = FontStyles.Normal;
927
                                                    if (FontStyles.Italic == TextStyle)
928
                                                    {
929
                                                        fontStyle = FontStyles.Italic;
930
                                                    }
931

    
932
                                                    FontWeight fontWeight = FontWeights.Black;
933

    
934
                                                    var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
935
                                                    if (FontWeights.Bold == TextWeight)
936
                                                    {
937
                                                        fontWeight = FontWeights.Bold;
938
                                                    }
939

    
940
                                                    TextDecorationCollection decoration = TextDecorations.Baseline;
941
                                                    if (control.fontConfig.Count() == 5)
942
                                                    {
943
                                                        decoration = TextDecorations.Underline;
944
                                                    }
945

    
946
                                                if (control.isTrans)
947
                                                {
948
                                                    //인구 수정 Arrow Text Style적용 되도록 변경
949
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), 
950
                                                        newStartPoint, tempMidPoint, 
951
                                                        LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
952
                                                }
953
                                                else
954
                                                {
955
                                                    if (control.isFixed)
956
                                                    {
957
                                                        var testP = new Point(0, 0);
958
                                                        if (control.isFixed)
959
                                                        {
960
                                                            if (tempPoint[1] == newEndPoint)
961
                                                            {
962
                                                                testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
963
                                                            }
964
                                                            else if (tempPoint[3] == newEndPoint)
965
                                                            {
966
                                                                testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
967
                                                            }
968
                                                            else if (tempPoint[0] == newEndPoint)
969
                                                            {
970
                                                                testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
971
                                                            }
972
                                                            else if (tempPoint[2] == newEndPoint)
973
                                                            {
974
                                                                testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
975
                                                            }
976
                                                        }
977
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
978
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), 
979
                                                            tempStartPoint, testP,
980
                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
981
                                                        new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
982
                                                    }
983
                                                    else
984
                                                    {
985
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
986
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), 
987
                                                            newStartPoint, newMidPoint,
988
                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
989

    
990

    
991
                                                        }
992
                                                }
993

    
994
                                                }
995
                                                catch (Exception ex)
996
                                                {
997

    
998
                                                }
999
                                            }
1000
                                            break;
1001
                                        #endregion
1002
                                        #region SignControl
1003
                                        case "SignControl":
1004
                                            using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1005
                                            {
1006
                                                
1007
                                                double Angle = control.Angle;
1008
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1009
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1010
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1011
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1012
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1013
                                                double Opacity = control.Opac;
1014
                                                string UserNumber = control.UserNumber;
1015
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1016
                                            }
1017
                                            break;
1018
                                        #endregion
1019
                                        #region MyRegion
1020
                                        case "DateControl":
1021
                                            using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1022
                                            {
1023
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1024
                                                string Text = control.Text;
1025
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1026
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1027
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1028
                                                SolidColorBrush FontColor = _SetColor;
1029
                                                double Angle = control.Angle;
1030
                                                double Opacity = control.Opac;
1031
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1032
                                            }
1033
                                        break;
1034
                                        #endregion
1035
                                        #region SymControlN (APPROVED)
1036
                                        case "SymControlN":
1037
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1038
                                            {
1039
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1040
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1041
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1042
                                                SolidColorBrush FontColor = _SetColor;
1043
                                                double Angle = control.Angle;
1044
                                                double Opacity = control.Opac;
1045
                                                                                                
1046
                                                string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1047
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1048
                                            }
1049
                                            break;
1050
                                        case "SymControl":
1051
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1052
                                            {
1053
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1054
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1055
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1056
                                                SolidColorBrush FontColor = _SetColor;
1057
                                                double Angle = control.Angle;
1058
                                                double Opacity = control.Opac;
1059
                                                
1060
                                                string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", "");
1061
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1062
                                            }
1063
                                            break;
1064
                                        #endregion
1065
                                        #region Image
1066
                                        case "ImgControl":
1067
                                            using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1068
                                            {
1069
                                                double Angle = control.Angle;
1070
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1071
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1072
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1073
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1074
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1075
                                                double Opacity = control.Opac;
1076
                                                string FilePath = control.ImagePath;
1077
                                                //Uri uri = new Uri(s.ImagePath);
1078

    
1079
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1080
                                            }
1081
                                            break;
1082
                                        #endregion
1083
                                        default:
1084
                                            break;
1085
                                    }
1086
                                }
1087
                                catch (Exception ex)
1088
                                {
1089
                                    
1090
                                }
1091
                            }
1092
                        }
1093
                        pdfStamper.Outlines = root;
1094
                        pdfStamper.Close();
1095
                        pdfReader.Close();
1096
                    } 
1097
                }
1098
                #endregion
1099
            }
1100

    
1101
            try
1102
            {
1103
                if (tempFileInfo.Exists)
1104
                {
1105
                    tempFileInfo.Delete();
1106
                }
1107

    
1108
                if (File.Exists(pdfFilePath))
1109
                {
1110

    
1111
                    FinalPDFPath = new FileInfo(pdfFilePath);
1112

    
1113
                    ///TODO : 복사할 경로를 configuration으로 빼주세요
1114
                    
1115
                    string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", "");
1116
                    File.Move(FinalPDFPath.FullName, pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1117
                    FinalPDFPath = new FileInfo(pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1118

    
1119
                    try
1120
                    {
1121
                        File.Delete(pdfFilePath);
1122
                    }
1123
                    catch (Exception ex)
1124
                    {
1125
                        System.Diagnostics.Debug.Write("삭제 불가" + ex.Message);
1126
                    }
1127
                    //
1128

    
1129
                    return true;
1130
                }
1131
            }
1132
            catch (Exception ex)
1133
            {
1134

    
1135
                throw;
1136
            }
1137

    
1138
            return false;
1139
        }
1140

    
1141
        public void Dispose()
1142
        {
1143
            throw new NotImplementedException();
1144
        }       
1145

    
1146
        #endregion
1147
    }
1148
}
클립보드 이미지 추가 (최대 크기: 500 MB)