프로젝트

일반

사용자정보

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

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

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