프로젝트

일반

사용자정보

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

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

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

1 7ca218b3 KangIngu
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 7f01e35f ljiyeon
using System.Configuration;
11 7ca218b3 KangIngu
using System.IO;
12
using System.Linq;
13
using System.Net;
14 7f01e35f ljiyeon
using System.Runtime.InteropServices;
15 7ca218b3 KangIngu
using System.Text;
16 e05bed4e djkim
using System.Web;
17 7ca218b3 KangIngu
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 8c3a888c djkim
        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 7ca218b3 KangIngu
        //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 8c3a888c djkim
        private void SetNotice(string finalID, string message)
72 7ca218b3 KangIngu
        {
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 e05bed4e djkim
            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 7ca218b3 KangIngu
        }
100
101
        public Point GetPdfPointSystem(Point point)
102
        {
103
            point = new Point(point.X + pdfSize.Left * scaleWidth, point.Y - pdfSize.Bottom * scaleHeight);
104
            return new Point((float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight));
105
        }
106
107 488ba687 humkyung
        public double GetPdfSize(double size)
108
        {
109
            return (size / scaleWidth);
110
        }
111
112 8c3a888c djkim
        public List<Point> GetPdfPointSystem(List<Point> point)
113 7ca218b3 KangIngu
        {
114
            List<Point> dummy = new List<Point>();
115
            foreach (var item in point)
116
            {
117
                dummy.Add(GetPdfPointSystem(item));
118
            }
119
            return dummy;
120
        }
121
122
        public double returnAngle(Point start, Point end)
123
        {
124
            double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y);
125
            //angle *= -1;
126
127
            angle += 90;
128
            //if (angle < 0)
129
            //{
130
            //    angle = angle + 360;
131
            //}
132
            return angle;
133
        }
134
135
        #endregion
136
137
        #region 생성자 & 소멸자
138
        public void MakeFinalPDF(object _FinalPDF)
139
        {
140 8c3a888c djkim
141
            DOCUMENT_ITEM documentItem;
142
            FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF;
143 7ca218b3 KangIngu
            FinalItem = FinalPDF;
144
145
146
            string PdfFilePathRoot = null;
147
            string TestFile = System.IO.Path.GetTempFileName();
148
149
            #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정
150 488ba687 humkyung
            try
151 7ca218b3 KangIngu
            {
152 8c3a888c djkim
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
153 7ca218b3 KangIngu
                {
154 8c3a888c djkim
                    var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO);
155
156
                    if (_properties.Count() > 0)
157 7ca218b3 KangIngu
                    {
158 8c3a888c djkim
                        PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE;
159 7ca218b3 KangIngu
                        _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE;
160
                        _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE;
161
                    }
162
                    else
163
                    {
164
                        SetNotice(FinalPDF.ID, "프로퍼티를 가지고 올 수 없습니다.");
165
                        return;
166
                    }
167 8c3a888c djkim
168
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
169
170
                    if (finalList.Count() > 0)
171
                    {
172
                        finalList.FirstOrDefault().START_DATETIME = DateTime.Now;
173
                        finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create;
174
                        _entity.SaveChanges();
175
                    }
176
                }
177 7ca218b3 KangIngu
            }
178
            catch (Exception ex)
179
            {
180
                SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString());
181
                return;
182
            }
183
            #endregion
184
185
            #region 문서 복사
186
            try
187
            {
188 8c3a888c djkim
                using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
189 7ca218b3 KangIngu
                {
190 8c3a888c djkim
                    var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID);
191 7ca218b3 KangIngu
192 8c3a888c djkim
                    if (_DOCINFO.Count() > 0)
193 7ca218b3 KangIngu
                    {
194 8c3a888c djkim
                        DocInfoItem = _DOCINFO.FirstOrDefault();
195
                        DocPageItem = DocInfoItem.DOCPAGE.ToList();
196 7ca218b3 KangIngu
197
                        PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\"
198
                                         + (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString()
199
                                         + @"\" + FinalPDF.DOCUMENT_ID + @"\";
200
201 8c3a888c djkim
                        MarkupInfoItem = DocInfoItem.MARKUP_INFO.Where(data => data.CONSOLIDATE == 1 && data.AVOID_CONSOLIDATE == 0 && data.PART_CONSOLIDATE == 0).FirstOrDefault();
202 7ca218b3 KangIngu
203
                        if (MarkupInfoItem == null)
204
                        {
205
                            throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다");
206
                        }
207
                        else
208
                        {
209 8c3a888c djkim
                            if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0)
210
                            {
211
                                MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d => d.PAGENUMBER).ToList();
212
                            }
213
                            else
214 7ca218b3 KangIngu
                            {
215
                                throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다");
216 8c3a888c djkim
                            }
217 6c9fec59 djkim
                        }
218 7ca218b3 KangIngu
219 8c3a888c djkim
                        using (CIEntities _ci_Internal = new CIEntities(ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString()))
220 6c9fec59 djkim
                        {
221 8c3a888c djkim
                            documentItem = _ci_Internal.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID).FirstOrDefault();
222
                            if (documentItem == null)
223 7ca218b3 KangIngu
                            {
224 8c3a888c djkim
                                throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요");
225 7ca218b3 KangIngu
                            }
226 8c3a888c djkim
227
                            var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 
228
229
                            #region 파일 체크
230
                            if (_files.Count() == 1)
231 7ca218b3 KangIngu
                            {
232 8c3a888c djkim
                                if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()))
