프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (69.6 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 System;
9
using System.Collections.Generic;
10
using System.Configuration;
11
using System.IO;
12
using System.Linq;
13
using System.Net;
14
using System.Runtime.InteropServices;
15
using System.Text;
16
using System.Web;
17
using System.Windows;
18
using System.Windows.Media;
19

    
20
namespace MarkupToPDF
21
{
22
    public class MarkupToPDF : IDisposable
23
    {
24
        #region 초기 데이터
25
        private static iTextSharp.text.Rectangle mediaBox;
26
        private FileInfo PdfFilePath = null;
27
        private FileInfo FinalPDFPath = null;
28
        private string _FinalPDFStorgeLocal = null;
29
        private string _FinalPDFStorgeRemote = null;
30
        private string OriginFileName = null;
31
        public FINAL_PDF FinalItem;
32
        public DOCINFO DocInfoItem = null;
33
        public List<DOCPAGE> DocPageItem = null;
34
        public MARKUP_INFO MarkupInfoItem = null;
35
        public List<MARKUP_DATA> MarkupDataSet = null;
36
        //private string _PrintPDFStorgeLocal = null;
37
        //private string _PrintPDFStorgeRemote = null;
38
        public event EventHandler<MakeFinalErrorArgs> FinalMakeError;
39
        public event EventHandler<EndFinalEventArgs> EndFinal;
40

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

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

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

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

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

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

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

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

    
115
        public double GetPdfSize(double size)
116
        {
117
            return (size / scaleWidth);
118
        }
119

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

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

    
135
            angle += 90;
136
            //if (angle < 0)
137
            //{
138
            //    angle = angle + 360;
139
            //}
140
            return angle;
141
        }
142

    
143
        #endregion
144

    
145
        #region 생성자 & 소멸자
146
        public void MakeFinalPDF(object _FinalPDF)
147
        {
148

    
149
            DOCUMENT_ITEM documentItem;
150
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
151
            FinalItem = FinalPDF;
152

    
153

    
154
            string PdfFilePathRoot = null;
155
            string TestFile = System.IO.Path.GetTempFileName();
156

    
157
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
158
            try
159
            {
160
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
161
                {
162
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
163

    
164
                    if (_properties.Count() > 0)
165
                    {
166
                        PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
167
                        _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
168
                        _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
169
                    }
170
                    else
171
                    {
172
                        SetNotice(FinalPDF.ID, "프로퍼티를 가지고 올 수 없습니다.");
173
                        return;
174
                    }
175
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
176
                    if (finalList.Count() > 0)
177
                    {
178
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
179
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
180
                        _entity.SaveChanges();
181
                    }
182

    
183
                }
184
            }
185
            catch (Exception ex)
186
            {
187
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
188
                return;
189
            }
190
            #endregion
191

    
192
            #region 문서 복사
193
            try
194
            {
195
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
196
                {
197
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
198

    
199
                    if (_DOCINFO.Count() > 0)
200
                    {
201
                        DocInfoItem = _DOCINFO.FirstOrDefault();
202
                        DocPageItem = DocInfoItem.DOCPAGE.ToList();
203

    
204
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
205
                                         + (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString()
206
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
207

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

    
210
                        if (MarkupInfoItem == null)
211
                        {
212
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
213
                        }
214
                        else
215
                        {
216
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0)
217
                            {
218
                                MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d => d.PAGENUMBER).ToList();
219
                            }
220
                            else
221
                            {
222
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
223
                            }
224
                        }
225

    
226
                        documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault();
227
                        if (documentItem == null)
228
                        {
229
                            throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
230
                        }
231

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

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

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

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

    
302
            try
303
            {
304

    
305
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
306
                {
307
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
308

    
309
                    if (finalList.Count() > 0)
310
                    {
311
                        TestFile = SetFlattingPDF(TestFile);
312
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.Insert;
313
                        //_entity.SaveChanges();
314

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

    
335
                throw;
336
            }
337
        }
338
        #endregion
339

    
340
        #region PDF
341
        public static float scaleWidth = 0;
342
        public static float scaleHeight = 0;
343

    
344
        private string SetFlattingPDF(string tempFileInfo)
345
        {
346
            if (File.Exists(tempFileInfo))
347
            {
348
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
349

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

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

    
362
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
363
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
364
                    //scaleWidth = 2.0832634F;
365
                    //scaleHeight = 3.0F;
366

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

    
377
                var memStream = new MemoryStream();
378
                var stamper = new PdfStamper(pdfReader, memStream)
379
                {
380
                    FormFlattening = true,                     
381
                    //FreeTextFlattening = true,
382
                    //AnnotationFlattening = true,                     
383
                };
384
                
385
                stamper.Close();
386
                pdfReader.Close();
387
                var array = memStream.ToArray();
388
                File.Delete(tempFileInfo);
389
                File.WriteAllBytes(TestFile.FullName, array);
390

    
391
                return TestFile.FullName;
392
            }
393
            else
394
            {
395
                return tempFileInfo;
396
            }
397
        }
398

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

    
410
            stamper.Close();
411
            var array = memStream.ToArray();
412
            File.WriteAllBytes(dest, array);
413
        }
414

    
415
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
416
        {
417
            try
418
            {
419
                string pdfFilePath = null;
420
                List<MEMBER> memberlist = null;
421
                FileInfo tempFileInfo = new FileInfo(testFile);
422

    
423
                if (!Directory.Exists(_FinalPDFStorgeLocal))
424
                {
425
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
426
                }
427
                pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name;
428
                using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
429
                {
430
                    memberlist = cIEntities.MEMBER.ToList();
431
                }
432
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
433
                {
434
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
435

    
436
                    #region 코멘트 적용 + 커버시트
437
                    using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
438
                    {
439
                        PdfReader pdfReader = new PdfReader(pdfStream);
440
                        //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
441
                        Dictionary<string, object> bookmark;
442
                        List<Dictionary<string, object>> outlines;
443
                        outlines = new List<Dictionary<string, object>>();
444
                        List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
445

    
446
                        var dic = new Dictionary<string, object>();
447
                        foreach (var data in MarkupDataSet)
448
                        {
449

    
450
                            string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
451

    
452
                            var member = memberlist.Where(u => u.ID == userid).FirstOrDefault();
453
                            string username = member.NAME;
454
                            string userdept = member.DEPARTMENT;
455
                            bookmark = new Dictionary<string, object>();
456
                            bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
457
                            bookmark.Add("Page", data.PAGENUMBER + " Fit");
458
                            bookmark.Add("Action", "GoTo");
459
                            bookmark.Add("Kids", outlines);
460
                            root.Add(bookmark);
461
                        }
462

    
463

    
464
                        using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
465
                        {
466
                            var _SetColor = new SolidColorBrush(Colors.Red);
467

    
468
                            string[] delimiterChars = { "|DZ|" };
469
                            string[] delimiterChars2 = { "|" };
470

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

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

    
480
                                mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
481
                                var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);                                
482

    
483
                                if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
484
                                {
485
                                    pdfSize = cropBox; 
486
                                }
487
                                scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
488
                                scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
489

    
490
                                pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
491
                                _entity.SaveChanges();
492

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

    
495
                                PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
496

    
497

    
498
                                foreach (var data in markedData)
499
                                {
500
                                    var item = JsonSerializerHelper.UnCompressString(data);
501
                                    var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
502

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

    
518
                                                        var Opacity = control.Opac;
519
                                                        string UserID = control.UserID;
520
                                                        double Interval = control.Interval;
521
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
522
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
523
                                                        switch (control.LineStyleSet)
524
                                                        {
525
                                                            case LineStyleSet.ArrowLine:
526
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity);
527
                                                                break;
528
                                                            case LineStyleSet.CancelLine:
529
                                                                {
530
                                                                    var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X)));
531
                                                                    var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y)));
532

    
533
                                                                    if (x > y)
534
                                                                    {
535
                                                                        StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
536
                                                                        EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
537
                                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity);
538
                                                                    }
539
                                                                }
540
                                                                break;
541
                                                            case LineStyleSet.TwinLine:
542
                                                                {
543
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity);
544
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity);
545
                                                                }
546
                                                                break;
547
                                                            case LineStyleSet.DimLine:
548
                                                                {
549
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity);
550
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity);
551
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity);
552
                                                                }
