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