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