프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 66128b37

이력 | 보기 | 이력해설 | 다운로드 (71.9 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.Windows;
17
using System.Windows.Media;
18

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

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

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

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

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

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

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

    
78
        private string GetFileName(string hrefLink)
79
        {
80
            return System.IO.Path.GetFileName(hrefLink.Replace("/", "\\"));
81
        }
82

    
83
        public Point GetPdfPointSystem(Point point)
84
        {
85
            point = new Point(point.X + pdfSize.Left * scaleWidth, point.Y - pdfSize.Bottom * scaleHeight);
86
            return new Point((float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight));
87
        }
88

    
89
        public double GetPdfSize(double size)
90
        {
91
            return (size / scaleWidth);
92
        }
93

    
94
        public List<Point> GetPdfPointSystem(List<Point> point) 
95
        {
96
            List<Point> dummy = new List<Point>();
97
            foreach (var item in point)
98
            {
99
                dummy.Add(GetPdfPointSystem(item));
100
            }
101
            return dummy;
102
        }
103

    
104
        public double returnAngle(Point start, Point end)
105
        {
106
            double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y);
107
            //angle *= -1;
108

    
109
            angle += 90;
110
            //if (angle < 0)
111
            //{
112
            //    angle = angle + 360;
113
            //}
114
            return angle;
115
        }
116

    
117
        #endregion
118

    
119
        #region 생성자 & 소멸자
120
        public void MakeFinalPDF(object _FinalPDF)