553
                                                                break;
554
                                                            default:
555
                                                                break;
556
                                                        }
557

    
558

    
559
                                                    }
560
                                                }
561
                                                break;
562
                                            #endregion
563
                                            #region ArrowControlMulti
564
                                            case "ArrowControl_Multi":
565
                                                {
566
                                                    using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
567
                                                    {
568
                                                        string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
569
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
570
                                                        Point MidPoint = GetPdfPointSystem(control.MidPoint);
571
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
572
                                                        DoubleCollection DashSize = control.DashSize;
573
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
574
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
575

    
576
                                                        double Opacity = control.Opac;
577

    
578
                                                        if (EndPoint == MidPoint)
579
                                                        {
580
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity);
581
                                                        }
582
                                                        else
583
                                                        {
584
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
585
                                                        }
586

    
587
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
588

    
589
                                                    }
590
                                                }
591
                                                break;
592
                                            #endregion
593
                                            #region PolyControl
594
                                            case "PolygonControl":
595
                                                using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item))
596
                                                {
597
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
598
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
599
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
600
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
601
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
602
                                                    double Opacity = control.Opac;
603
                                                    DoubleCollection DashSize = control.DashSize;
604

    
605
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
606
                                                }
607
                                                break;
608
                                            #endregion
609
                                            #region ArcControl
