markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ bb3a236d
이력 | 보기 | 이력해설 | 다운로드 (68.2 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 | 3ad12023 | djkim | |
411 | 7ca218b3 | KangIngu | public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo) |
412 | { |
||
413 | string pdfFilePath = null; |
||
414 | 3ad12023 | djkim | List<MEMBER> memberlist = null; |
415 | 7ca218b3 | KangIngu | FileInfo tempFileInfo = new FileInfo(testFile); |
416 | |||
417 | if (!Directory.Exists(_FinalPDFStorgeLocal)) |
||
418 | { |
||
419 | Directory.CreateDirectory(_FinalPDFStorgeLocal); |
||
420 | } |
||
421 | pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name; |
||
422 | 3ad12023 | djkim | using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString())) |
423 | { |
||
424 | memberlist = cIEntities.MEMBER.ToList(); |
||
425 | } |
||
426 | 7ca218b3 | KangIngu | using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
427 | { |
||
428 | FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault(); |
||
429 | |||
430 | #region 코멘트 적용 + 커버시트 |
||
431 | using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) // |
||
432 | { |
||
433 | PdfReader pdfReader = new PdfReader(pdfStream); |
||
434 | //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>(); |
||
435 | Dictionary<string, object> bookmark; |
||
436 | List<Dictionary<string, object>> outlines; |
||
437 | outlines = new List<Dictionary<string, object>>(); |
||
438 | List<Dictionary<string, object>> root = new List<Dictionary<string, object>>(); |
||
439 | |||
440 | var dic = new Dictionary<string, object>(); |
||
441 | 3ad12023 | djkim | foreach (var data in MarkupDataSet) |
442 | { |
||
443 | |||
444 | string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID; |
||
445 | |||
446 | var member = memberlist.Where(u => u.ID == userid).FirstOrDefault(); |
||
447 | string username = member.NAME; |
||
448 | string userdept = member.DEPARTMENT; |
||
449 | bookmark = new Dictionary<string, object>(); |
||
450 | bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER)); |
||
451 | bookmark.Add("Page", data.PAGENUMBER + " Fit"); |
||
452 | bookmark.Add("Action", "GoTo"); |
||
453 | bookmark.Add("Kids", outlines); |
||
454 | root.Add(bookmark); |
||
455 | } |
||
456 | 7ca218b3 | KangIngu | |
457 | |||
458 | using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create))) |
||
459 | { |
||
460 | var _SetColor = new SolidColorBrush(Colors.Red); |
||
461 | |||
462 | string[] delimiterChars = { "|DZ|" }; |
||
463 | string[] delimiterChars2 = { "|" }; |
||
464 | |||
465 | //pdfStamper.FormFlattening = true; //이미 선처리 작업함 |
||
466 | pdfStamper.SetFullCompression(); |
||
467 | _SetColor = new SolidColorBrush(Colors.Red); |
||
468 | |||
469 | foreach (var markupItem in MarkupDataSet) |
||
470 | { |
||
471 | pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER); |
||
472 | var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault(); |
||
473 | |||
474 | mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER); |
||
475 | var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER); |
||
476 | |||
477 | //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width; |
||
478 | //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height; |
||
479 | |||
480 | //강인구 테스트 |
||
481 | scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
||
482 | scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
||
483 | |||
484 | f633b10b | KangIngu | if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height) |
485 | 7ca218b3 | KangIngu | { |
486 | mediaBox = cropBox; |
||
487 | } |
||
488 | |||
489 | pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER; |
||
490 | _entity.SaveChanges(); |
||
491 | |||
492 | string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
||
493 | |||
494 | PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER); |
||
495 | |||
496 | |||
497 | foreach (var data in markedData) |
||
498 | { |
||
499 | |||
500 | var item = JsonSerializerHelper.UnCompressString(data); |
||
501 | //item = data.Replace("H", "_h"); |
||
502 | var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); |
||
503 | |||
504 | try |
||
505 | { |
||
506 | switch (ControlT.Name) |
||
507 | { |
||
508 | #region LINE |
||
509 | case "LineControl": |
||
510 | { |
||
511 | using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item)) |
||
512 | { |
||
513 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
514 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
515 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
516 | DoubleCollection DashSize = control.DashSize; |
||
517 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
518 | |||
519 | var Opacity = control.Opac; |
||
520 | string UserID = control.UserID; |
||
521 | double Interval = control.Interval; |
||
522 | double LineSize = Convert.ToDouble(InnerData.First()); |
||
523 | Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity); |
||
524 | switch (control.LineStyleSet) |
||
525 | { |
||
526 | //case LineStyleSet.SingleLine: |
||
527 | // Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
||
528 | // break; |
||
529 | case LineStyleSet.ArrowLine: |
||
530 | //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
||
531 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
532 | break; |
||
533 | case LineStyleSet.CancelLine: |
||
534 | { |
||
535 | var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X))); |
||
536 | var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y))); |
||
537 | |||
538 | if (x > y) |
||
539 | { |
||
540 | StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0)); |
||
541 | EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0)); |
||
542 | Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity); |
||
543 | } |
||
544 | } |
||
545 | break; |
||
546 | case LineStyleSet.TwinLine: |
||
547 | { |
||
548 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
549 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
550 | //Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity); |
||
551 | } |
||
552 | break; |
||
553 | case LineStyleSet.DimLine: |
||
554 | { |
||
555 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
556 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
557 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
558 | } |
||
559 | break; |
||
560 | default: |
||
561 | break; |
||
562 | } |
||
563 | |||
564 | |||
565 | } |
||
566 | } |
||
567 | break; |
||
568 | #endregion |
||
569 | #region ArrowControlMulti |
||
570 | case "ArrowControl_Multi": |
||
571 | { |
||
572 | using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
||
573 | { |
||
574 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
575 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
576 | Point MidPoint = GetPdfPointSystem(control.MidPoint); |
||
577 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
578 | DoubleCollection DashSize = control.DashSize; |
||
579 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
580 | double LineSize = Convert.ToDouble(InnerData.First()); |
||
581 | |||
582 | double Opacity = control.Opac; |
||
583 | |||
584 | if (EndPoint == MidPoint) |
||
585 | { |
||
586 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
587 | } |
||
588 | else |
||
589 | { |
||
590 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
591 | } |
||
592 | |||
593 | Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
||
594 | |||
595 | } |
||
596 | } |
||
597 | break; |
||
598 | #endregion |
||
599 | #region PolyControl |
||
600 | case "PolygonControl": |
||
601 | using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize <S_PolyControl>(item)) |
||
602 | { |
||
603 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
604 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
605 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
606 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
607 | double LineSize = Convert.ToDouble(InnerData.First()); |
||
608 | double Opacity = control.Opac; |
||
609 | DoubleCollection DashSize = control.DashSize; |
||
610 | |||
611 | Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
||
612 | } |
||
613 | break; |
||
614 | #endregion |
||
615 | #region ArcControl |
||
616 | case "ArcControl": |
||
617 | { |
||
618 | using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
||
619 | { |
||
620 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
621 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
622 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
623 | Point MidPoint = GetPdfPointSystem(control.MidPoint); |
||
624 | DoubleCollection DashSize = control.DashSize; |
||
625 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
626 | |||
627 | var Opacity = control.Opac; |
||
628 | string UserID = control.UserID; |
||
629 | double LineSize = Convert.ToDouble(InnerData.First()); |
||
630 | bool IsTransOn = control.IsTransOn; |
||
631 | |||
632 | if (control.IsTransOn) |
||
633 | { |
||
634 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
||
635 | Controls_PDF.HoneyPDFLib_DrawSet_Arrow.ConverseAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
||
636 | } |
||
637 | else |
||
638 | { |
||
639 | Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
||
640 | } |
||
641 | |||
642 | } |
||
643 | } |
||
644 | break; |
||
645 | #endregion |
||
646 | #region RectangleControl |
||
647 | case "RectangleControl": |
||
648 | using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
||
649 | { |
||
650 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
651 | double LineSize = Convert.ToDouble(data2.First()); |
||
652 | var PaintStyle = control.PaintState; |
||
653 | double Angle = control.Angle; |
||
654 | DoubleCollection DashSize = control.DashSize; |
||
655 | double Opacity = control.Opac; |
||
656 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
657 | 66128b37 | humkyung | |
658 | 7ca218b3 | KangIngu | Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
659 | } |
||
660 | break; |
||
661 | #endregion |
||
662 | #region TriControl |
||
663 | case "TriControl": |
||
664 | using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item)) |
||
665 | { |
||
666 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
667 | double LineSize = Convert.ToDouble(data2.First()); |
||
668 | var PaintStyle = control.Paint; |
||
669 | double Angle = control.Angle; |
||
670 | //StrokeColor = _SetColor, //색상은 레드 |
||
671 | DoubleCollection DashSize = control.DashSize; |
||
672 | double Opacity = control.Opac; |
||
673 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
674 | |||
675 | Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
||
676 | } |
||
677 | break; |
||
678 | #endregion |
||
679 | #region CircleControl |
||
680 | case "CircleControl": |
||
681 | using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
||
682 | { |
||
683 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
684 | double LineSize = Convert.ToDouble(data2.First()); |
||
685 | var StartPoint = GetPdfPointSystem(control.StartPoint); |
||
686 | var EndPoint = GetPdfPointSystem(control.EndPoint); |
||
687 | var PaintStyle = control.PaintState; |
||
688 | double Angle = control.Angle; |
||
689 | DoubleCollection DashSize = control.DashSize; |
||
690 | double Opacity = control.Opac; |
||
691 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
692 | Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
||
693 | |||
694 | } |
||
695 | break; |
||
696 | #endregion |
||
697 | #region RectCloudControl |
||
698 | case "RectCloudControl": |
||
699 | using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
||
700 | { |
||
701 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
702 | double LineSize = Convert.ToDouble(data2.First()); |
||
703 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
704 | 53393bae | KangIngu | //double ArcLength = 30; |
705 | 7ca218b3 | KangIngu | double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
706 | f633b10b | KangIngu | |
707 | 53393bae | KangIngu | |
708 | double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength; |
||
709 | |||
710 | 7ca218b3 | KangIngu | var PaintStyle = control.PaintState; |
711 | double Opacity = control.Opac; |
||
712 | DoubleCollection DashSize = control.DashSize; |
||
713 | |||
714 | //드로잉 방식이 표현되지 않음 |
||
715 | var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
||
716 | |||
717 | double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
||
718 | bool reverse = (area < 0); |
||
719 | if (PaintStyle == PaintSet.None) |
||
720 | { |
||
721 | 66128b37 | humkyung | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
722 | 7ca218b3 | KangIngu | } |
723 | else |
||
724 | { |
||
725 | 66128b37 | humkyung | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
726 | 7ca218b3 | KangIngu | } |
727 | } |
||
728 | break; |
||
729 | #endregion |
||
730 | #region CloudControl |
||
731 | case "CloudControl": |
||
732 | using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
||
733 | { |
||
734 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
735 | double LineSize = Convert.ToDouble(data2.First()); |
||
736 | double Toler = control.Toler; |
||
737 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
738 | 53393bae | KangIngu | double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength; |
739 | 7ca218b3 | KangIngu | var PaintStyle = control.PaintState; |
740 | double Opacity = control.Opac; |
||
741 | bool isTransOn = control.IsTrans; |
||
742 | bool isChain = control.IsChain; |
||
743 | |||
744 | DoubleCollection DashSize = control.DashSize; |
||
745 | |||
746 | if (isChain) |
||
747 | { |
||
748 | Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
||
749 | } |
||
750 | else |
||
751 | { |
||
752 | if (isTransOn) |
||
753 | { |
||
754 | double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
||
755 | bool reverse = (area < 0); |
||
756 | |||
757 | if (PaintStyle == PaintSet.None) |
||
758 | { |
||
759 | 66128b37 | humkyung | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
760 | 7ca218b3 | KangIngu | } |
761 | else |
||
762 | { |
||
763 | 66128b37 | humkyung | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
764 | 7ca218b3 | KangIngu | } |
765 | } |
||
766 | else |
||
767 | { |
||
768 | Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
||
769 | } |
||
770 | } |
||
771 | } |
||
772 | break; |
||
773 | #endregion |
||
774 | #region TEXT |
||
775 | case "TextControl": |
||
776 | using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
||
777 | { |
||
778 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
779 | 10df01b4 | humkyung | string Text = control.Text; |
780 | 7ca218b3 | KangIngu | |
781 | bool isUnderline = false; |
||
782 | control.BoxW -= scaleWidth; |
||
783 | control.BoxH -= scaleHeight; |
||
784 | System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH); |
||
785 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
786 | Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH)); |
||
787 | |||
788 | List<Point> pointSet = new List<Point>(); |
||
789 | pointSet.Add(StartPoint); |
||
790 | pointSet.Add(EndPoint); |
||
791 | |||
792 | PaintSet paint = PaintSet.None; |
||
793 | switch (control.paintMethod) |
||
794 | { |
||
795 | case 1: |
||
796 | { |
||
797 | paint = PaintSet.Fill; |
||
798 | } |
||
799 | break; |
||
800 | case 2: |
||
801 | { |
||
802 | paint = PaintSet.Hatch; |
||
803 | } |
||
804 | break; |
||
805 | default: |
||
806 | break; |
||
807 | } |
||
808 | 488ba687 | humkyung | if (control.isHighLight) paint |= PaintSet.Highlight; |
809 | 7ca218b3 | KangIngu | |
810 | double LineSize = Convert.ToDouble(data2.First()); |
||
811 | double TextSize = Convert.ToDouble(data2[1]); |
||
812 | SolidColorBrush FontColor = _SetColor; |
||
813 | double Angle = control.Angle; |
||
814 | double Opacity = control.Opac; |
||
815 | FontFamily fontfamilly = new FontFamily(control.fontConfig[0]); |
||
816 | var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
||
817 | |||
818 | FontStyle fontStyle = FontStyles.Normal; |
||
819 | if (FontStyles.Italic == TextStyle) |
||
820 | { |
||
821 | fontStyle = FontStyles.Italic; |
||
822 | } |
||
823 | |||
824 | FontWeight fontWeight = FontWeights.Black; |
||
825 | |||
826 | var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
||
827 | d4b0c723 | KangIngu | //강인구 수정(2018.04.17) |
828 | if (FontWeights.Bold == TextWeight) |
||
829 | //if (FontWeights.ExtraBold == TextWeight) |
||
830 | 7ca218b3 | KangIngu | { |
831 | fontWeight = FontWeights.Bold; |
||
832 | } |
||
833 | |||
834 | TextDecorationCollection decoration = TextDecorations.Baseline; |
||
835 | if (control.fontConfig.Count() == 4) |
||
836 | { |
||
837 | decoration = TextDecorations.Underline; |
||
838 | } |
||
839 | |||
840 | if (LineSize <= 3) |
||
841 | { |
||
842 | LineSize = 3; |
||
843 | } |
||
844 | |||
845 | 23b7be0e | humkyung | Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
846 | 7ca218b3 | KangIngu | } |
847 | break; |
||
848 | #endregion |
||
849 | #region ArrowTextControl |
||
850 | case "ArrowTextControl": |
||
851 | using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
||
852 | { |
||
853 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
854 | Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
||
855 | Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
||
856 | Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
||
857 | bool isUnderLine = false; |
||
858 | string Text = ""; |
||
859 | 488ba687 | humkyung | double fontsize = 30; |
860 | 7ca218b3 | KangIngu | |
861 | System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
||
862 | Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
||
863 | List<Point> tempPoint = new List<Point>(); |
||
864 | |||
865 | var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
||
866 | |||
867 | tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
||
868 | tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
||
869 | tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
||
870 | tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
||
871 | double Angle = control.Angle; |
||
872 | var newStartPoint = tempStartPoint; |
||
873 | var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
||
874 | var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
||
875 | |||
876 | double LineSize = Convert.ToDouble(data2.First()); |
||
877 | SolidColorBrush FontColor = _SetColor; |
||
878 | bool isHighlight = control.isHighLight; |
||
879 | double Opacity = control.Opac; |
||
880 | PaintSet Paint = PaintSet.None; |
||
881 | |||
882 | switch (control.ArrowStyle) |
||
883 | { |
||
884 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
||
885 | { |
||
886 | Paint = PaintSet.None; |
||
887 | } |
||
888 | break; |
||
889 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
||
890 | { |
||
891 | Paint = PaintSet.Hatch; |
||
892 | } |
||
893 | break; |
||
894 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
||
895 | { |
||
896 | Paint = PaintSet.Fill; |
||
897 | } |
||
898 | break; |
||
899 | default: |
||
900 | break; |
||
901 | } |
||
902 | 488ba687 | humkyung | if (control.isHighLight) Paint |= PaintSet.Highlight; |
903 | 7ca218b3 | KangIngu | |
904 | if (Paint == PaintSet.Hatch) |
||
905 | { |
||
906 | 10df01b4 | humkyung | Text = control.ArrowText; |
907 | 7ca218b3 | KangIngu | } |
908 | else |
||
909 | { |
||
910 | 10df01b4 | humkyung | Text = control.ArrowText; |
911 | 7ca218b3 | KangIngu | } |
912 | |||
913 | try |
||
914 | { |
||
915 | if (control.fontConfig.Count == 4) |
||
916 | { |
||
917 | 488ba687 | humkyung | fontsize = Convert.ToDouble(control.fontConfig[3]); |
918 | 7ca218b3 | KangIngu | } |
919 | f633b10b | KangIngu | |
920 | //강인구 수정(2018.04.17) |
||
921 | var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
||
922 | |||
923 | FontStyle fontStyle = FontStyles.Normal; |
||
924 | if (FontStyles.Italic == TextStyle) |
||
925 | { |
||
926 | fontStyle = FontStyles.Italic; |
||
927 | } |
||
928 | |||
929 | FontWeight fontWeight = FontWeights.Black; |
||
930 | |||
931 | var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
||
932 | if (FontWeights.Bold == TextWeight) |
||
933 | { |
||
934 | fontWeight = FontWeights.Bold; |
||
935 | } |
||
936 | |||
937 | TextDecorationCollection decoration = TextDecorations.Baseline; |
||
938 | if (control.fontConfig.Count() == 5) |
||
939 | { |
||
940 | decoration = TextDecorations.Underline; |
||
941 | } |
||
942 | |||
943 | 7ca218b3 | KangIngu | if (control.isTrans) |
944 | { |
||
945 | f633b10b | KangIngu | //인구 수정 Arrow Text Style적용 되도록 변경 |
946 | 53eada70 | humkyung | Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
947 | newStartPoint, tempMidPoint, |
||
948 | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
||
949 | 7ca218b3 | KangIngu | } |
950 | else |
||
951 | { |
||
952 | if (control.isFixed) |
||
953 | { |
||
954 | var testP = new Point(0, 0); |
||
955 | if (control.isFixed) |
||
956 | { |
||
957 | if (tempPoint[1] == newEndPoint) |
||
958 | { |
||
959 | testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
||
960 | } |
||
961 | else if (tempPoint[3] == newEndPoint) |
||
962 | { |
||
963 | testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
||
964 | } |
||
965 | else if (tempPoint[0] == newEndPoint) |
||
966 | { |
||
967 | testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
||
968 | } |
||
969 | else if (tempPoint[2] == newEndPoint) |
||
970 | { |
||
971 | testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
||
972 | } |
||
973 | } |
||
974 | f633b10b | KangIngu | //인구 수정 Arrow Text Style적용 되도록 변경 |
975 | 53eada70 | humkyung | Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
976 | tempStartPoint, testP, |
||
977 | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
||
978 | f633b10b | KangIngu | new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
979 | 7ca218b3 | KangIngu | } |
980 | else |
||
981 | { |
||
982 | f633b10b | KangIngu | //인구 수정 Arrow Text Style적용 되도록 변경 |
983 | 53eada70 | humkyung | Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
984 | newStartPoint, newMidPoint, |
||
985 | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
||
986 | f633b10b | KangIngu | |
987 | |||
988 | } |
||
989 | } |
||
990 | |||
991 | } |
||
992 | catch (Exception ex) |
||
993 | { |
||
994 | |||
995 | 7ca218b3 | KangIngu | } |
996 | } |
||
997 | break; |
||
998 | #endregion |
||
999 | #region SignControl |
||
1000 | case "SignControl": |
||
1001 | using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
||
1002 | { |
||
1003 | |||
1004 | double Angle = control.Angle; |
||
1005 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1006 | Point TopRightPoint = GetPdfPointSystem(control.TR); |
||
1007 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1008 | Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
||
1009 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1010 | double Opacity = control.Opac; |
||
1011 | string UserNumber = control.UserNumber; |
||
1012 | Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
||
1013 | } |
||
1014 | break; |
||
1015 | #endregion |
||
1016 | #region MyRegion |
||
1017 | case "DateControl": |
||
1018 | using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
||
1019 | { |
||
1020 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1021 | string Text = control.Text; |
||
1022 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1023 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1024 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1025 | SolidColorBrush FontColor = _SetColor; |
||
1026 | double Angle = control.Angle; |
||
1027 | double Opacity = control.Opac; |
||
1028 | Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
||
1029 | } |
||
1030 | break; |
||
1031 | #endregion |
||
1032 | #region SymControlN (APPROVED) |
||
1033 | case "SymControlN": |
||
1034 | using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
||
1035 | { |
||
1036 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1037 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1038 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1039 | SolidColorBrush FontColor = _SetColor; |
||
1040 | double Angle = control.Angle; |
||
1041 | double Opacity = control.Opac; |
||
1042 | e05bed4e | djkim | |
1043 | string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
||
1044 | Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
||
1045 | 7ca218b3 | KangIngu | } |
1046 | break; |
||
1047 | 4899d460 | djkim | case "SymControl": |
1048 | using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
||
1049 | { |
||
1050 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1051 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1052 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1053 | SolidColorBrush FontColor = _SetColor; |
||
1054 | double Angle = control.Angle; |
||
1055 | double Opacity = control.Opac; |
||
1056 | e05bed4e | djkim | |
1057 | 1684a18d | djkim | string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
1058 | e05bed4e | djkim | Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
1059 | 4899d460 | djkim | } |
1060 | break; |
||
1061 | 7ca218b3 | KangIngu | #endregion |
1062 | #region Image |
||
1063 | case "ImgControl": |
||
1064 | using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
||
1065 | { |
||
1066 | double Angle = control.Angle; |
||
1067 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1068 | Point TopRightPoint = GetPdfPointSystem(control.TR); |
||
1069 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1070 | Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
||
1071 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1072 | double Opacity = control.Opac; |
||
1073 | string FilePath = control.ImagePath; |
||
1074 | //Uri uri = new Uri(s.ImagePath); |
||
1075 | |||
1076 | Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
||
1077 | } |
||
1078 | break; |
||
1079 | #endregion |
||
1080 | default: |
||
1081 | break; |
||
1082 | } |
||
1083 | } |
||
1084 | catch (Exception ex) |
||
1085 | { |
||
1086 | |||
1087 | } |
||
1088 | } |
||
1089 | } |
||
1090 | pdfStamper.Outlines = root; |
||
1091 | pdfStamper.Close(); |
||
1092 | pdfReader.Close(); |
||
1093 | 53393bae | KangIngu | } |
1094 | 7ca218b3 | KangIngu | } |
1095 | #endregion |
||
1096 | } |
||
1097 | |||
1098 | try |
||
1099 | { |
||
1100 | if (tempFileInfo.Exists) |
||
1101 | { |
||
1102 | tempFileInfo.Delete(); |
||
1103 | } |
||
1104 | |||
1105 | if (File.Exists(pdfFilePath)) |
||
1106 | { |
||
1107 | |||
1108 | FinalPDFPath = new FileInfo(pdfFilePath); |
||
1109 | |||
1110 | 4a1073c1 | humkyung | ///TODO : 복사할 경로를 configuration으로 빼주세요 |
1111 | e05bed4e | djkim | |
1112 | string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
||
1113 | File.Move(FinalPDFPath.FullName, pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
||
1114 | FinalPDFPath = new FileInfo(pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
||
1115 | 7ca218b3 | KangIngu | |
1116 | try |
||
1117 | { |
||
1118 | File.Delete(pdfFilePath); |
||
1119 | } |
||
1120 | catch (Exception ex) |
||
1121 | { |
||
1122 | System.Diagnostics.Debug.Write("삭제 불가" + ex.Message); |
||
1123 | } |
||
1124 | // |
||
1125 | |||
1126 | return true; |
||
1127 | } |
||
1128 | } |
||
1129 | catch (Exception ex) |
||
1130 | { |
||
1131 | |||
1132 | throw; |
||
1133 | } |
||
1134 | |||
1135 | return false; |
||
1136 | } |
||
1137 | |||
1138 | public void Dispose() |
||
1139 | { |
||
1140 | throw new NotImplementedException(); |
||
1141 | e05bed4e | djkim | } |
1142 | 7f01e35f | ljiyeon | |
1143 | 7ca218b3 | KangIngu | #endregion |
1144 | } |
||
1145 | } |