121
        {
122
            
123
            DOCUMENT_ITEM documentItem;
124
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
125
            FinalItem = FinalPDF;
126

    
127

    
128
            string PdfFilePathRoot = null;
129
            string TestFile = System.IO.Path.GetTempFileName();
130

    
131
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
132
            try
133
            {
134
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
135
                {
136
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
137

    
138
                    if (_properties.Count () > 0)
139
                    {
140
                        PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
141
                        _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
142
                        _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
143
                    }
144
                    else
145
                    {
146
                        SetNotice(FinalPDF.ID, "프로퍼티를 가지고 올 수 없습니다.");
147
                        return;
148
                    }
149

    
150
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
151

    
152
                    if (finalList.Count() > 0)
153
                    {
154
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
155
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
156
                        _entity.SaveChanges(); 
157
                    }
158
                }
159
            }
160
            catch (Exception ex)
161
            {
162
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
163
                return;
164
            }
165
            #endregion
166

    
167
            #region 문서 복사
168
            try
169
            {
170
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
171
                {
172
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
173

    
174
                    if (_DOCINFO.Count() > 0)
175
                    {
176
                        DocInfoItem = _DOCINFO.FirstOrDefault();
177
                        DocPageItem = DocInfoItem.DOCPAGE.ToList();
178

    
179
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
180
                                         + (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString()
181
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
182

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

    
185
                        if (MarkupInfoItem == null)
186
                        {
187
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
188
                        }
189
                        else
190
                        {
191
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0)
192
                            {
193
                                MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d=>d.PAGENUMBER).ToList();
194
                            }
195
                            else
196
                            {
197
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
198
                            }
199
                        }
200

    
201
                        using (CIEntities _ci_Internal = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
202
                        {
203
                            documentItem = _ci_Internal.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID).FirstOrDefault();
204
                            if (documentItem == null)
205
                            {
206
                                throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
207
                            }
208

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

    
211
                            #region 파일 체크
212
                            if (_files.Count() == 1)
213
                            {
214
                                if (_files.First().Name.ToLower() == GetFileName(documentItem.ORIGINAL_FILE).ToLower())
215
                                {
216
                                    OriginFileName = _files.First().Name;
217
                                    PdfFilePath = _files.First().CopyTo(TestFile, true);
218
                                }
219
                                else
220
                                {
221
                                    throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다");
222
                                }
223
                            }
224
                            else if (_files.Count() > 1)
225
                            {
226
                                var originalFile = _files.Where(data => data.Name == GetFileName(documentItem.ORIGINAL_FILE)).FirstOrDefault();
227

    
228
                                if (originalFile == null)
229
                                {
230
                                    throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
231
                                }
232
                                else
233
                                {
234
                                    OriginFileName = originalFile.Name;
235
                                    PdfFilePath = originalFile.CopyTo(TestFile, true);
236
                                }
237
                            }
238
                            else
239
                            {
240
                                throw new Exception("PDF를 찾지 못하였습니다");
241
                            }
242
                            #endregion
243

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

    
279
            try
280
            {
281

    
282
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
283
                {
284
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
285

    
286
                    if (finalList.Count() > 0)
287
                    {
288
                        TestFile = SetFlattingPDF(TestFile);
289
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.Insert;
290
                        //_entity.SaveChanges();
291

    
292
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
293
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.PdfStamp;
294
                        //_entity.SaveChanges();
295
                    }
296
                }
297
                    if (EndFinal != null)
298
                    {
299
                        EndFinal(this, new EndFinalEventArgs
300
                        {
301
                            OriginPDFName = OriginFileName,
302
                            FinalPDFPath = _FinalPDFStorgeRemote + "\\" + FinalPDFPath.Name,
303
                            Error = "",
304
                            Message = "",
305
                            FinalPDF = FinalPDF,
306
                        });
307
                    }
308
            }
309
            catch (Exception ex)
310
            {
311

    
312
                throw;
313
            }
314
        }
315
        #endregion
316

    
317
        #region PDF
318
        float scaleWidth = 0;
319
        float scaleHeight = 0;
320

    
321
         
322
        private string SetFlattingPDF(string tempFileInfo)
323
        {
324
            if (File.Exists(tempFileInfo))
325
            {
326
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
327

    
328
                PdfReader pdfReader = new PdfReader(tempFileInfo);
329
                for (int i = 1; i < pdfReader.NumberOfPages; i++)
330
                {
331
                    var mediaBox = pdfReader.GetPageSize(i);
332
                    var cropbox = pdfReader.GetCropBox(i);
333

    
334
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
335
                    //{
336
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
337
                    //}
338
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
339

    
340
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
341
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
342
                    //scaleWidth = 2.0832634F;
343
                    //scaleHeight = 3.0F;
344

    
345
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
346
                    //강인구 수정
347
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
348
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
349
                    //{
350
                    //    var pageDict = pdfReader.GetPageN(i);
351
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
352
                    //}
353
                }
354

    
355
                var memStream = new MemoryStream();
356
                var stamper = new PdfStamper(pdfReader, memStream)
357
                {
358
                    FormFlattening = true,
359
                    FreeTextFlattening = true,
360
                    AnnotationFlattening = true,
361
                };
362

    
363
                stamper.Close();
364
                pdfReader.Close();
365
                var array = memStream.ToArray();
366
                File.Delete(tempFileInfo);
367
                File.WriteAllBytes(TestFile.FullName, array);
368

    
369
                return TestFile.FullName;
370
            }
371
            else
372
            {
373
                return tempFileInfo;
374
            }
375
        }
376

    
377
        public void flattenPdfFile(string src, ref string dest)
378
        {
379
            PdfReader reader = new PdfReader(src);
380
            var memStream = new MemoryStream();
381
            var stamper = new PdfStamper(reader, memStream)
382
            {
383
                FormFlattening = true,
384
                FreeTextFlattening = true,
385
                AnnotationFlattening = true,
386
            };
387

    
388
            stamper.Close();
389
            var array = memStream.ToArray();
390
            File.WriteAllBytes(dest, array);
391
        }
392

    
393
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
394
        {
395
            string pdfFilePath = null;
396
            FileInfo tempFileInfo = new FileInfo(testFile);
397

    
398
            if (!Directory.Exists(_FinalPDFStorgeLocal))
399
            {
400
                Directory.CreateDirectory(_FinalPDFStorgeLocal);
401
            }
402
            pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name;
403

    
404
            using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
405
            {
406
                FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
407

    
408
                #region 코멘트 적용 + 커버시트
409
                using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) //
410
                {
411
                    PdfReader pdfReader = new PdfReader(pdfStream);
412
                    //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>();
413
                    Dictionary<string, object> bookmark;
414
                    List<Dictionary<string, object>> outlines;
415
                    outlines = new List<Dictionary<string, object>>();
416
                    List<Dictionary<string, object>> root = new List<Dictionary<string, object>>();
417

    
418
                    var dic = new Dictionary<string, object>();
419
                    MarkupDataSet.Select(d => d.PAGENUMBER).ToList().ForEach(a =>
420
                      {
421
                          bookmark = new Dictionary<string, object>();
422
                          bookmark.Add("Title", "Commented Page : " + a);
423
                          bookmark.Add("Page", a + " Fit");
424
                          //bookmark.Add("Page", "2 /XYZ 50 500 50 50");
425
                          bookmark.Add("Action", "GoTo");
426
                          bookmark.Add("Kids", outlines);
427
                          root.Add(bookmark);
428
                      });
429

    
430

    
431
                    using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
432
                    {
433
                        var _SetColor = new SolidColorBrush(Colors.Red);
434
                        
435
                        string[] delimiterChars = { "|DZ|" };
436
                        string[] delimiterChars2 = { "|" };
437

    
438
                        //pdfStamper.FormFlattening = true; //이미 선처리 작업함
439
                        pdfStamper.SetFullCompression();
440
                        _SetColor = new SolidColorBrush(Colors.Red);
441

    
442
                        foreach (var markupItem in MarkupDataSet)
443
                        {
444
                            pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER);
445
                            var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault();
446

    
447
                            mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
448
                            var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
449

    
450
                            //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
451
                            //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
452
                            
453
                            //강인구 테스트
454
                            scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
455
                            scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
456

    
457
                            if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
458
                            {
459
                                mediaBox = cropBox;
460
                            }
461
                            
462
                            pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
463
                            _entity.SaveChanges();
464

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

    
467
                            PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
468

    
469
                            
470
                            foreach (var data in markedData)
471
                            {
472
                                
473
                                var item = JsonSerializerHelper.UnCompressString(data);
474
                                //item = data.Replace("H", "_h");
475
                                var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
476

    
477
                                try
478
                                {
479
                                    switch (ControlT.Name)
480
                                    {
481
                                        #region LINE
482
                                        case "LineControl":
483
                                            {
484
                                                using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
485
                                                {
486
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
487
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
488
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
489
                                                    DoubleCollection DashSize = control.DashSize;
490
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
491

    
492
                                                    var Opacity = control.Opac;
493
                                                    string UserID = control.UserID;
494
                                                    double Interval = control.Interval;
495
                                                    double LineSize = Convert.ToDouble(InnerData.First());
496
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
497
                                                    switch (control.LineStyleSet)
498
                                                    {
499
                                                        //case LineStyleSet.SingleLine:
500
                                                        //    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
501
                                                        //    break;
502
                                                        case LineStyleSet.ArrowLine:
503
                                                            //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
504
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
505
                                                            break;
506
                                                        case LineStyleSet.CancelLine:
507
                                                            {
508
                                                                var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X)));
509
                                                                var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y)));
510

    
511
                                                                if (x > y)
512
                                                                {
513
                                                                    StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
514
                                                                    EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
515
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity);
516
                                                                }
517
                                                            }
518
                                                            break;
519
                                                        case LineStyleSet.TwinLine:
520
                                                            {
521
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
522
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
523
                                                                //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
524
                                                            }
525
                                                            break;
526
                                                        case LineStyleSet.DimLine:
527
                                                            {
528
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
529
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
530
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
531
                                                            }
532
                                                            break;
533
                                                        default:
534
                                                            break;
535
                                                    }
536

    
537
                                                    
538
                                                }
539
                                            }
540
                                            break;
541
                                        #endregion
542
                                        #region ArrowControlMulti
543
                                        case "ArrowControl_Multi":
544
                                            {
545
                                                using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
546
                                                {
547
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
548
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
549
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
550
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
551
                                                    DoubleCollection DashSize = control.DashSize;
552
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
553
                                                    double LineSize = Convert.ToDouble(InnerData.First());
554

    
555
                                                    double Opacity = control.Opac;
556

    
557
                                                    if (EndPoint == MidPoint)
558
                                                    {
559
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
560
                                                    }
561
                                                    else
562
                                                    {
563
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
564
                                                    }
565

    
566
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
567

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

    
584
                                                Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
585
                                            }
586
                                        break;
587
                                        #endregion
588
                                        #region ArcControl
589
                                        case "ArcControl":
590
                                            {
591
                                                using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
592
                                                {
593
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
594
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
595
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
596
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
597
                                                    DoubleCollection DashSize = control.DashSize;
598
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
599

    
600
                                                    var Opacity = control.Opac;
601
                                                    string UserID = control.UserID;
602
                                                    double LineSize = Convert.ToDouble(InnerData.First());
603
                                                    bool IsTransOn = control.IsTransOn;
604

    
605
                                                    if (control.IsTransOn)
606
                                                    {
607
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
608
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
609
                                                    }
610
                                                    else
611
                                                    {
612
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
613
                                                    }
614

    
615
                                                }
616
                                            }
617
                                            break;
618
                                        #endregion
619
                                        #region RectangleControl
620
                                        case "RectangleControl":
621
                                        using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
622
                                        {
623
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
624
                                                double LineSize = Convert.ToDouble(data2.First());
625
                                                var PaintStyle = control.PaintState;
626
                                                double Angle = control.Angle;
627
                                                DoubleCollection DashSize = control.DashSize;
628
                                                double Opacity = control.Opac;
629
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
630
                                                
631
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
632
                                        }
633
                                        break;
634
                                        #endregion
635
                                        #region TriControl
636
                                        case "TriControl":
637
                                        using (S_TriControl control  = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
638
                                        {
639
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
640
                                                double LineSize = Convert.ToDouble(data2.First());
641
                                                var PaintStyle = control.Paint;
642
                                                double Angle = control.Angle;
643
                                                //StrokeColor = _SetColor, //색상은 레드
644
                                                DoubleCollection DashSize = control.DashSize;
645
                                                double Opacity = control.Opac;
646
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
647

    
648
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
649
                                            }
650
                                        break;
651
                                        #endregion
652
                                        #region CircleControl
653
                                        case "CircleControl":                                            
654
                                            using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
655
                                            {
656
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
657
                                                double LineSize = Convert.ToDouble(data2.First());
658
                                                var StartPoint = GetPdfPointSystem(control.StartPoint);
659
                                                var EndPoint = GetPdfPointSystem(control.EndPoint);
660
                                                var PaintStyle = control.PaintState;
661
                                                double Angle = control.Angle;
662
                                                DoubleCollection DashSize = control.DashSize;
663
                                                double Opacity = control.Opac;
664
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
665
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
666

    
667
                                            }
668
                                        break;
669
                                        #endregion
670
                                        #region RectCloudControl
671
                                        case "RectCloudControl":
672
                                            using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
673
                                            {
674
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
675
                                                double LineSize = Convert.ToDouble(data2.First());
676
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
677
                                                //double ArcLength = 30;
678
                                                double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
679

    
680

    
681
                                                double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength;
682

    
683
                                                //ArcLength = (size * 0.13);
684

    
685
                                                //강인구 수정(클라우드 사이즈)
686
                                                //if (ArcLength <= 10)
687
                                                //{
688
                                                //    ArcLength = 10;
689
                                                //}
690
                                                //if (ArcLength <= 3)
691
                                                //{
692
                                                //    ArcLength = 10;
693
                                                //}
694
                                                //else if (ArcLength <= 10)
695
                                                //{
696
                                                //    ArcLength = 20;
697
                                                //}
698
                                                //else if (ArcLength <= 30)
699
                                                //{
700
                                                //    ArcLength = 30;
701
                                                //}
702

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

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

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

    
737
                                                DoubleCollection DashSize = control.DashSize;
738

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

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

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

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

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

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

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

    
817
                                                FontWeight fontWeight = FontWeights.Black;
818

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

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

    
833
                                                if (LineSize <= 3)
834
                                                {
835
                                                    LineSize = 3;
836
                                                }
837

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

    
854
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
855
                                                Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
856
                                                List<Point> tempPoint = new List<Point>();
857

    
858
                                                var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
859

    
860
                                                tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
861
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
862
                                                tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
863
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
864
                                                double Angle = control.Angle;
865
                                                var newStartPoint = tempStartPoint;
866
                                                var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
867
                                                var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
868

    
869
                                                double LineSize = Convert.ToDouble(data2.First());
870
                                                SolidColorBrush FontColor = _SetColor;
871
                                                bool isHighlight = control.isHighLight;
872
                                                double Opacity = control.Opac;
873
                                                PaintSet Paint = PaintSet.None;
874

    
875
                                                switch (control.ArrowStyle)
876
                                                {
877
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
878
                                                        {
879
                                                            Paint = PaintSet.None;
880
                                                        }
881
                                                        break;
882
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
883
                                                        {
884
                                                            Paint = PaintSet.Hatch;
885
                                                        }
886
                                                        break;
887
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
888
                                                        {
889
                                                            Paint = PaintSet.Fill;
890
                                                        }
891
                                                        break;
892
                                                    default:
893
                                                        break;
894
                                                }
895
                                                if (control.isHighLight) Paint |= PaintSet.Highlight;
896

    
897
                                                if (Paint == PaintSet.Hatch)
898
                                                {
899
                                                    Text = control.ArrowText;
900
                                                }
901
                                                else
902
                                                {
903
                                                    Text = control.ArrowText;
904
                                                }
905

    
906
                                                try
907
                                                {
908
                                                    if (control.fontConfig.Count == 4)
909
                                                    {
910
                                                        fontsize = Convert.ToDouble(control.fontConfig[3]);
911
                                                    }
912

    
913
                                                    //강인구 수정(2018.04.17)
914
                                                    var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
915

    
916
                                                    FontStyle fontStyle = FontStyles.Normal;
917
                                                    if (FontStyles.Italic == TextStyle)
918
                                                    {
919
                                                        fontStyle = FontStyles.Italic;
920
                                                    }
921

    
922
                                                    FontWeight fontWeight = FontWeights.Black;
923

    
924
                                                    var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
925
                                                    if (FontWeights.Bold == TextWeight)
926
                                                    {
927
                                                        fontWeight = FontWeights.Bold;
928
                                                    }
929

    
930
                                                    TextDecorationCollection decoration = TextDecorations.Baseline;
931
                                                    if (control.fontConfig.Count() == 5)
932
                                                    {
933
                                                        decoration = TextDecorations.Underline;
934
                                                    }
935

    
936
                                                if (control.isTrans)
937
                                                {
938
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(newStartPoint, tempMidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
939
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(newStartPoint, tempMidPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
940
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(tempMidPoint, newEndPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
941
                                                    //인구 수정 Arrow Text Style적용 되도록 변경
942
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize,
943
                                                                                            contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
944
                                                    //Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, 
945
                                                    //                                        contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), new FontStyle(), new FontWeight(), new TextDecorationCollection(), Text, sizeF, Opacity, Angle);
946

    
947
                                                }
948
                                                else
949
                                                {
950
                                                    if (control.isFixed)
951
                                                    {
952
                                                        var testP = new Point(0, 0);
953
                                                        if (control.isFixed)
954
                                                        {
955
                                                            if (tempPoint[1] == newEndPoint)
956
                                                            {
957
                                                                testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
958
                                                            }
959
                                                            else if (tempPoint[3] == newEndPoint)
960
                                                            {
961
                                                                testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
962
                                                            }
963
                                                            else if (tempPoint[0] == newEndPoint)
964
                                                            {
965
                                                                testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
966
                                                            }
967
                                                            else if (tempPoint[2] == newEndPoint)
968
                                                            {
969
                                                                testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
970
                                                            }
971
                                                        }
972
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(tempStartPoint, testP, (int)LineSize, contentByte, _SetColor, Opacity);
973
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(tempStartPoint, testP, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
974
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(testP, newEndPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
975

    
976
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
977
                                                        //Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / 3, tempEndPoint.Y - control.BoxHeight / 3), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
978
                                                        //                                                   new FontFamily(), new FontStyle(), new FontWeight(), new TextDecorationCollection(), Text, sizeF, Opacity, Angle);
979
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
980
                                                        new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
981
                                                    }
982
                                                    else
983
                                                    {
984
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(newStartPoint, newMidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
985
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(newStartPoint, newMidPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
986
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(newMidPoint, newEndPoint, (int)LineSize, contentByte, new DoubleCollection(9999), _SetColor, Opacity);
987

    
988
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
989
                                                        //Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), new FontStyle(), new FontWeight(), new TextDecorationCollection(), Text, sizeF, Opacity, Angle);
990
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
991

    
992

    
993
                                                        }
994
                                                }
995

    
996
                                                }
997
                                                catch (Exception ex)
998
                                                {
999

    
1000
                                                }
1001
                                            }
1002
                                            break;
1003
                                        #endregion
1004
                                        #region SignControl
1005
                                        case "SignControl":
1006
                                            using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
1007
                                            {
1008
                                                
1009
                                                double Angle = control.Angle;
1010
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1011
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1012
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1013
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1014
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1015
                                                double Opacity = control.Opac;
1016
                                                string UserNumber = control.UserNumber;
1017
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
1018
                                            }
1019
                                            break;
1020
                                        #endregion
1021
                                        #region MyRegion
1022
                                        case "DateControl":
1023
                                            using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1024
                                            {
1025
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1026
                                                string Text = control.Text;
1027
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1028
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1029
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1030
                                                SolidColorBrush FontColor = _SetColor;
1031
                                                double Angle = control.Angle;
1032
                                                double Opacity = control.Opac;
1033
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1034
                                            }
1035
                                        break;
1036
                                        #endregion
1037
                                        #region SymControlN (APPROVED)
1038
                                        case "SymControlN":
1039
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1040
                                            {
1041
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1042
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1043
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1044
                                                SolidColorBrush FontColor = _SetColor;
1045
                                                double Angle = control.Angle;
1046
                                                double Opacity = control.Opac;
1047

    
1048
                                                StringBuilder ApprovedImgPath = new StringBuilder(512);
1049
                                                GetPrivateProfileString("ApprovedImgPath", "URL", "(NONE)", ApprovedImgPath, 512, Path.Combine(AppDataFolder, "FinalService.ini"));
1050

    
1051
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, ApprovedImgPath.ToString());
1052
                                            }
1053
                                            break;
1054
                                        case "SymControl":
1055
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1056
                                            {
1057
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1058
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1059
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1060
                                                SolidColorBrush FontColor = _SetColor;
1061
                                                double Angle = control.Angle;
1062
                                                double Opacity = control.Opac;
1063

    
1064
                                                StringBuilder imgpath = new StringBuilder(512);
1065
                                                GetPrivateProfileString("CheckmarkImgPath", "URL", "(NONE)", imgpath, 512, Path.Combine(AppDataFolder, "FinalService.ini"));
1066

    
1067
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath.ToString());
1068
                                            }
1069
                                            break;
1070
                                        #endregion
1071
                                        #region Image
1072
                                        case "ImgControl":
1073
                                            using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1074
                                            {
1075
                                                double Angle = control.Angle;
1076
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1077
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1078
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1079
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1080
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1081
                                                double Opacity = control.Opac;
1082
                                                string FilePath = control.ImagePath;
1083
                                                //Uri uri = new Uri(s.ImagePath);
1084

    
1085
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1086
                                            }
1087
                                            break;
1088
                                        #endregion
1089
                                        default:
1090
                                            break;
1091
                                    }
1092
                                }
1093
                                catch (Exception ex)
1094
                                {
1095
                                    
1096
                                }
1097
                            }
1098
                        }
1099
                        pdfStamper.Outlines = root;
1100
                        pdfStamper.Close();
1101
                        pdfReader.Close();
1102
                    } 
1103
                }
1104
                #endregion
1105
            }
1106

    
1107
            try
1108
            {
1109
                if (tempFileInfo.Exists)
1110
                {
1111
                    tempFileInfo.Delete();
1112
                }
1113

    
1114
                if (File.Exists(pdfFilePath))
1115
                {
1116

    
1117
                    FinalPDFPath = new FileInfo(pdfFilePath);
1118

    
1119
                    ///TODO : 복사할 경로를 configuration으로 빼주세요
1120
                    //File.Move(FinalPDFPath.FullName, @"\\192.168.0.67\finalpdf\" + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1121
                    //FinalPDFPath = new FileInfo(@"\\192.168.0.67\finalpdf\" + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1122
                    StringBuilder PDFMovePath = new StringBuilder(512);
1123
                    GetPrivateProfileString("PDFMovePath", "URL", "(NONE)", PDFMovePath, 512, Path.Combine(AppDataFolder, "FinalService.ini"));
1124
                    File.Move(FinalPDFPath.FullName, PDFMovePath.ToString() + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1125
                    FinalPDFPath = new FileInfo(PDFMovePath.ToString() + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1126

    
1127
                    try
1128
                    {
1129
                        File.Delete(pdfFilePath);
1130
                    }
1131
                    catch (Exception ex)
1132
                    {
1133
                        System.Diagnostics.Debug.Write("삭제 불가" + ex.Message);
1134
                    }
1135
                    //
1136

    
1137
                    return true;
1138
                }
1139
            }
1140
            catch (Exception ex)
1141
            {
1142

    
1143
                throw;
1144
            }
1145

    
1146
            return false;
1147
        }
1148

    
1149
        public void Dispose()
1150
        {
1151
            throw new NotImplementedException();
1152
        }
1153

    
1154
        [DllImport("kernel32")]
1155
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
1156

    
1157
        public static string AppDataFolder
1158
        {
1159
            get
1160
            {
1161
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS");
1162
            }
1163
        }
1164

    
1165
        #endregion
1166
    }
1167
}
클립보드 이미지 추가 (최대 크기: 500 MB)