610
                                            case "ArcControl":
611
                                                {
612
                                                    using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
613
                                                    {
614
                                                        string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
615
                                                        Point StartPoint = GetPdfPointSystem(control.StartPoint);
616
                                                        Point EndPoint = GetPdfPointSystem(control.EndPoint);
617
                                                        Point MidPoint = GetPdfPointSystem(control.MidPoint);
618
                                                        DoubleCollection DashSize = control.DashSize;
619
                                                        List<Point> PointSet = GetPdfPointSystem(control.PointSet);
620

    
621
                                                        var Opacity = control.Opac;
622
                                                        string UserID = control.UserID;
623
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
624
                                                        bool IsTransOn = control.IsTransOn;
625

    
626
                                                        if (control.IsTransOn)
627
                                                        {
628
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
629
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
630
                                                        }
631
                                                        else
632
                                                        {
633
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
634
                                                        }
635

    
636
                                                    }
637
                                                }
638
                                                break;
639
                                            #endregion
640
                                            #region RectangleControl
641
                                            case "RectangleControl":
642
                                                using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
643
                                                {
644
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
645
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
646
                                                    var PaintStyle = control.PaintState;
647
                                                    double Angle = control.Angle;
648
                                                    DoubleCollection DashSize = control.DashSize;
649
                                                    double Opacity = control.Opac;
650
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
651

    
652
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
653
                                                }
654
                                                break;
655
                                            #endregion
656
                                            #region TriControl
657
                                            case "TriControl":
658
                                                using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
659
                                                {
660
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
661
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
662
                                                    var PaintStyle = control.Paint;
663
                                                    double Angle = control.Angle;
664
                                                    //StrokeColor = _SetColor, //색상은 레드
665
                                                    DoubleCollection DashSize = control.DashSize;
666
                                                    double Opacity = control.Opac;
667
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
668

    
669
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
670
                                                }
671
                                                break;
672
                                            #endregion
673
                                            #region CircleControl
674
                                            case "CircleControl":
675
                                                using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
676
                                                {
677
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
678
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
679
                                                    var StartPoint = GetPdfPointSystem(control.StartPoint);
680
                                                    var EndPoint = GetPdfPointSystem(control.EndPoint);
681
                                                    var PaintStyle = control.PaintState;
682
                                                    double Angle = control.Angle;
683
                                                    DoubleCollection DashSize = control.DashSize;
684
                                                    double Opacity = control.Opac;
685
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
686
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
687

    
688
                                                }
689
                                                break;
690
                                            #endregion
691
                                            #region RectCloudControl
692
                                            case "RectCloudControl":
693
                                                using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
694
                                                {
695
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
696
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
697
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
698
                                                    double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
699

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

    
702
                                                    var PaintStyle = control.PaintState;
703
                                                    double Opacity = control.Opac;
704
                                                    DoubleCollection DashSize = control.DashSize;
705

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

    
709
                                                    double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
710
                                                    bool reverse = (area < 0);
711
                                                    if (PaintStyle == PaintSet.None)
712
                                                    {
713
                                                        Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
714
                                                    }
715
                                                    else
716
                                                    {
717
                                                        Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
718
                                                    }
719
                                                }