233
                                {
234
                                    OriginFileName = _files.First().Name;
235
                                    PdfFilePath = _files.First().CopyTo(TestFile, true);
236
                                }
237
                                else
238
                                {
239
                                    throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower());
240
                                }
241 7ca218b3 KangIngu
                            }
242 8c3a888c djkim
                            else if (_files.Count() > 1)
243 7ca218b3 KangIngu
                            {
244 8c3a888c djkim
                                var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault();
245
246
                                if (originalFile == null)
247
                                {
248
                                    throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다");
249
                                }
250
                                else
251
                                {
252
                                    OriginFileName = originalFile.Name;
253
                                    PdfFilePath = originalFile.CopyTo(TestFile, true);
254
                                }
255 7ca218b3 KangIngu
                            }
256 6c9fec59 djkim
                            else
257 7ca218b3 KangIngu
                            {
258 8c3a888c djkim
                                throw new Exception("PDF를 찾지 못하였습니다");
259 7ca218b3 KangIngu
                            }
260 8c3a888c djkim
                            #endregion
261 6c9fec59 djkim
262 8c3a888c djkim
                            #region 예외처리
263
                            if (PdfFilePath == null)
264
                            {
265
                                throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다");
266
                            }
267
                            if (!PdfFilePath.Exists)
268
                            {
269
                                throw new Exception("PDF원본이 존재하지 않습니다");
270
                            }
271
                            #endregion
272 6c9fec59 djkim
                        }
273 7ca218b3 KangIngu
                    }
274
                    else
275
                    {
276
                        throw new Exception("일치하는 DocInfo가 없습니다");
277
                    }
278
                }
279
            }
280
            catch (Exception ex)
281
            {
282
                if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다")
283
                {
284
                    SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다");
285
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
286
                    process.StartInfo.FileName = "cmd";
287
                    process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\"";
288
                    process.Start();
289
                }
290
                else
291
                {
292
                    SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message);
293
                }
294
            }
295
            #endregion
296
297
            try
298
            {
299
300 8c3a888c djkim
                using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString()))
301
                {
302
                    var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID);
303
304
                    if (finalList.Count() > 0)
305 7ca218b3 KangIngu
                    {
306 8c3a888c djkim
                        TestFile = SetFlattingPDF(TestFile);
307
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.Insert;
308
                        //_entity.SaveChanges();
309
310
                        SetStampInPDF(FinalItem, TestFile, MarkupInfoItem);
311
                        //finalList.FirstOrDefault().STATUS = (int)FinalStatus.PdfStamp;
312
                        //_entity.SaveChanges();
313 7ca218b3 KangIngu
                    }
314 8c3a888c djkim
                }
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 7ca218b3 KangIngu
            }
327
            catch (Exception ex)
328
            {
329
330
                throw;
331
            }
332
        }
333
        #endregion
334
335
        #region PDF
336 4804a4fb humkyung
        public static float scaleWidth = 0;
337
        public static float scaleHeight = 0;
338 8c3a888c djkim
339 7ca218b3 KangIngu
        private string SetFlattingPDF(string tempFileInfo)
