프로젝트

일반

사용자정보

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

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

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