720
                                                break;
721
                                            #endregion
722
                                            #region CloudControl
723
                                            case "CloudControl":
724
                                                using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
725
                                                {
726
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
727
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
728
                                                    double Toler = control.Toler;
729
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
730
                                                    double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
731
                                                    var PaintStyle = control.PaintState;
732
                                                    double Opacity = control.Opac;
733
                                                    bool isTransOn = control.IsTrans;
734
                                                    bool isChain = control.IsChain;
735

    
736
                                                    DoubleCollection DashSize = control.DashSize;
737

    
738
                                                    if (isChain)
739
                                                    {
740
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
741
                                                    }
742
                                                    else
743
                                                    {
744
                                                        if (isTransOn)
745
                                                        {
746
                                                            double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
747
                                                            bool reverse = (area < 0);
748

    
749
                                                            if (PaintStyle == PaintSet.None)
750
                                                            {
751
                                                                Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
752
                                                            }
753
                                                            else
754
                                                            {
755
                                                                Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
756
                                                            }
757
                                                        }
758
                                                        else
759
                                                        {
760
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
761
                                                        }
762
                                                    }
763
                                                }
764
                                                break;
765
                                            #endregion
766
                                            #region TEXT
767
                                            case "TextControl":
768
                                                using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
769
                                                {
770
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
771
                                                    string Text = control.Text;
772

    
773
                                                    bool isUnderline = false;
774
                                                    control.BoxW -= scaleWidth;
775
                                                    control.BoxH -= scaleHeight;
776
                                                    System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
777
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
778
                                                    Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
779

    
780
                                                    List<Point> pointSet = new List<Point>();
781
                                                    pointSet.Add(StartPoint);
782
                                                    pointSet.Add(EndPoint);
783

    
784
                                                    PaintSet paint = PaintSet.None;
785
                                                    switch (control.paintMethod)
786
                                                    {
787
                                                        case 1:
788
                                                            {
789
                                                                paint = PaintSet.Fill;
790
                                                            }
791
                                                            break;
792
                                                        case 2:
793
                                                            {
794
                                                                paint = PaintSet.Hatch;
795
                                                            }
796
                                                            break;
797
                                                        default:
798
                                                            break;
799
                                                    }
800
                                                    if (control.isHighLight) paint |= PaintSet.Highlight;
801

    
802
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
803
                                                    double TextSize = Convert.ToDouble(data2[1]);
804
                                                    SolidColorBrush FontColor = _SetColor;
805
                                                    double Angle = control.Angle;
806
                                                    double Opacity = control.Opac;
807
                                                    FontFamily fontfamilly = new FontFamily(control.fontConfig[0]);
808
                                                    var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
809

    
810
                                                    FontStyle fontStyle = FontStyles.Normal;
811
                                                    if (FontStyles.Italic == TextStyle)
812
                                                    {
813
                                                        fontStyle = FontStyles.Italic;
814
                                                    }
815

    
816
                                                    FontWeight fontWeight = FontWeights.Black;
817

    
818
                                                    var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
819
                                                    //강인구 수정(2018.04.17)
820
                                                    if (FontWeights.Bold == TextWeight)
821
                                                    //if (FontWeights.ExtraBold == TextWeight)
822
                                                    {
823
                                                        fontWeight = FontWeights.Bold;
824
                                                    }
825

    
826
                                                    TextDecorationCollection decoration = TextDecorations.Baseline;
827
                                                    if (control.fontConfig.Count() == 4)
828
                                                    {
829
                                                        decoration = TextDecorations.Underline;
830
                                                    }
831

    
832
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
833
                                                }
834
                                                break;
835
                                            #endregion
836
                                            #region ArrowTextControl
837
                                            case "ArrowTextControl":
838
                                                using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item))