340
        {
341
            if (File.Exists(tempFileInfo))
342
            {
343
                FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName());
344
345
                PdfReader pdfReader = new PdfReader(tempFileInfo);
346
                for (int i = 1; i < pdfReader.NumberOfPages; i++)
347
                {
348
                    var mediaBox = pdfReader.GetPageSize(i);
349
                    var cropbox = pdfReader.GetCropBox(i);
350
351 8c3a888c djkim
                    //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString()))
352
                    //{
353
                    //    _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE)
354
                    //}
355 7ca218b3 KangIngu
                    var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault();
356
357 8c3a888c djkim
                    //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
358
                    //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
359
                    //scaleWidth = 2.0832634F;
360
                    //scaleHeight = 3.0F;
361
362 7ca218b3 KangIngu
                    PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i));
363 8c3a888c djkim
                    //강인구 수정
364
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height))
365
                    //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height))
366
                    //{
367
                    //    var pageDict = pdfReader.GetPageN(i);
368
                    //    pageDict.Put(PdfName.MEDIABOX, rect);
369
                    //}
370 7ca218b3 KangIngu
                }
371
372
                var memStream = new MemoryStream();
373
                var stamper = new PdfStamper(pdfReader, memStream)
374
                {
375
                    FormFlattening = true,
376
                    FreeTextFlattening = true,
377
                    AnnotationFlattening = true,
378
                };
379
380
                stamper.Close();
381
                pdfReader.Close();
382
                var array = memStream.ToArray();
383
                File.Delete(tempFileInfo);
384
                File.WriteAllBytes(TestFile.FullName, array);
385
386
                return TestFile.FullName;
387
            }
388
            else
389
            {
390
                return tempFileInfo;
391
            }
392
        }
393
394
        public void flattenPdfFile(string src, ref string dest)
395
        {
396
            PdfReader reader = new PdfReader(src);
397
            var memStream = new MemoryStream();
398
            var stamper = new PdfStamper(reader, memStream)
399
            {
400
                FormFlattening = true,
401
                FreeTextFlattening = true,
402
                AnnotationFlattening = true,
403
            };
404
405
            stamper.Close();
406
            var array = memStream.ToArray();
407
            File.WriteAllBytes(dest, array);
408
        }
409 8c3a888c djkim
410
        public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo)
411 7ca218b3 KangIngu
        {
412
            string pdfFilePath = null;
413 8c3a888c djkim
            List<MEMBER> memberlist = null;
414 7ca218b3 KangIngu
            FileInfo tempFileInfo = new FileInfo(testFile);
415
416
            if (!Directory.Exists(_FinalPDFStorgeLocal))
417
            {
418
                Directory.CreateDirectory(_FinalPDFStorgeLocal);
419
            }
420
            pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name;
421 8c3a888c djkim
            using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString()))
422 abaa85b4 djkim
            {
423 8c3a888c djkim
                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 abaa85b4 djkim
429 8c3a888c djkim
                #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 3ad12023 djkim
                    {
442 7ca218b3 KangIngu
443 8c3a888c djkim
                        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 abaa85b4 djkim
456 7ca218b3 KangIngu
457 8c3a888c djkim
                    using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create)))
458
                    {
459
                        var _SetColor = new SolidColorBrush(Colors.Red);
460 abaa85b4 djkim
461 8c3a888c djkim
                        string[] delimiterChars = { "|DZ|" };
462
                        string[] delimiterChars2 = { "|" };
463 abaa85b4 djkim
464 8c3a888c djkim
                        //pdfStamper.FormFlattening = true; //이미 선처리 작업함
465
                        pdfStamper.SetFullCompression();
466
                        _SetColor = new SolidColorBrush(Colors.Red);
467 abaa85b4 djkim
468 8c3a888c djkim
                        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 7ca218b3 KangIngu
473 8c3a888c djkim
                            mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER);
474
                            var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER);
475 7ca218b3 KangIngu
476 8c3a888c djkim
                            //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width;
477
                            //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height;
478 7ca218b3 KangIngu
479 8c3a888c djkim
                            //강인구 테스트
480
                            scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width;
481
                            scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height;
482 7ca218b3 KangIngu
483 8c3a888c djkim
                            if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height)
484
                            {
485
                                mediaBox = cropBox;
486
                            }
487 7ca218b3 KangIngu
488 8c3a888c djkim
                            pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER;
489
                            _entity.SaveChanges();
490 7ca218b3 KangIngu
491 8c3a888c djkim
                            string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
492 7ca218b3 KangIngu
493 8c3a888c djkim
                            PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER);
494 7ca218b3 KangIngu
495
496 8c3a888c djkim
                            foreach (var data in markedData)
