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