839
                                                {
840
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
841
                                                    Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
842
                                                    Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
843
                                                    Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
844
                                                    bool isUnderLine = false;
845
                                                    string Text = "";
846
                                                    double fontsize = 30;
847

    
848
                                                    System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
849
                                                    Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
850
                                                    List<Point> tempPoint = new List<Point>();
851

    
852
                                                    var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
853

    
854
                                                    tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
855
                                                    tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
856
                                                    tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
857
                                                    tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
858
                                                    double Angle = control.Angle;
859
                                                    var newStartPoint = tempStartPoint;
860
                                                    var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
861
                                                    var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
862

    
863
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
864
                                                    SolidColorBrush FontColor = _SetColor;
865
                                                    bool isHighlight = control.isHighLight;
866
                                                    double Opacity = control.Opac;
867
                                                    PaintSet Paint = PaintSet.None;
868

    
869
                                                    switch (control.ArrowStyle)
870
                                                    {
871
                                                        case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
872
                                                            {
873
                                                                Paint = PaintSet.None;
874
                                                            }
875
                                                            break;
876
                                                        case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
877
                                                            {
878
                                                                Paint = PaintSet.Hatch;
879
                                                            }
880
                                                            break;
881
                                                        case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
882
                                                            {
883
                                                                Paint = PaintSet.Fill;
884
                                                            }
885
                                                            break;
886
                                                        default:
887
                                                            break;
888
                                                    }
889
                                                    if (control.isHighLight) Paint |= PaintSet.Highlight;
890

    
891
                                                    if (Paint == PaintSet.Hatch)
892
                                                    {
893
                                                        Text = control.ArrowText;
894
                                                    }
895
                                                    else
896
                                                    {
897
                                                        Text = control.ArrowText;
898
                                                    }
899

    
900
                                                    try
901
                                                    {
902
                                                        if (control.fontConfig.Count == 4)
903
                                                        {
904
                                                            fontsize = Convert.ToDouble(control.fontConfig[3]);
905
                                                        }
906

    
907
                                                        //강인구 수정(2018.04.17)
908
                                                        var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
909

    
910
                                                        FontStyle fontStyle = FontStyles.Normal;
911
                                                        if (FontStyles.Italic == TextStyle)
912
                                                        {
913
                                                            fontStyle = FontStyles.Italic;
914
                                                        }
915

    
916
                                                        FontWeight fontWeight = FontWeights.Black;
917

    
918
                                                        var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
919
                                                        if (FontWeights.Bold == TextWeight)
920
                                                        {
921
                                                            fontWeight = FontWeights.Bold;
922
                                                        }
923

    
924
                                                        TextDecorationCollection decoration = TextDecorations.Baseline;
925
                                                        if (control.fontConfig.Count() == 5)
926
                                                        {
927
                                                            decoration = TextDecorations.Underline;
928
                                                        }
929

    
930
                                                        if (control.isTrans)
931
                                                        {
932
                                                            //인구 수정 Arrow Text Style적용 되도록 변경
933
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
934
                                                                newStartPoint, tempMidPoint,
935
                                                                LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
936
                                                        }
937
                                                        else
938
                                                        {
939
                                                            if (control.isFixed)
940
                                                            {
941
                                                                var testP = new Point(0, 0);
942
                                                                if (control.isFixed)
943
                                                                {
944
                                                                    if (tempPoint[1] == newEndPoint)
945
                                                                    {
946
                                                                        testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
947
                                                                    }
948
                                                                    else if (tempPoint[3] == newEndPoint)
949
                                                                    {
950
                                                                        testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
951
                                                                    }
952
                                                                    else if (tempPoint[0] == newEndPoint)
953
                                                                    {
954
                                                                        testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
955
                                                                    }
956
                                                                    else if (tempPoint[2] == newEndPoint)
957
                                                                    {
958
                                                                        testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
959
                                                                    }
960
                                                                }
961
                                                                //인구 수정 Arrow Text Style적용 되도록 변경
962
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
963
                                                                    tempStartPoint, testP,
964
                                                                    LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
965
                                                                new FontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
966
                                                            }
967
                                                            else
968
                                                            {
969
                                                                //인구 수정 Arrow Text Style적용 되도록 변경
970
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
971
                                                                    newStartPoint, newMidPoint,
972
                                                                    LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
973
                                                            }
974
                                                        }
975
                                                    }
976
                                                    catch (Exception ex)
977
                                                    {
978

    
979
                                                    }
980
                                                }