497 abaa85b4 djkim
                            {
498 8c3a888c djkim
                                var item = JsonSerializerHelper.UnCompressString(data);
499
                                var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item);
500
501
                                try
502 7ca218b3 KangIngu
                                {
503 8c3a888c djkim
                                    switch (ControlT.Name)
504
                                    {
505
                                        #region LINE
506
                                        case "LineControl":
507 7ca218b3 KangIngu
                                            {
508 8c3a888c djkim
                                                using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item))
509 7ca218b3 KangIngu
                                                {
510 8c3a888c djkim
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
511
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
512
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
513
                                                    DoubleCollection DashSize = control.DashSize;
514
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
515
516
                                                    var Opacity = control.Opac;
517
                                                    string UserID = control.UserID;
518
                                                    double Interval = control.Interval;
519
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
520
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity);
521
                                                    switch (control.LineStyleSet)
522
                                                    {
523
                                                        case LineStyleSet.ArrowLine:
524
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
525
                                                            break;
526
                                                        case LineStyleSet.CancelLine:
527 7ca218b3 KangIngu
                                                            {
528 8c3a888c djkim
                                                                var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X)));
529
                                                                var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y)));
530
531
                                                                if (x > y)
532
                                                                {
533
                                                                    StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0));
534
                                                                    EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0));
535
                                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity);
536
                                                                }
537 7ca218b3 KangIngu
                                                            }
538 8c3a888c djkim
                                                            break;
539
                                                        case LineStyleSet.TwinLine:
540
                                                            {
541
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
542
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
543
                                                            }
544
                                                            break;
545
                                                        case LineStyleSet.DimLine:
546
                                                            {
547
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
548
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
549
                                                                Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
550
                                                            }
551
                                                            break;
552
                                                        default:
553
                                                            break;
554
                                                    }
555 7ca218b3 KangIngu
556
557 8c3a888c djkim
                                                }
558 7ca218b3 KangIngu
                                            }
559 8c3a888c djkim
                                            break;
560
                                        #endregion
561
                                        #region ArrowControlMulti
562
                                        case "ArrowControl_Multi":
563 abaa85b4 djkim
                                            {
564 8c3a888c djkim
                                                using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item))
565
                                                {
566
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
567
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
568
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
569
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
570
                                                    DoubleCollection DashSize = control.DashSize;
571
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
572
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
573 abaa85b4 djkim
574 8c3a888c djkim
                                                    double Opacity = control.Opac;
575 abaa85b4 djkim
576 8c3a888c djkim
                                                    if (EndPoint == MidPoint)
577
                                                    {
578
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
579
                                                    }
580
                                                    else
581
                                                    {
582
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
583
                                                    }
584 7ca218b3 KangIngu
585 8c3a888c djkim
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
586 abaa85b4 djkim
587 8c3a888c djkim
                                                }
588 7ca218b3 KangIngu
                                            }
589 8c3a888c djkim
                                            break;
590
                                        #endregion
591
                                        #region PolyControl
592
                                        case "PolygonControl":
593
                                            using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item))
594 7ca218b3 KangIngu
                                            {
595 abaa85b4 djkim
                                                string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
596
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
597
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
598
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
599
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
600 8c3a888c djkim
                                                double Opacity = control.Opac;
601
                                                DoubleCollection DashSize = control.DashSize;
602 abaa85b4 djkim
603
                                                Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
604
                                            }
605 8c3a888c djkim
                                            break;
606
                                        #endregion
607
                                        #region ArcControl
608
                                        case "ArcControl":
609 abaa85b4 djkim
                                            {
610 8c3a888c djkim
                                                using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item))
611 7ca218b3 KangIngu
                                                {
612 8c3a888c djkim
                                                    string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
613
                                                    Point StartPoint = GetPdfPointSystem(control.StartPoint);
614
                                                    Point EndPoint = GetPdfPointSystem(control.EndPoint);
615
                                                    Point MidPoint = GetPdfPointSystem(control.MidPoint);
616
                                                    DoubleCollection DashSize = control.DashSize;
617
                                                    List<Point> PointSet = GetPdfPointSystem(control.PointSet);
618
619
                                                    var Opacity = control.Opac;
620
                                                    string UserID = control.UserID;
621
                                                    double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()));
622
                                                    bool IsTransOn = control.IsTransOn;
623
624
                                                    if (control.IsTransOn)
625 abaa85b4 djkim
                                                    {
626 8c3a888c djkim
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
627
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true);
628 abaa85b4 djkim
                                                    }
