프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
143
        #endregion
144

    
145
        #region 생성자 & 소멸자
146
        public void MakeFinalPDF(object _FinalPDF)
147
        {
148
            DOCUMENT_ITEM documentItem;
149
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
150
            FinalItem = FinalPDF;
151

    
152

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

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

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

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

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

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

    
203
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
204
                                         + (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5))
205
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
206

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

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

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

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

    
233
                        #region 파일 체크
234
                        if (_files.Count() == 1)
235
                        {
236
                            /// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정
237
                            //if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()))
238
                            //{
239
                                OriginFileName = _files.First().Name;
240
                                PdfFilePath = _files.First().CopyTo(TestFile, true);
241
                            //}
242
                            //else
243
                            //{
244
                            //    throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower());
245
                            //}
246
                        }
247
                        else if (_files.Count() > 1)
248
                        {
249
                            var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault();
250

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

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

    
302
            try
303
            {
304

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

    
309
                    if (finalList.Count() > 0)
310
                    {
311
                        TestFile = SetFlattingPDF(TestFile);
312
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
313
                    }
314
                }
315
                if (EndFinal != null)
316
                {
317
                    EndFinal(this, new EndFinalEventArgs
318
                    {
319
                        OriginPDFName = OriginFileName,
320
                        FinalPDFPath = FinalPDFPath.FullName,
321
                        Error = "",
322
                        Message = "",
323
                        FinalPDF = FinalPDF,
324
                    });
325
                }
326
            }
327
            catch (Exception ex)
328
            {
329
                throw ex;
330
            }
331
        }
332
        #endregion
333

    
334
        #region PDF
335
        public static float scaleWidth = 0;
336
        public static float scaleHeight = 0;
337

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

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

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

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

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

    
371
                var memStream = new MemoryStream();
372
                var stamper = new PdfStamper(pdfReader, memStream)
373
                {
374
                    FormFlattening = true,                     
375
                    //FreeTextFlattening = true,
376
                    //AnnotationFlattening = true,                     
377
                };
378
                
379
                stamper.Close();
380
                pdfReader.Close();
381
                var array = memStream.ToArray();
382
                File.Delete(tempFileInfo);
383
                File.WriteAllBytes(TestFile.FullName, array);
384

    
385
                return TestFile.FullName;
386
            }
387
            else
388
            {
389
                return tempFileInfo;
390
            }
391
        }
392

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

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

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

    
416
                if (!Directory.Exists(_FinalPDFStorgeLocal))
417
                {
418
                    Directory.CreateDirectory(_FinalPDFStorgeLocal);
419
                }
420
                string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name);
421
                using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
422
                {
423
                    memberlist = cIEntities.MEMBER.ToList();
424
                }
425
                using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
426
                {
427
                    FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault();
428

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

    
439
                        var dic = new Dictionary<string, object>();
440
                        foreach (var data in MarkupDataSet)
441
                        {
442

    
443
                            string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID;
444

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

    
456

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

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

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

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

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

    
476
                                if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
477
                                {
478
                                    pdfSize = cropBox; 
479
                                }
480
                                scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
481
                                scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
482

    
483
                                pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
484
                                _entity.SaveChanges();
485

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

    
488
                                PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
489

    
490

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

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

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

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

    
551

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

    
569
                                                        double Opacity = control.Opac;
570

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

    
580
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
581

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

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

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

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

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

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

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

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

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

    
695
                                                    var PaintStyle = control.PaintState;
696
                                                    double Opacity = control.Opac;
697
                                                    DoubleCollection DashSize = control.DashSize;
698

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

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

    
729
                                                    DoubleCollection DashSize = control.DashSize;
730

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

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

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

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

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

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

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

    
809
                                                    FontWeight fontWeight = FontWeights.Black;
810

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

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

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

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

    
845
                                                    var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
846

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

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

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

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

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

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

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

    
909
                                                        FontWeight fontWeight = FontWeights.Black;
910

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

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

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

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

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

    
1020
                                                    string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1021
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1022
                                                }
1023
                                                break;
1024
                                            case "SymControl":
1025
                                                using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1026
                                                {
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

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

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

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

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

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

    
1098
                    return true;
1099
                }
1100
            }
1101
            catch (Exception)
1102
            {
1103
                throw;
1104
            }
1105
            return false;
1106
        }
1107

    
1108
        ~MarkupToPDF()
1109
        {
1110
            this.Dispose(false);
1111
        }
1112

    
1113
        private bool disposed;
1114

    
1115
        public void Dispose()
1116
        {
1117
            this.Dispose(true);
1118
            GC.SuppressFinalize(this);
1119
        }
1120

    
1121
        protected virtual void Dispose(bool disposing)
1122
        {
1123
            if (this.disposed) return;
1124
            if (disposing)
1125
            {
1126
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
1127
            }
1128
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
1129
            this.disposed = true;
1130
        }
1131

    
1132
        #endregion
1133
    }
1134
}
클립보드 이미지 추가 (최대 크기: 500 MB)