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