629
                                                    else
630
                                                    {
631 8c3a888c djkim
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity);
632 abaa85b4 djkim
                                                    }
633 8c3a888c djkim
634 7ca218b3 KangIngu
                                                }
635
                                            }
636 8c3a888c djkim
                                            break;
637
                                        #endregion
638
                                        #region RectangleControl
639
                                        case "RectangleControl":
640
                                            using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item))
641 7ca218b3 KangIngu
                                            {
642 8c3a888c djkim
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
643
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
644
                                                var PaintStyle = control.PaintState;
645
                                                double Angle = control.Angle;
646
                                                DoubleCollection DashSize = control.DashSize;
647
                                                double Opacity = control.Opac;
648
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
649
650
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
651 7ca218b3 KangIngu
                                            }
652 8c3a888c djkim
                                            break;
653
                                        #endregion
654
                                        #region TriControl
655
                                        case "TriControl":
656
                                            using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item))
657 7ca218b3 KangIngu
                                            {
658 8c3a888c djkim
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
659
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
660
                                                var PaintStyle = control.Paint;
661
                                                double Angle = control.Angle;
662
                                                //StrokeColor = _SetColor, //색상은 레드
663
                                                DoubleCollection DashSize = control.DashSize;
664
                                                double Opacity = control.Opac;
665
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
666 7ca218b3 KangIngu
667 8c3a888c djkim
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity);
668 abaa85b4 djkim
                                            }
669 8c3a888c djkim
                                            break;
670
                                        #endregion
671
                                        #region CircleControl
672
                                        case "CircleControl":
673
                                            using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item))
674 abaa85b4 djkim
                                            {
675 8c3a888c djkim
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
676
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
677
                                                var StartPoint = GetPdfPointSystem(control.StartPoint);
678
                                                var EndPoint = GetPdfPointSystem(control.EndPoint);
679
                                                var PaintStyle = control.PaintState;
680
                                                double Angle = control.Angle;
681
                                                DoubleCollection DashSize = control.DashSize;
682
                                                double Opacity = control.Opac;
683
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
684
                                                Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet);
685
686 abaa85b4 djkim
                                            }
687 8c3a888c djkim
                                            break;
688
                                        #endregion
689
                                        #region RectCloudControl
690
                                        case "RectCloudControl":
691
                                            using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item))
692
                                            {
693
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
694
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
695
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
696
                                                double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
697 abaa85b4 djkim
698 8c3a888c djkim
                                                double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
699
700
                                                var PaintStyle = control.PaintState;
701
                                                double Opacity = control.Opac;
702
                                                DoubleCollection DashSize = control.DashSize;
703
704
                                                //드로잉 방식이 표현되지 않음
705
                                                var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint));
706
707
                                                double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
708
                                                bool reverse = (area < 0);
709
                                                if (PaintStyle == PaintSet.None)
710
                                                {
711
                                                    Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
712
                                                }
713
                                                else
714
                                                {
715
                                                    Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
716
                                                }
717
                                            }
718
                                            break;
719
                                        #endregion
720
                                        #region CloudControl
721
                                        case "CloudControl":
722
                                            using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item))
723 abaa85b4 djkim
                                            {
724 8c3a888c djkim
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
725
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
726
                                                double Toler = control.Toler;
727
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
728
                                                double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight);
729
                                                var PaintStyle = control.PaintState;
730
                                                double Opacity = control.Opac;
731
                                                bool isTransOn = control.IsTrans;
732
                                                bool isChain = control.IsChain;
733
734
                                                DoubleCollection DashSize = control.DashSize;
735
736
                                                if (isChain)
737
                                                {
738
                                                    Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);
739
                                                }
740
                                                else
741
                                                {
742
                                                    if (isTransOn)
743 abaa85b4 djkim
                                                    {
744 8c3a888c djkim
                                                        double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet));
745
                                                        bool reverse = (area < 0);
746
747
                                                        if (PaintStyle == PaintSet.None)
748
                                                        {
749
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
750
                                                        }
751
                                                        else
752
                                                        {
753
                                                            Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity);
754
                                                        }
755 abaa85b4 djkim
                                                    }
756 8c3a888c djkim
                                                    else
757 abaa85b4 djkim
                                                    {
758 8c3a888c djkim
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity);
759 abaa85b4 djkim
                                                    }
760 8c3a888c djkim
                                                }
761 abaa85b4 djkim
                                            }
762 8c3a888c djkim
                                            break;
763
                                        #endregion
