프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 9dec2e0a

이력 | 보기 | 이력해설 | 다운로드 (69.2 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
            return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Top - (float)(point.Y / scaleHeight) - pdfSize.Bottom);
105
        }
106

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

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

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

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

    
135
        #endregion
136

    
137
        #region 생성자 & 소멸자
138
        public void MakeFinalPDF(object _FinalPDF)
139
        {
140

    
141
            DOCUMENT_ITEM documentItem;
142
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
143
            FinalItem = FinalPDF;
144

    
145

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

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

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

    
175
                }
176
            }
177
            catch (Exception ex)
178
            {
179
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
180
                return;
181
            }
182
            #endregion
183

    
184
            #region 문서 복사
185
            try
186
            {
187
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
188
                {
189
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
190

    
191
                    if (_DOCINFO.Count() > 0)
192
                    {
193
                        DocInfoItem = _DOCINFO.FirstOrDefault();
194
                        DocPageItem = DocInfoItem.DOCPAGE.ToList();
195

    
196
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
197
                                         + (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString()
198
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
199

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

    
202
                        if (MarkupInfoItem == null)
203
                        {
204
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
205
                        }
206
                        else
207
                        {
208
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0)
209
                            {
210
                                MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d => d.PAGENUMBER).ToList();
211
                            }
212
                            else
213
                            {
214
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
215
                            }
216
                        }
217

    
218
                        documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID).FirstOrDefault();
219
                        if (documentItem == null)
220
                        {
221
                            throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
222
                        }
223

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

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

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

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

    
294
            try
295
            {
296

    
297
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
298
                {
299
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
300

    
301
                    if (finalList.Count() > 0)
302
                    {
303
                        TestFile = SetFlattingPDF(TestFile);
304
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.Insert;
305
                        //_entity.SaveChanges();
306

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

    
327
                throw;
328
            }
329
        }
330
        #endregion
331

    
332
        #region PDF
333
        public static float scaleWidth = 0;
334
        public static float scaleHeight = 0;
335

    
336
        private string SetFlattingPDF(string tempFileInfo)
337
        {
338
            if (File.Exists(tempFileInfo))
339
            {
340
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
341

    
342
                PdfReader pdfReader = new PdfReader(tempFileInfo);
343
                for (int i = 1; i < pdfReader.NumberOfPages; i++)
344
                {
345
                    var mediaBox = pdfReader.GetPageSize(i);
346
                    var cropbox = pdfReader.GetCropBox(i);
347

    
348
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
349
                    //{
350
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
351
                    //}
352
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
353

    
354
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
355
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
356
                    //scaleWidth = 2.0832634F;
357
                    //scaleHeight = 3.0F;
358

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

    
369
                var memStream = new MemoryStream();
370
                var stamper = new PdfStamper(pdfReader, memStream)
371
                {
372
                    FormFlattening = true,
373
                    FreeTextFlattening = true,
374
                    AnnotationFlattening = true,
375
                };
376

    
377
                stamper.Close();
378
                pdfReader.Close();
379
                var array = memStream.ToArray();
380
                File.Delete(tempFileInfo);
381
                File.WriteAllBytes(TestFile.FullName, array);
382

    
383
                return TestFile.FullName;
384
            }
385
            else
386
            {
387
                return tempFileInfo;
388
            }
389
        }
390

    
391
        public void flattenPdfFile(string src, ref string dest)
392
        {
393
            PdfReader reader = new PdfReader(src);
394
            var memStream = new MemoryStream();
395
            var stamper = new PdfStamper(reader, memStream)
396
            {
397
                FormFlattening = true,
398
                FreeTextFlattening = true,
399
                AnnotationFlattening = true,
400
            };
401

    
402
            stamper.Close();
403
            var array = memStream.ToArray();
404
            File.WriteAllBytes(dest, array);
405
        }
406

    
407
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
408
        {
409
            try
410
            {
411
                string pdfFilePath = null;
412
                List<MEMBER> memberlist = null;
413
                FileInfo tempFileInfo = new FileInfo(testFile);
414

    
415
                if (!Directory.Exists(_FinalPDFStorgeLocal))
416
                {
417
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
418
                }
419
                pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name;
420
                using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
421
                {
422
                    memberlist = cIEntities.MEMBER.ToList();
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

    
444
                            var member = memberlist.Where(u => u.ID == userid).FirstOrDefault();
445
                            string username = member.NAME;
446
                            string userdept = member.DEPARTMENT;
447
                            bookmark = new Dictionary<string, object>();
448
                            bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER));
449
                            bookmark.Add("Page", data.PAGENUMBER + " Fit");
450
                            bookmark.Add("Action", "GoTo");
451
                            bookmark.Add("Kids", outlines);
452
                            root.Add(bookmark);
453
                        }
454

    
455

    
456
                        using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
457
                        {
458
                            var _SetColor = new SolidColorBrush(Colors.Red);
459

    
460
                            string[] delimiterChars = { "|DZ|" };
461
                            string[] delimiterChars2 = { "|" };
462

    
463
                            //pdfStamper.FormFlattening = true; //이미 선처리 작업함
464
                            pdfStamper.SetFullCompression();
465
                            _SetColor = new SolidColorBrush(Colors.Red);
466

    
467
                            foreach (var markupItem in MarkupDataSet)
468
                            {
469
                                pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
470
                                var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault();
471

    
472
                                mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
473
                                mediaBox = mediaBox.Rotate();
474
                                var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
475

    
476
                                //강인구 테스트
477
                                scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
478
                                scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
479

    
480
                                //if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
481
                                //{
482
                                //    mediaBox = cropBox;
483
                                //}
484

    
485
                                pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
486
                                _entity.SaveChanges();
487

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

    
490
                                PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
491

    
492

    
493
                                foreach (var data in markedData)
494
                                {
495
                                    var item = JsonSerializerHelper.UnCompressString(data);
496
                                    var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
497

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

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

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

    
553

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

    
571
                                                        double Opacity = control.Opac;
572

    
573
                                                        if (EndPoint == MidPoint)
574
                                                        {
575
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity);
576
                                                        }
577
                                                        else
578
                                                        {
579
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
580
                                                        }
581

    
582
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
583

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

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

    
616
                                                        var Opacity = control.Opac;
617
                                                        string UserID = control.UserID;
618
                                                        double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
619
                                                        bool IsTransOn = control.IsTransOn;
620

    
621
                                                        if (control.IsTransOn)
622
                                                        {
623
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
624
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
625
                                                        }
626
                                                        else
627
                                                        {
628
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
629
                                                        }
630

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

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

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

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

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

    
697
                                                    var PaintStyle = control.PaintState;
698
                                                    double Opacity = control.Opac;
699
                                                    DoubleCollection DashSize = control.DashSize;
700

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

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

    
731
                                                    DoubleCollection DashSize = control.DashSize;
732

    
733
                                                    if (isChain)
734
                                                    {
735
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
736
                                                    }
737
                                                    else
738
                                                    {
739
                                                        if (isTransOn)
740
                                                        {
741
                                                            double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
742
                                                            bool reverse = (area < 0);
743

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

    
768
                                                    bool isUnderline = false;
769
                                                    control.BoxW -= scaleWidth;
770
                                                    control.BoxH -= scaleHeight;
771
                                                    System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
772
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
773
                                                    Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
774

    
775
                                                    List<Point> pointSet = new List<Point>();
776
                                                    pointSet.Add(StartPoint);
777
                                                    pointSet.Add(EndPoint);
778

    
779
                                                    PaintSet paint = PaintSet.None;
780
                                                    switch (control.paintMethod)
781
                                                    {
782
                                                        case 1:
783
                                                            {
784
                                                                paint = PaintSet.Fill;
785
                                                            }
786
                                                            break;
787
                                                        case 2:
788
                                                            {
789
                                                                paint = PaintSet.Hatch;
790
                                                            }
791
                                                            break;
792
                                                        default:
793
                                                            break;
794
                                                    }
795
                                                    if (control.isHighLight) paint |= PaintSet.Highlight;
796

    
797
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
798
                                                    double TextSize = Convert.ToDouble(data2[1]);
799
                                                    SolidColorBrush FontColor = _SetColor;
800
                                                    double Angle = control.Angle;
801
                                                    double Opacity = control.Opac;
802
                                                    FontFamily fontfamilly = new FontFamily(control.fontConfig[0]);
803
                                                    var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
804

    
805
                                                    FontStyle fontStyle = FontStyles.Normal;
806
                                                    if (FontStyles.Italic == TextStyle)
807
                                                    {
808
                                                        fontStyle = FontStyles.Italic;
809
                                                    }
810

    
811
                                                    FontWeight fontWeight = FontWeights.Black;
812

    
813
                                                    var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
814
                                                    //강인구 수정(2018.04.17)
815
                                                    if (FontWeights.Bold == TextWeight)
816
                                                    //if (FontWeights.ExtraBold == TextWeight)
817
                                                    {
818
                                                        fontWeight = FontWeights.Bold;
819
                                                    }
820

    
821
                                                    TextDecorationCollection decoration = TextDecorations.Baseline;
822
                                                    if (control.fontConfig.Count() == 4)
823
                                                    {
824
                                                        decoration = TextDecorations.Underline;
825
                                                    }
826

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

    
843
                                                    System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
844
                                                    Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
845
                                                    List<Point> tempPoint = new List<Point>();
846

    
847
                                                    var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
848

    
849
                                                    tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
850
                                                    tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
851
                                                    tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
852
                                                    tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
853
                                                    double Angle = control.Angle;
854
                                                    var newStartPoint = tempStartPoint;
855
                                                    var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
856
                                                    var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
857

    
858
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
859
                                                    SolidColorBrush FontColor = _SetColor;
860
                                                    bool isHighlight = control.isHighLight;
861
                                                    double Opacity = control.Opac;
862
                                                    PaintSet Paint = PaintSet.None;
863

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

    
886
                                                    if (Paint == PaintSet.Hatch)
887
                                                    {
888
                                                        Text = control.ArrowText;
889
                                                    }
890
                                                    else
891
                                                    {
892
                                                        Text = control.ArrowText;
893
                                                    }
894

    
895
                                                    try
896
                                                    {
897
                                                        if (control.fontConfig.Count == 4)
898
                                                        {
899
                                                            fontsize = Convert.ToDouble(control.fontConfig[3]);
900
                                                        }
901

    
902
                                                        //강인구 수정(2018.04.17)
903
                                                        var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
904

    
905
                                                        FontStyle fontStyle = FontStyles.Normal;
906
                                                        if (FontStyles.Italic == TextStyle)
907
                                                        {
908
                                                            fontStyle = FontStyles.Italic;
909
                                                        }
910

    
911
                                                        FontWeight fontWeight = FontWeights.Black;
912

    
913
                                                        var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
914
                                                        if (FontWeights.Bold == TextWeight)
915
                                                        {
916
                                                            fontWeight = FontWeights.Bold;
917
                                                        }
918

    
919
                                                        TextDecorationCollection decoration = TextDecorations.Baseline;
920
                                                        if (control.fontConfig.Count() == 5)
921
                                                        {
922
                                                            decoration = TextDecorations.Underline;
923
                                                        }
924

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

    
974
                                                    }
975
                                                }
976
                                                break;
977
                                            #endregion
978
                                            #region SignControl
979
                                            case "SignControl":
980
                                                using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
981
                                                {
982

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

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

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

    
1055
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1056
                                                }
1057
                                                break;
1058
                                            #endregion
1059
                                            default:
1060
                                                break;
1061
                                        }
1062
                                    }
1063
                                    catch (Exception ex)
1064
                                    {
1065

    
1066
                                    }
1067
                                }
1068
                            }
1069
                            pdfStamper.Outlines = root;
1070
                            pdfStamper.Close();
1071
                            pdfReader.Close();
1072
                        }
1073
                    }
1074
                    #endregion
1075
                }
1076
                if (tempFileInfo.Exists)
1077
                {
1078
                    tempFileInfo.Delete();
1079
                }
1080

    
1081
                if (File.Exists(pdfFilePath))
1082
                {
1083
                    try
1084
                    {
1085
                        FinalPDFPath = new FileInfo(pdfFilePath);
1086

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

    
1101
                    return true;
1102
                }
1103
            }
1104
            catch (Exception)
1105
            {
1106
                throw;
1107
            }
1108
            return false;
1109
        }
1110

    
1111
        public void Dispose()
1112
        {
1113
            throw new NotImplementedException();
1114
        }
1115

    
1116
        #endregion
1117
    }
1118
}
클립보드 이미지 추가 (최대 크기: 500 MB)