981
                                                break;
982
                                            #endregion
983
                                            #region SignControl
984
                                            case "SignControl":
985
                                                using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
986
                                                {
987

    
988
                                                    double Angle = control.Angle;
989
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
990
                                                    Point TopRightPoint = GetPdfPointSystem(control.TR);
991
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
992
                                                    Point LeftBottomPoint = GetPdfPointSystem(control.LB);
993
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
994
                                                    double Opacity = control.Opac;
995
                                                    string UserNumber = control.UserNumber;
996
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
997
                                                }
998
                                                break;
999
                                            #endregion
1000
                                            #region MyRegion
1001
                                            case "DateControl":
1002
                                                using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1003
                                                {
1004
                                                    string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1005
                                                    string Text = control.Text;
1006
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
1007
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
1008
                                                    List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1009
                                                    SolidColorBrush FontColor = _SetColor;
1010
                                                    double Angle = control.Angle;
1011
                                                    double Opacity = control.Opac;
1012
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1013
                                                }
1014
                                                break;
1015
                                            #endregion
1016
                                            #region SymControlN (APPROVED)
1017
                                            case "SymControlN":
1018
                                                using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1019
                                                {
1020
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
1021
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
1022
                                                    List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1023
                                                    SolidColorBrush FontColor = _SetColor;
1024
                                                    double Angle = control.Angle;
1025
                                                    double Opacity = control.Opac;
1026

    
1027
                                                    string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1028
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1029
                                                }
1030
                                                break;
1031
                                            case "SymControl":
1032
                                                using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1033
                                                {
1034
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
1035
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
1036
                                                    List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1037
                                                    SolidColorBrush FontColor = _SetColor;
1038
                                                    double Angle = control.Angle;
1039
                                                    double Opacity = control.Opac;
1040

    
1041
                                                    string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", "");
1042
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1043
                                                }
1044
                                                break;
1045
                                            #endregion
1046
                                            #region Image
1047
                                            case "ImgControl":
1048
                                                using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1049
                                                {
1050
                                                    double Angle = control.Angle;
1051
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
1052
                                                    Point TopRightPoint = GetPdfPointSystem(control.TR);
1053
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
1054
                                                    Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1055
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1056
                                                    double Opacity = control.Opac;
1057
                                                    string FilePath = control.ImagePath;
1058
                                                    //Uri uri = new Uri(s.ImagePath);
1059

    
1060
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1061
                                                }
1062
                                                break;
1063
                                            #endregion
1064
                                            default:
1065
                                                break;
1066
                                        }
1067
                                    }
1068
                                    catch (Exception ex)
1069
                                    {
1070

    
1071
                                    }
1072
                                }
1073
                            }
1074
                            pdfStamper.Outlines = root;
1075
                            pdfStamper.Close();
1076
                            pdfReader.Close();
1077
                        }
1078
                    }
1079
                    #endregion
1080
                }
1081
                if (tempFileInfo.Exists)
1082
                {
1083
                    tempFileInfo.Delete();
1084
                }
1085

    
1086
                if (File.Exists(pdfFilePath))
1087
                {
1088
                    try
1089
                    {
1090
                        FinalPDFPath = new FileInfo(pdfFilePath);
1091

    
1092
                        string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", "");
1093
                        string destfilepath = Path.Combine(pdfmovepath,FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1094
                        if (File.Exists(destfilepath))
1095
                            File.Delete(destfilepath);
1096
                        File.Move(FinalPDFPath.FullName, destfilepath);
1097
                        FinalPDFPath = new FileInfo(destfilepath);
1098
                        File.Delete(pdfFilePath);
1099
                    }
1100
                    catch (Exception ex)
1101
                    {
1102
                        SetNotice(finaldata.ID, "File move error: " + ex.ToString());
1103
                    }
1104
                    //
1105

    
1106
                    return true;
1107
                }
1108
            }
1109
            catch (Exception)
1110
            {
1111
                throw;
1112
            }
1113
            return false;
1114
        }
1115

    
1116
        public void Dispose()
1117
        {
1118
            throw new NotImplementedException();
1119
        }
1120

    
1121
        #endregion
1122
    }
1123
}
클립보드 이미지 추가 (최대 크기: 500 MB)