764
                                        #region TEXT
765
                                        case "TextControl":
766
                                            using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
767 abaa85b4 djkim
                                            {
768 8c3a888c djkim
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
769
                                                string Text = control.Text;
770 abaa85b4 djkim
771 8c3a888c djkim
                                                bool isUnderline = false;
772
                                                control.BoxW -= scaleWidth;
773
                                                control.BoxH -= scaleHeight;
774
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH);
775
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
776
                                                Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH));
777
778
                                                List<Point> pointSet = new List<Point>();
779
                                                pointSet.Add(StartPoint);
780
                                                pointSet.Add(EndPoint);
781
782
                                                PaintSet paint = PaintSet.None;
783
                                                switch (control.paintMethod)
784 7ca218b3 KangIngu
                                                {
785 8c3a888c djkim
                                                    case 1:
786
                                                        {
787
                                                            paint = PaintSet.Fill;
788
                                                        }
789
                                                        break;
790
                                                    case 2:
791
                                                        {
792
                                                            paint = PaintSet.Hatch;
793
                                                        }
794
                                                        break;
795
                                                    default:
796
                                                        break;
797 7ca218b3 KangIngu
                                                }
798 8c3a888c djkim
                                                if (control.isHighLight) paint |= PaintSet.Highlight;
799 7ca218b3 KangIngu
800 8c3a888c djkim
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
801
                                                double TextSize = Convert.ToDouble(data2[1]);
802
                                                SolidColorBrush FontColor = _SetColor;
803
                                                double Angle = control.Angle;
804
                                                double Opacity = control.Opac;
805
                                                FontFamily fontfamilly = new FontFamily(control.fontConfig[0]);
806 7ca218b3 KangIngu
                                                var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
807
808
                                                FontStyle fontStyle = FontStyles.Normal;
809
                                                if (FontStyles.Italic == TextStyle)
810
                                                {
811
                                                    fontStyle = FontStyles.Italic;
812
                                                }
813
814
                                                FontWeight fontWeight = FontWeights.Black;
815
816
                                                var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
817 8c3a888c djkim
                                                //강인구 수정(2018.04.17)
818 d4b0c723 KangIngu
                                                if (FontWeights.Bold == TextWeight)
819 8c3a888c djkim
                                                //if (FontWeights.ExtraBold == TextWeight)
820 7ca218b3 KangIngu
                                                {
821
                                                    fontWeight = FontWeights.Bold;
822
                                                }
823
824
                                                TextDecorationCollection decoration = TextDecorations.Baseline;
825 8c3a888c djkim
                                                if (control.fontConfig.Count() == 4)
826 7ca218b3 KangIngu
                                                {
827
                                                    decoration = TextDecorations.Underline;
828
                                                }
829
830 8c3a888c djkim
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
831
                                            }
832
                                            break;
833
                                        #endregion
834
                                        #region ArrowTextControl
835
                                        case "ArrowTextControl":
836
                                            using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item))
837
                                            {
838
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
839
                                                Point tempStartPoint = GetPdfPointSystem(control.StartPoint);
840
                                                Point tempMidPoint = GetPdfPointSystem(control.MidPoint);
841
                                                Point tempEndPoint = GetPdfPointSystem(control.EndPoint);
842
                                                bool isUnderLine = false;
843
                                                string Text = "";
844
                                                double fontsize = 30;
845
846
                                                System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight);
847
                                                Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight));
848
                                                List<Point> tempPoint = new List<Point>();
849
850
                                                var tempRectMidPoint = MathSet.getRectMiddlePoint(rect);
851
852
                                                tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y));
853
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top));
854
                                                tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y));
855
                                                tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom));
856
                                                double Angle = control.Angle;
857
                                                var newStartPoint = tempStartPoint;
858
                                                var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint);
859
                                                var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint);
860
861
                                                double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()));
862
                                                SolidColorBrush FontColor = _SetColor;
863
                                                bool isHighlight = control.isHighLight;
864
                                                double Opacity = control.Opac;
865
                                                PaintSet Paint = PaintSet.None;
866
867
                                                switch (control.ArrowStyle)
868 7ca218b3 KangIngu
                                                {
869 8c3a888c djkim
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal:
870
                                                        {
871
                                                            Paint = PaintSet.None;
872
                                                        }
873
                                                        break;
874
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud:
875
                                                        {
876
                                                            Paint = PaintSet.Hatch;
877
                                                        }
878
                                                        break;
879
                                                    case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect:
880
                                                        {
881
                                                            Paint = PaintSet.Fill;
882
                                                        }
883
                                                        break;
884
                                                    default:
885
                                                        break;
886
                                                }
