프로젝트

일반

사용자정보

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

markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 00aa0bf5

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