887
                                                if (control.isHighLight) Paint |= PaintSet.Highlight;
888
889
                                                if (Paint == PaintSet.Hatch)
890
                                                {
891
                                                    Text = control.ArrowText;
892 7ca218b3 KangIngu
                                                }
893
                                                else
894
                                                {
895 8c3a888c djkim
                                                    Text = control.ArrowText;
896
                                                }
897
898
                                                try
899
                                                {
900
                                                    if (control.fontConfig.Count == 4)
901 7ca218b3 KangIngu
                                                    {
902 8c3a888c djkim
                                                        fontsize = Convert.ToDouble(control.fontConfig[3]);
903 7ca218b3 KangIngu
                                                    }
904 8c3a888c djkim
905
                                                    //강인구 수정(2018.04.17)
906
                                                    var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]);
907
908
                                                    FontStyle fontStyle = FontStyles.Normal;
909
                                                    if (FontStyles.Italic == TextStyle)
910
                                                    {
911
                                                        fontStyle = FontStyles.Italic;
912
                                                    }
913
914
                                                    FontWeight fontWeight = FontWeights.Black;
915
916
                                                    var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]);
917
                                                    if (FontWeights.Bold == TextWeight)
918
                                                    {
919
                                                        fontWeight = FontWeights.Bold;
920
                                                    }
921
922
                                                    TextDecorationCollection decoration = TextDecorations.Baseline;
923
                                                    if (control.fontConfig.Count() == 5)
924
                                                    {
925
                                                        decoration = TextDecorations.Underline;
926
                                                    }
927
928
                                                    if (control.isTrans)
929 7ca218b3 KangIngu
                                                    {
930 f633b10b KangIngu
                                                        //인구 수정 Arrow Text Style적용 되도록 변경
931 abaa85b4 djkim
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
932 8c3a888c djkim
                                                            newStartPoint, tempMidPoint,
933 53eada70 humkyung
                                                            LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
934 4804a4fb humkyung
                                                    }
935 8c3a888c djkim
                                                    else
936
                                                    {
937
                                                        if (control.isFixed)
938
                                                        {
939
                                                            var testP = new Point(0, 0);
940
                                                            if (control.isFixed)
941
                                                            {
942
                                                                if (tempPoint[1] == newEndPoint)
943
                                                                {
944
                                                                    testP = new Point(newEndPoint.X, newEndPoint.Y - 10);
945
                                                                }
946
                                                                else if (tempPoint[3] == newEndPoint)
947
                                                                {
948
                                                                    testP = new Point(newEndPoint.X, newEndPoint.Y + 10);
949
                                                                }
950
                                                                else if (tempPoint[0] == newEndPoint)
951
                                                                {
952
                                                                    testP = new Point(newEndPoint.X - 10, newEndPoint.Y);
953
                                                                }
954
                                                                else if (tempPoint[2] == newEndPoint)
955
                                                                {
956
                                                                    testP = new Point(newEndPoint.X + 10, newEndPoint.Y);
957
                                                                }
958
                                                            }
959
                                                            //인구 수정 Arrow Text Style적용 되도록 변경
960
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
961
                                                                tempStartPoint, testP,
962
                                                                LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight,
963
                                                            new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
964
                                                        }
965
                                                        else
966
                                                        {
967
                                                            //인구 수정 Arrow Text Style적용 되도록 변경
968
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight),
969
                                                                newStartPoint, newMidPoint,
970
                                                                LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle);
971
                                                        }
972
                                                    }
973 f633b10b KangIngu
                                                }
974 8c3a888c djkim
                                                catch (Exception ex)
975
                                                {
976
977
                                                }
978
                                            }
979
                                            break;
980
                                        #endregion
981
                                        #region SignControl
982
                                        case "SignControl":
983
                                            using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item))
984
                                            {
985
986
                                                double Angle = control.Angle;
987
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
988
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
989
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
990
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
991
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
992
                                                double Opacity = control.Opac;
993
                                                string UserNumber = control.UserNumber;
994
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO);
995
                                            }
996
                                            break;
997
                                        #endregion
998
                                        #region MyRegion
999
                                        case "DateControl":
1000
                                            using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item))
1001
                                            {
1002
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1003
                                                string Text = control.Text;
1004
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1005
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1006
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1007
                                                SolidColorBrush FontColor = _SetColor;
1008
                                                double Angle = control.Angle;
1009
                                                double Opacity = control.Opac;
1010
                                                Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity);
1011
                                            }
1012
                                            break;
1013
                                        #endregion
1014
                                        #region SymControlN (APPROVED)
1015
                                        case "SymControlN":
1016
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1017
                                            {
1018
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1019
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1020
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1021
                                                SolidColorBrush FontColor = _SetColor;
1022
                                                double Angle = control.Angle;
1023
                                                double Opacity = control.Opac;
1024
1025
                                                string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", "");
1026
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1027 7ca218b3 KangIngu
                                            }
1028 8c3a888c djkim
                                            break;
1029
                                        case "SymControl":
1030
                                            using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item))
1031 7ca218b3 KangIngu
                                            {
1032 8c3a888c djkim
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1033
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1034
                                                List<Point> pointSet = GetPdfPointSystem(control.PointSet);
1035
                                                SolidColorBrush FontColor = _SetColor;
1036
                                                double Angle = control.Angle;
1037
                                                double Opacity = control.Opac;
1038 abaa85b4 djkim
1039 8c3a888c djkim
                                                string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", "");
1040
                                                Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath);
1041 7ca218b3 KangIngu
                                            }
1042 8c3a888c djkim
                                            break;
1043
                                        #endregion
1044
                                        #region Image
1045
                                        case "ImgControl":
1046
                                            using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item))
1047
                                            {
1048
                                                double Angle = control.Angle;
1049
                                                Point StartPoint = GetPdfPointSystem(control.StartPoint);
1050
                                                Point TopRightPoint = GetPdfPointSystem(control.TR);
1051
                                                Point EndPoint = GetPdfPointSystem(control.EndPoint);
1052
                                                Point LeftBottomPoint = GetPdfPointSystem(control.LB);
1053
                                                List<Point> PointSet = GetPdfPointSystem(control.PointSet);
1054
                                                double Opacity = control.Opac;
1055
                                                string FilePath = control.ImagePath;
1056
                                                //Uri uri = new Uri(s.ImagePath);
1057
1058
                                                Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity);
1059
                                            }
1060
                                            break;
1061
                                        #endregion
1062
                                        default:
1063
                                            break;
1064
                                    }
1065 7ca218b3 KangIngu
                                }
1066 8c3a888c djkim
                                catch (Exception ex)
1067
                                {
1068 abaa85b4 djkim
1069 8c3a888c djkim
                                }
1070 abaa85b4 djkim
                            }
1071 7ca218b3 KangIngu
                        }
1072 8c3a888c djkim
                        pdfStamper.Outlines = root;
1073
                        pdfStamper.Close();
1074
                        pdfReader.Close();
1075 abaa85b4 djkim
                    }
1076 7ca218b3 KangIngu
                }
1077 8c3a888c djkim
                #endregion
1078 7ca218b3 KangIngu
            }
1079
1080
            try
1081
            {
1082
                if (tempFileInfo.Exists)
1083
                {
1084
                    tempFileInfo.Delete();
1085
                }
1086
1087
                if (File.Exists(pdfFilePath))
1088
                {
1089
1090
                    FinalPDFPath = new FileInfo(pdfFilePath);
1091
1092 4a1073c1 humkyung
                    ///TODO : 복사할 경로를 configuration으로 빼주세요
1093 8c3a888c djkim
1094 e05bed4e djkim
                    string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", "");
1095
                    File.Move(FinalPDFPath.FullName, pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1096
                    FinalPDFPath = new FileInfo(pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf"));
1097 7ca218b3 KangIngu
1098
                    try
1099
                    {
1100
                        File.Delete(pdfFilePath);
1101
                    }
1102
                    catch (Exception ex)
1103
                    {
1104
                        System.Diagnostics.Debug.Write("삭제 불가" + ex.Message);
1105
                    }
1106
                    //
1107
1108
                    return true;
1109
                }
1110
            }
1111
            catch (Exception ex)
1112
            {
1113
1114
                throw;
1115
            }
1116
1117
            return false;
1118
        }
1119
1120
        public void Dispose()
1121
        {
1122
            throw new NotImplementedException();
1123 8c3a888c djkim
        }
1124 7f01e35f ljiyeon
1125 7ca218b3 KangIngu
        #endregion
1126
    }
1127
}
클립보드 이미지 추가 (최대 크기: 500 MB)