markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 4f017ed3
이력 | 보기 | 이력해설 | 다운로드 (84.9 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 | c206d293 | taeseongkim | using Markus.Fonts; |
9 | 7ca218b3 | KangIngu | using System; |
10 | using System.Collections.Generic; |
||
11 | 7f01e35f | ljiyeon | using System.Configuration; |
12 | 7ca218b3 | KangIngu | using System.IO; |
13 | using System.Linq; |
||
14 | using System.Net; |
||
15 | 7f01e35f | ljiyeon | using System.Runtime.InteropServices; |
16 | 7ca218b3 | KangIngu | using System.Text; |
17 | e05bed4e | djkim | using System.Web; |
18 | 7ca218b3 | KangIngu | using System.Windows; |
19 | using System.Windows.Media; |
||
20 | |||
21 | namespace MarkupToPDF |
||
22 | { |
||
23 | public class MarkupToPDF : IDisposable |
||
24 | { |
||
25 | #region 초기 데이터 |
||
26 | private static iTextSharp.text.Rectangle mediaBox; |
||
27 | private FileInfo PdfFilePath = null; |
||
28 | private FileInfo FinalPDFPath = null; |
||
29 | private string _FinalPDFStorgeLocal = null; |
||
30 | private string _FinalPDFStorgeRemote = null; |
||
31 | private string OriginFileName = null; |
||
32 | 8c3a888c | djkim | public FINAL_PDF FinalItem; |
33 | public DOCINFO DocInfoItem = null; |
||
34 | public List<DOCPAGE> DocPageItem = null; |
||
35 | public MARKUP_INFO MarkupInfoItem = null; |
||
36 | public List<MARKUP_DATA> MarkupDataSet = null; |
||
37 | 7ca218b3 | KangIngu | //private string _PrintPDFStorgeLocal = null; |
38 | //private string _PrintPDFStorgeRemote = null; |
||
39 | public event EventHandler<MakeFinalErrorArgs> FinalMakeError; |
||
40 | public event EventHandler<EndFinalEventArgs> EndFinal; |
||
41 | ab590000 | taeseongkim | public event EventHandler<StatusChangedEventArgs> StatusChanged; |
42 | 7ca218b3 | KangIngu | |
43 | private iTextSharp.text.Rectangle pdfSize { get; set; } |
||
44 | private double pageW = 0; |
||
45 | private double pageH = 0; |
||
46 | |||
47 | //private const double zoomLevel = 3.0; |
||
48 | private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음 |
||
49 | #endregion |
||
50 | |||
51 | #region 메서드 |
||
52 | public static bool IsLocalIPAddress(string host) |
||
53 | { |
||
54 | try |
||
55 | { |
||
56 | IPAddress[] hostIPs = Dns.GetHostAddresses(host); |
||
57 | IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); |
||
58 | |||
59 | foreach (IPAddress hostIP in hostIPs) |
||
60 | { |
||
61 | if (IPAddress.IsLoopback(hostIP)) return true; |
||
62 | |||
63 | foreach (IPAddress localIP in localIPs) |
||
64 | { |
||
65 | if (hostIP.Equals(localIP)) return true; |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 | catch { } |
||
70 | return false; |
||
71 | } |
||
72 | |||
73 | 8c3a888c | djkim | private void SetNotice(string finalID, string message) |
74 | 7ca218b3 | KangIngu | { |
75 | if (FinalMakeError != null) |
||
76 | { |
||
77 | FinalMakeError(this, new MakeFinalErrorArgs { FinalID = finalID, Message = message }); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | private string GetFileName(string hrefLink) |
||
82 | { |
||
83 | e05bed4e | djkim | try |
84 | { |
||
85 | if (hrefLink.Contains("vpcs_doclib")) |
||
86 | { |
||
87 | return System.IO.Path.GetFileName(hrefLink.Replace("/", "\\")); |
||
88 | } |
||
89 | else |
||
90 | { |
||
91 | Uri fileurl = new Uri(hrefLink); |
||
92 | int index = hrefLink.IndexOf("?"); |
||
93 | string filename = HttpUtility.ParseQueryString(fileurl.Query).Get("fileName"); |
||
94 | return filename; |
||
95 | } |
||
96 | } |
||
97 | catch (Exception ex) |
||
98 | { |
||
99 | throw ex; |
||
100 | } |
||
101 | 7ca218b3 | KangIngu | } |
102 | |||
103 | public Point GetPdfPointSystem(Point point) |
||
104 | { |
||
105 | 9dec2e0a | humkyung | /// 주어진 좌표를 pdf의 (Left, Top - Bottom(?)) 좌표에 맞추어 변환한다. |
106 | 9ced2402 | djkim | /// Rotation 90 일 경우 pdfsize box 와 media box 가 달라 다른 계산식 적용 |
107 | if (pdfSize.Rotation == 90) |
||
108 | { |
||
109 | return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Top - (float)(point.Y / scaleHeight) - pdfSize.Bottom); |
||
110 | } |
||
111 | else |
||
112 | { |
||
113 | return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight) + pdfSize.Bottom); |
||
114 | } |
||
115 | 7ca218b3 | KangIngu | } |
116 | |||
117 | 488ba687 | humkyung | public double GetPdfSize(double size) |
118 | { |
||
119 | return (size / scaleWidth); |
||
120 | } |
||
121 | |||
122 | 8c3a888c | djkim | public List<Point> GetPdfPointSystem(List<Point> point) |
123 | 7ca218b3 | KangIngu | { |
124 | List<Point> dummy = new List<Point>(); |
||
125 | foreach (var item in point) |
||
126 | { |
||
127 | dummy.Add(GetPdfPointSystem(item)); |
||
128 | } |
||
129 | return dummy; |
||
130 | } |
||
131 | |||
132 | public double returnAngle(Point start, Point end) |
||
133 | { |
||
134 | double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y); |
||
135 | //angle *= -1; |
||
136 | |||
137 | angle += 90; |
||
138 | //if (angle < 0) |
||
139 | //{ |
||
140 | // angle = angle + 360; |
||
141 | //} |
||
142 | return angle; |
||
143 | } |
||
144 | |||
145 | #endregion |
||
146 | |||
147 | c206d293 | taeseongkim | public bool AddStamp(string stampData) |
148 | { |
||
149 | bool result = false; |
||
150 | |||
151 | try |
||
152 | { |
||
153 | using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
154 | { |
||
155 | var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
||
156 | |||
157 | if(stamp.Count() > 0) |
||
158 | { |
||
159 | var xamldata = Serialize.Core.JsonSerializerHelper.CompressStamp(stampData); |
||
160 | |||
161 | stamp.First().VALUE = xamldata; |
||
162 | _entity.SaveChanges(); |
||
163 | result = true; |
||
164 | } |
||
165 | } |
||
166 | } |
||
167 | catch (Exception) |
||
168 | { |
||
169 | |||
170 | throw; |
||
171 | } |
||
172 | |||
173 | return result; |
||
174 | |||
175 | } |
||
176 | |||
177 | 077fb153 | taeseongkim | /// <summary> |
178 | /// local에서 final 생성하는 경우 이 함수로 추가 후 실행 |
||
179 | /// </summary> |
||
180 | /// <param name="finalpdf"></param> |
||
181 | /// <returns></returns> |
||
182 | public AddFinalPDFResult AddFinalPDF(string ProjectNo,string DocumentID,string UserID) |
||
183 | { |
||
184 | c206d293 | taeseongkim | //var list = Markus.Fonts.FontHelper.GetFontStream("Arial Unicode MS"); |
185 | //System.Diagnostics.Debug.WriteLine(list); |
||
186 | |||
187 | 077fb153 | taeseongkim | AddFinalPDFResult result = new AddFinalPDFResult { Success = false }; |
188 | |||
189 | try |
||
190 | { |
||
191 | FINAL_PDF addItem = new FINAL_PDF{ |
||
192 | ID = CommonLib.Guid.shortGuid(), |
||
193 | PROJECT_NO = ProjectNo, |
||
194 | DOCUMENT_ID = DocumentID, |
||
195 | CREATE_USER_ID = UserID, |
||
196 | CREATE_DATETIME = DateTime.Now, |
||
197 | STATUS = 4 |
||
198 | }; |
||
199 | |||
200 | using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(ProjectNo).ToString())) |
||
201 | { |
||
202 | var docitems = _entity.DOCINFO.Where(x => x.PROJECT_NO == ProjectNo && x.DOCUMENT_ID == DocumentID); |
||
203 | |||
204 | if(docitems.Count() > 0) |
||
205 | { |
||
206 | addItem.DOCINFO_ID = docitems.First().ID; |
||
207 | result.Success = true; |
||
208 | } |
||
209 | else |
||
210 | { |
||
211 | result.Exception = "docInfo Not Found."; |
||
212 | result.Success = false; |
||
213 | } |
||
214 | |||
215 | var markupInfoItems = _entity.MARKUP_INFO.Where(x =>x.DOCINFO_ID == addItem.DOCINFO_ID); |
||
216 | |||
217 | if (markupInfoItems.Count() > 0) |
||
218 | { |
||
219 | addItem.MARKUPINFO_ID = markupInfoItems.First().ID; |
||
220 | result.Success = true; |
||
221 | } |
||
222 | else |
||
223 | { |
||
224 | result.Exception = "Markup Info Not Found."; |
||
225 | result.Success = false; |
||
226 | } |
||
227 | } |
||
228 | |||
229 | if (result.Success) |
||
230 | { |
||
231 | using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
||
232 | { |
||
233 | var finalList = _entity.FINAL_PDF.Where(final => final.ID == addItem.ID); |
||
234 | |||
235 | /// Insrt and Update |
||
236 | if (finalList.Count() == 0) |
||
237 | { |
||
238 | _entity.FINAL_PDF.AddObject(addItem); |
||
239 | _entity.SaveChanges(); |
||
240 | |||
241 | result.FinalPDF = addItem; |
||
242 | result.Success = true; |
||
243 | } |
||
244 | } |
||
245 | } |
||
246 | } |
||
247 | catch (Exception ex) |
||
248 | { |
||
249 | System.Diagnostics.Debug.WriteLine(ex); |
||
250 | result.Success = false; |
||
251 | } |
||
252 | |||
253 | return result; |
||
254 | } |
||
255 | |||
256 | 7ca218b3 | KangIngu | #region 생성자 & 소멸자 |
257 | public void MakeFinalPDF(object _FinalPDF) |
||
258 | { |
||
259 | 8c3a888c | djkim | DOCUMENT_ITEM documentItem; |
260 | FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF; |
||
261 | 7ca218b3 | KangIngu | FinalItem = FinalPDF; |
262 | |||
263 | |||
264 | string PdfFilePathRoot = null; |
||
265 | string TestFile = System.IO.Path.GetTempFileName(); |
||
266 | |||
267 | #region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정 |
||
268 | 488ba687 | humkyung | try |
269 | 7ca218b3 | KangIngu | { |
270 | 8c3a888c | djkim | using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
271 | 7ca218b3 | KangIngu | { |
272 | 8c3a888c | djkim | var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO); |
273 | |||
274 | if (_properties.Count() > 0) |
||
275 | 7ca218b3 | KangIngu | { |
276 | 077fb153 | taeseongkim | if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0) |
277 | { |
||
278 | SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : TileSourcePath Not Found."); |
||
279 | return; |
||
280 | } |
||
281 | else |
||
282 | { |
||
283 | PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE; |
||
284 | } |
||
285 | |||
286 | if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).Count() == 0) |
||
287 | { |
||
288 | SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeLocal Not Found."); |
||
289 | return; |
||
290 | } |
||
291 | else |
||
292 | { |
||
293 | _FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE; |
||
294 | } |
||
295 | |||
296 | |||
297 | if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).Count() == 0) |
||
298 | { |
||
299 | SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeRemote Not Found."); |
||
300 | return; |
||
301 | } |
||
302 | else |
||
303 | { |
||
304 | _FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE; |
||
305 | } |
||
306 | 7ca218b3 | KangIngu | } |
307 | else |
||
308 | { |
||
309 | 077fb153 | taeseongkim | SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : Final PDF Properties Not Found."); |
310 | 7ca218b3 | KangIngu | return; |
311 | } |
||
312 | 077fb153 | taeseongkim | |
313 | e0f00e26 | djkim | var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
314 | 077fb153 | taeseongkim | |
315 | 8c3a888c | djkim | if (finalList.Count() > 0) |
316 | { |
||
317 | finalList.FirstOrDefault().START_DATETIME = DateTime.Now; |
||
318 | finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create; |
||
319 | _entity.SaveChanges(); |
||
320 | } |
||
321 | e0f00e26 | djkim | |
322 | 8c3a888c | djkim | } |
323 | 7ca218b3 | KangIngu | } |
324 | catch (Exception ex) |
||
325 | { |
||
326 | SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString()); |
||
327 | return; |
||
328 | } |
||
329 | #endregion |
||
330 | |||
331 | #region 문서 복사 |
||
332 | try |
||
333 | { |
||
334 | 8c3a888c | djkim | using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString())) |
335 | 7ca218b3 | KangIngu | { |
336 | 8c3a888c | djkim | var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID); |
337 | 7ca218b3 | KangIngu | |
338 | 8c3a888c | djkim | if (_DOCINFO.Count() > 0) |
339 | 7ca218b3 | KangIngu | { |
340 | 8c3a888c | djkim | DocInfoItem = _DOCINFO.FirstOrDefault(); |
341 | DocPageItem = DocInfoItem.DOCPAGE.ToList(); |
||
342 | 7ca218b3 | KangIngu | |
343 | PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\" |
||
344 | a371522c | humkyung | + (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5)) |
345 | 7ca218b3 | KangIngu | + @"\" + FinalPDF.DOCUMENT_ID + @"\"; |
346 | |||
347 | 8c3a888c | djkim | MarkupInfoItem = DocInfoItem.MARKUP_INFO.Where(data => data.CONSOLIDATE == 1 && data.AVOID_CONSOLIDATE == 0 && data.PART_CONSOLIDATE == 0).FirstOrDefault(); |
348 | 7ca218b3 | KangIngu | |
349 | if (MarkupInfoItem == null) |
||
350 | { |
||
351 | throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
||
352 | } |
||
353 | else |
||
354 | { |
||
355 | 8c3a888c | djkim | if (MarkupInfoItem.MARKUP_INFO_VERSION.Count > 0) |
356 | { |
||
357 | MarkupDataSet = MarkupInfoItem.MARKUP_INFO_VERSION.OrderBy(d => d.CREATE_DATE).LastOrDefault().MARKUP_DATA.ToList().OrderBy(d => d.PAGENUMBER).ToList(); |
||
358 | } |
||
359 | else |
||
360 | 7ca218b3 | KangIngu | { |
361 | throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
||
362 | 8c3a888c | djkim | } |
363 | 6c9fec59 | djkim | } |
364 | 7ca218b3 | KangIngu | |
365 | 645f6f94 | djkim | documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault(); |
366 | e0f00e26 | djkim | if (documentItem == null) |
367 | 6c9fec59 | djkim | { |
368 | e0f00e26 | djkim | throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
369 | } |
||
370 | 8c3a888c | djkim | |
371 | e0f00e26 | djkim | var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 |
372 | 8c3a888c | djkim | |
373 | e0f00e26 | djkim | #region 파일 체크 |
374 | if (_files.Count() == 1) |
||
375 | { |
||
376 | ff01c725 | humkyung | /// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정 |
377 | //if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
||
378 | //{ |
||
379 | e0f00e26 | djkim | OriginFileName = _files.First().Name; |
380 | PdfFilePath = _files.First().CopyTo(TestFile, true); |
||
381 | c206d293 | taeseongkim | StatusChange($"Copy File file Count = 1 : {PdfFilePath}", 0); |
382 | ff01c725 | humkyung | //} |
383 | //else |
||
384 | //{ |
||
385 | // throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()); |
||
386 | //} |
||
387 | e0f00e26 | djkim | } |
388 | else if (_files.Count() > 1) |
||
389 | { |
||
390 | var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault(); |
||
391 | 6c9fec59 | djkim | |
392 | e0f00e26 | djkim | if (originalFile == null) |
393 | 8c3a888c | djkim | { |
394 | e0f00e26 | djkim | throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
395 | 8c3a888c | djkim | } |
396 | e0f00e26 | djkim | else |
397 | 8c3a888c | djkim | { |
398 | e0f00e26 | djkim | OriginFileName = originalFile.Name; |
399 | PdfFilePath = originalFile.CopyTo(TestFile, true); |
||
400 | c206d293 | taeseongkim | StatusChange($"Copy File file Count > 1 : {PdfFilePath}", 0); |
401 | 8c3a888c | djkim | } |
402 | 6c9fec59 | djkim | } |
403 | e0f00e26 | djkim | else |
404 | { |
||
405 | cbea3c14 | humkyung | throw new FileNotFoundException("PDF를 찾지 못하였습니다"); |
406 | e0f00e26 | djkim | } |
407 | #endregion |
||
408 | |||
409 | #region 예외처리 |
||
410 | if (PdfFilePath == null) |
||
411 | { |
||
412 | throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
||
413 | } |
||
414 | if (!PdfFilePath.Exists) |
||
415 | { |
||
416 | throw new Exception("PDF원본이 존재하지 않습니다"); |
||
417 | } |
||
418 | #endregion |
||
419 | |||
420 | 7ca218b3 | KangIngu | } |
421 | else |
||
422 | { |
||
423 | throw new Exception("일치하는 DocInfo가 없습니다"); |
||
424 | } |
||
425 | } |
||
426 | } |
||
427 | catch (Exception ex) |
||
428 | { |
||
429 | if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다") |
||
430 | { |
||
431 | SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
||
432 | System.Diagnostics.Process process = new System.Diagnostics.Process(); |
||
433 | process.StartInfo.FileName = "cmd"; |
||
434 | process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\""; |
||
435 | process.Start(); |
||
436 | } |
||
437 | else |
||
438 | { |
||
439 | SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message); |
||
440 | } |
||
441 | } |
||
442 | #endregion |
||
443 | |||
444 | try |
||
445 | { |
||
446 | |||
447 | 8c3a888c | djkim | using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
448 | { |
||
449 | var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
||
450 | |||
451 | if (finalList.Count() > 0) |
||
452 | 7ca218b3 | KangIngu | { |
453 | c206d293 | taeseongkim | //TestFile = SetFlattingPDF(TestFile); |
454 | //StatusChange($"SetFlattingPDF : {TestFile}", 0); |
||
455 | |||
456 | 8c3a888c | djkim | SetStampInPDF(FinalItem, TestFile, MarkupInfoItem); |
457 | c206d293 | taeseongkim | |
458 | StatusChange($"SetStampInPDF : {TestFile}", 0); |
||
459 | 7ca218b3 | KangIngu | } |
460 | 8c3a888c | djkim | } |
461 | if (EndFinal != null) |
||
462 | { |
||
463 | EndFinal(this, new EndFinalEventArgs |
||
464 | { |
||
465 | OriginPDFName = OriginFileName, |
||
466 | FinalPDFPath = FinalPDFPath.FullName, |
||
467 | Error = "", |
||
468 | Message = "", |
||
469 | FinalPDF = FinalPDF, |
||
470 | }); |
||
471 | } |
||
472 | 7ca218b3 | KangIngu | } |
473 | catch (Exception ex) |
||
474 | { |
||
475 | 782ad7b1 | taeseongkim | SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message); |
476 | 7ca218b3 | KangIngu | } |
477 | } |
||
478 | #endregion |
||
479 | |||
480 | #region PDF |
||
481 | 4804a4fb | humkyung | public static float scaleWidth = 0; |
482 | public static float scaleHeight = 0; |
||
483 | 8c3a888c | djkim | |
484 | 7ca218b3 | KangIngu | private string SetFlattingPDF(string tempFileInfo) |
485 | { |
||
486 | if (File.Exists(tempFileInfo)) |
||
487 | { |
||
488 | FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName()); |
||
489 | |||
490 | PdfReader pdfReader = new PdfReader(tempFileInfo); |
||
491 | c206d293 | taeseongkim | |
492 | dc0bfdad | djkim | for (int i = 1; i <= pdfReader.NumberOfPages; i++) |
493 | 7ca218b3 | KangIngu | { |
494 | var mediaBox = pdfReader.GetPageSize(i); |
||
495 | var cropbox = pdfReader.GetCropBox(i); |
||
496 | |||
497 | 8c3a888c | djkim | //using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString())) |
498 | //{ |
||
499 | // _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE) |
||
500 | //} |
||
501 | 7ca218b3 | KangIngu | var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault(); |
502 | |||
503 | 8c3a888c | djkim | //scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width; |
504 | //scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height; |
||
505 | //scaleWidth = 2.0832634F; |
||
506 | //scaleHeight = 3.0F; |
||
507 | |||
508 | 7ca218b3 | KangIngu | PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i)); |
509 | 8c3a888c | djkim | //강인구 수정 |
510 | //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height)) |
||
511 | //if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height)) |
||
512 | //{ |
||
513 | // var pageDict = pdfReader.GetPageN(i); |
||
514 | // pageDict.Put(PdfName.MEDIABOX, rect); |
||
515 | //} |
||
516 | 7ca218b3 | KangIngu | } |
517 | |||
518 | var memStream = new MemoryStream(); |
||
519 | var stamper = new PdfStamper(pdfReader, memStream) |
||
520 | { |
||
521 | dc0bfdad | djkim | FormFlattening = true, |
522 | //FreeTextFlattening = true, |
||
523 | //AnnotationFlattening = true, |
||
524 | 7ca218b3 | KangIngu | }; |
525 | dc0bfdad | djkim | |
526 | 7ca218b3 | KangIngu | stamper.Close(); |
527 | pdfReader.Close(); |
||
528 | var array = memStream.ToArray(); |
||
529 | File.Delete(tempFileInfo); |
||
530 | File.WriteAllBytes(TestFile.FullName, array); |
||
531 | |||
532 | return TestFile.FullName; |
||
533 | } |
||
534 | else |
||
535 | { |
||
536 | return tempFileInfo; |
||
537 | } |
||
538 | } |
||
539 | |||
540 | public void flattenPdfFile(string src, ref string dest) |
||
541 | { |
||
542 | PdfReader reader = new PdfReader(src); |
||
543 | var memStream = new MemoryStream(); |
||
544 | var stamper = new PdfStamper(reader, memStream) |
||
545 | { |
||
546 | FormFlattening = true, |
||
547 | FreeTextFlattening = true, |
||
548 | AnnotationFlattening = true, |
||
549 | }; |
||
550 | |||
551 | stamper.Close(); |
||
552 | var array = memStream.ToArray(); |
||
553 | File.WriteAllBytes(dest, array); |
||
554 | } |
||
555 | 8c3a888c | djkim | |
556 | ab590000 | taeseongkim | public void StatusChange(string message,int CurrentPage) |
557 | { |
||
558 | if(StatusChanged != null) |
||
559 | { |
||
560 | c206d293 | taeseongkim | var sb = new StringBuilder(); |
561 | sb.AppendLine(message); |
||
562 | |||
563 | StatusChanged(null, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = sb.ToString() }); |
||
564 | ab590000 | taeseongkim | } |
565 | } |
||
566 | |||
567 | 8c3a888c | djkim | public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo) |
568 | 7ca218b3 | KangIngu | { |
569 | e0f00e26 | djkim | try |
570 | 8c3a888c | djkim | { |
571 | faebcce2 | taeseongkim | |
572 | e0f00e26 | djkim | FileInfo tempFileInfo = new FileInfo(testFile); |
573 | abaa85b4 | djkim | |
574 | e0f00e26 | djkim | if (!Directory.Exists(_FinalPDFStorgeLocal)) |
575 | 8c3a888c | djkim | { |
576 | e0f00e26 | djkim | Directory.CreateDirectory(_FinalPDFStorgeLocal); |
577 | } |
||
578 | cbea3c14 | humkyung | string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name); |
579 | faebcce2 | taeseongkim | |
580 | |||
581 | e0f00e26 | djkim | using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
582 | { |
||
583 | FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault(); |
||
584 | 7ca218b3 | KangIngu | |
585 | e0f00e26 | djkim | #region 코멘트 적용 + 커버시트 |
586 | using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) // |
||
587 | 8c3a888c | djkim | { |
588 | ab590000 | taeseongkim | StatusChange("comment Cover",0); |
589 | faebcce2 | taeseongkim | |
590 | e0f00e26 | djkim | PdfReader pdfReader = new PdfReader(pdfStream); |
591 | //List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>(); |
||
592 | Dictionary<string, object> bookmark; |
||
593 | List<Dictionary<string, object>> outlines; |
||
594 | faebcce2 | taeseongkim | |
595 | e0f00e26 | djkim | outlines = new List<Dictionary<string, object>>(); |
596 | List<Dictionary<string, object>> root = new List<Dictionary<string, object>>(); |
||
597 | |||
598 | var dic = new Dictionary<string, object>(); |
||
599 | faebcce2 | taeseongkim | |
600 | e0f00e26 | djkim | foreach (var data in MarkupDataSet) |
601 | { |
||
602 | ab590000 | taeseongkim | StatusChange("MarkupDataSet", 0); |
603 | abaa85b4 | djkim | |
604 | e0f00e26 | djkim | string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID; |
605 | |||
606 | faebcce2 | taeseongkim | string username = ""; |
607 | string userdept = ""; |
||
608 | |||
609 | using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString())) |
||
610 | { |
||
611 | var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid); |
||
612 | |||
613 | if(memberlist.Count() > 0) |
||
614 | { |
||
615 | username = memberlist.First().NAME; |
||
616 | userdept = memberlist.First().DEPARTMENT; |
||
617 | } |
||
618 | } |
||
619 | |||
620 | e0f00e26 | djkim | bookmark = new Dictionary<string, object>(); |
621 | bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER)); |
||
622 | bookmark.Add("Page", data.PAGENUMBER + " Fit"); |
||
623 | bookmark.Add("Action", "GoTo"); |
||
624 | bookmark.Add("Kids", outlines); |
||
625 | root.Add(bookmark); |
||
626 | } |
||
627 | abaa85b4 | djkim | |
628 | |||
629 | e0f00e26 | djkim | using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create))) |
630 | 8c3a888c | djkim | { |
631 | c206d293 | taeseongkim | AcroFields pdfFormFields = pdfStamper.AcroFields; |
632 | 782ad7b1 | taeseongkim | |
633 | try |
||
634 | { |
||
635 | if (pdfFormFields.GenerateAppearances != true) |
||
636 | { |
||
637 | pdfFormFields.GenerateAppearances = true; |
||
638 | } |
||
639 | } |
||
640 | catch (Exception ex) |
||
641 | { |
||
642 | SetNotice(FinalItem.ID, "this pdf is not AcroForm."); |
||
643 | } |
||
644 | c206d293 | taeseongkim | |
645 | e0f00e26 | djkim | var _SetColor = new SolidColorBrush(Colors.Red); |
646 | 7ca218b3 | KangIngu | |
647 | e0f00e26 | djkim | string[] delimiterChars = { "|DZ|" }; |
648 | string[] delimiterChars2 = { "|" }; |
||
649 | 7ca218b3 | KangIngu | |
650 | e0f00e26 | djkim | //pdfStamper.FormFlattening = true; //이미 선처리 작업함 |
651 | pdfStamper.SetFullCompression(); |
||
652 | _SetColor = new SolidColorBrush(Colors.Red); |
||
653 | 7ca218b3 | KangIngu | |
654 | e0f00e26 | djkim | foreach (var markupItem in MarkupDataSet) |
655 | 8c3a888c | djkim | { |
656 | 2e1d6c99 | djkim | pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER); |
657 | e0f00e26 | djkim | var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault(); |
658 | 7ca218b3 | KangIngu | |
659 | e0f00e26 | djkim | mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER); |
660 | 2e1d6c99 | djkim | var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER); |
661 | 7ca218b3 | KangIngu | |
662 | 7aa36857 | humkyung | /// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다 |
663 | if (cropBox != null && |
||
664 | (cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom)) |
||
665 | 2e1d6c99 | djkim | { |
666 | 7aa36857 | humkyung | PdfDictionary dict = pdfReader.GetPageN(markupItem.PAGENUMBER); |
667 | |||
668 | PdfArray oNewMediaBox = new PdfArray(); |
||
669 | oNewMediaBox.Add(new PdfNumber(cropBox.Left)); |
||
670 | oNewMediaBox.Add(new PdfNumber(cropBox.Top)); |
||
671 | oNewMediaBox.Add(new PdfNumber(cropBox.Right)); |
||
672 | oNewMediaBox.Add(new PdfNumber(cropBox.Bottom)); |
||
673 | dict.Put(PdfName.MEDIABOX, oNewMediaBox); |
||
674 | |||
675 | 2e1d6c99 | djkim | pdfSize = cropBox; |
676 | } |
||
677 | e0f00e26 | djkim | scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
678 | scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
||
679 | 7ca218b3 | KangIngu | |
680 | e0f00e26 | djkim | pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER; |
681 | _entity.SaveChanges(); |
||
682 | 8c3a888c | djkim | |
683 | e0f00e26 | djkim | string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
684 | |||
685 | PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER); |
||
686 | |||
687 | |||
688 | foreach (var data in markedData) |
||
689 | 7ca218b3 | KangIngu | { |
690 | e0f00e26 | djkim | var item = JsonSerializerHelper.UnCompressString(data); |
691 | var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); |
||
692 | |||
693 | try |
||
694 | 8c3a888c | djkim | { |
695 | e0f00e26 | djkim | switch (ControlT.Name) |
696 | { |
||
697 | #region LINE |
||
698 | case "LineControl": |
||
699 | 7ca218b3 | KangIngu | { |
700 | e0f00e26 | djkim | using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item)) |
701 | 8c3a888c | djkim | { |
702 | 4f017ed3 | taeseongkim | DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
703 | e0f00e26 | djkim | } |
704 | 8c3a888c | djkim | } |
705 | e0f00e26 | djkim | break; |
706 | #endregion |
||
707 | #region ArrowControlMulti |
||
708 | case "ArrowControl_Multi": |
||
709 | 8c3a888c | djkim | { |
710 | e0f00e26 | djkim | using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
711 | { |
||
712 | 4f017ed3 | taeseongkim | DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
713 | e0f00e26 | djkim | } |
714 | 8c3a888c | djkim | } |
715 | e0f00e26 | djkim | break; |
716 | #endregion |
||
717 | #region PolyControl |
||
718 | case "PolygonControl": |
||
719 | using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item)) |
||
720 | 7ca218b3 | KangIngu | { |
721 | 8c3a888c | djkim | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
722 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
723 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
724 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
725 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
726 | e0f00e26 | djkim | double Opacity = control.Opac; |
727 | DoubleCollection DashSize = control.DashSize; |
||
728 | 8c3a888c | djkim | |
729 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
730 | 8c3a888c | djkim | } |
731 | e0f00e26 | djkim | break; |
732 | #endregion |
||
733 | c206d293 | taeseongkim | #region ArcControl or ArrowArcControl |
734 | e0f00e26 | djkim | case "ArcControl": |
735 | c206d293 | taeseongkim | case "ArrowArcControl": |
736 | 8c3a888c | djkim | { |
737 | e0f00e26 | djkim | using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
738 | abaa85b4 | djkim | { |
739 | e0f00e26 | djkim | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
740 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
741 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
742 | Point MidPoint = GetPdfPointSystem(control.MidPoint); |
||
743 | DoubleCollection DashSize = control.DashSize; |
||
744 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
745 | |||
746 | var Opacity = control.Opac; |
||
747 | string UserID = control.UserID; |
||
748 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
749 | bool IsTransOn = control.IsTransOn; |
||
750 | |||
751 | if (control.IsTransOn) |
||
752 | 8c3a888c | djkim | { |
753 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
754 | Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
||
755 | 8c3a888c | djkim | } |
756 | else |
||
757 | { |
||
758 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
759 | 8c3a888c | djkim | } |
760 | e0f00e26 | djkim | |
761 | c206d293 | taeseongkim | if (ControlT.Name == "ArrowArcControl") |
762 | { |
||
763 | Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
||
764 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
||
765 | } |
||
766 | abaa85b4 | djkim | } |
767 | 8c3a888c | djkim | } |
768 | e0f00e26 | djkim | break; |
769 | #endregion |
||
770 | #region RectangleControl |
||
771 | case "RectangleControl": |
||
772 | using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
||
773 | 7ca218b3 | KangIngu | { |
774 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
775 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
776 | var PaintStyle = control.PaintState; |
||
777 | double Angle = control.Angle; |
||
778 | DoubleCollection DashSize = control.DashSize; |
||
779 | double Opacity = control.Opac; |
||
780 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
781 | |||
782 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
783 | 7ca218b3 | KangIngu | } |
784 | e0f00e26 | djkim | break; |
785 | #endregion |
||
786 | #region TriControl |
||
787 | case "TriControl": |
||
788 | using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item)) |
||
789 | 7ca218b3 | KangIngu | { |
790 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
791 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
792 | var PaintStyle = control.Paint; |
||
793 | double Angle = control.Angle; |
||
794 | //StrokeColor = _SetColor, //색상은 레드 |
||
795 | DoubleCollection DashSize = control.DashSize; |
||
796 | double Opacity = control.Opac; |
||
797 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
798 | 7ca218b3 | KangIngu | |
799 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
800 | 7ca218b3 | KangIngu | } |
801 | e0f00e26 | djkim | break; |
802 | #endregion |
||
803 | #region CircleControl |
||
804 | case "CircleControl": |
||
805 | using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
||
806 | 7ca218b3 | KangIngu | { |
807 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
808 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
809 | var StartPoint = GetPdfPointSystem(control.StartPoint); |
||
810 | var EndPoint = GetPdfPointSystem(control.EndPoint); |
||
811 | var PaintStyle = control.PaintState; |
||
812 | double Angle = control.Angle; |
||
813 | DoubleCollection DashSize = control.DashSize; |
||
814 | double Opacity = control.Opac; |
||
815 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
816 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
817 | e0f00e26 | djkim | |
818 | 7ca218b3 | KangIngu | } |
819 | e0f00e26 | djkim | break; |
820 | #endregion |
||
821 | #region RectCloudControl |
||
822 | case "RectCloudControl": |
||
823 | using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
||
824 | { |
||
825 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
826 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
827 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
828 | double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
||
829 | |||
830 | double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
||
831 | |||
832 | var PaintStyle = control.PaintState; |
||
833 | double Opacity = control.Opac; |
||
834 | DoubleCollection DashSize = control.DashSize; |
||
835 | 7ca218b3 | KangIngu | |
836 | e0f00e26 | djkim | //드로잉 방식이 표현되지 않음 |
837 | var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
||
838 | |||
839 | double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
||
840 | bool reverse = (area < 0); |
||
841 | if (PaintStyle == PaintSet.None) |
||
842 | { |
||
843 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
844 | } |
||
845 | else |
||
846 | { |
||
847 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
848 | } |
||
849 | } |
||
850 | break; |
||
851 | #endregion |
||
852 | #region CloudControl |
||
853 | case "CloudControl": |
||
854 | using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
||
855 | 7ca218b3 | KangIngu | { |
856 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
857 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
858 | double Toler = control.Toler; |
||
859 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
860 | double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
||
861 | var PaintStyle = control.PaintState; |
||
862 | double Opacity = control.Opac; |
||
863 | bool isTransOn = control.IsTrans; |
||
864 | bool isChain = control.IsChain; |
||
865 | |||
866 | DoubleCollection DashSize = control.DashSize; |
||
867 | |||
868 | if (isChain) |
||
869 | { |
||
870 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
871 | e0f00e26 | djkim | } |
872 | else |
||
873 | { |
||
874 | if (isTransOn) |
||
875 | 8c3a888c | djkim | { |
876 | e0f00e26 | djkim | double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
877 | bool reverse = (area < 0); |
||
878 | |||
879 | if (PaintStyle == PaintSet.None) |
||
880 | { |
||
881 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
882 | } |
||
883 | else |
||
884 | { |
||
885 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
886 | } |
||
887 | 8c3a888c | djkim | } |
888 | e0f00e26 | djkim | else |
889 | 8c3a888c | djkim | { |
890 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
891 | 8c3a888c | djkim | } |
892 | e0f00e26 | djkim | } |
893 | 7ca218b3 | KangIngu | } |
894 | e0f00e26 | djkim | break; |
895 | #endregion |
||
896 | #region TEXT |
||
897 | case "TextControl": |
||
898 | using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
||
899 | 7ca218b3 | KangIngu | { |
900 | 4f017ed3 | taeseongkim | DrawTextBox(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
901 | } |
||
902 | break; |
||
903 | #endregion |
||
904 | #region ArrowTextControl |
||
905 | case "ArrowTextControl": |
||
906 | using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
||
907 | { |
||
908 | //using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
||
909 | //{ |
||
910 | // textcontrol.Angle = control.Angle; |
||
911 | // textcontrol.BoxH = control.BoxHeight; |
||
912 | // textcontrol.BoxW = control.BoxWidth; |
||
913 | // textcontrol.EndPoint = control.EndPoint; |
||
914 | // textcontrol.FontColor = "#FFFF0000"; |
||
915 | // textcontrol.Name = "TextControl"; |
||
916 | // textcontrol.Opac = control.Opac; |
||
917 | // textcontrol.PointSet = new List<Point>(); |
||
918 | // textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]); |
||
919 | // textcontrol.StartPoint = control.StartPoint; |
||
920 | // textcontrol.Text = control.ArrowText; |
||
921 | // textcontrol.TransformPoint = control.TransformPoint; |
||
922 | // textcontrol.UserID = null; |
||
923 | // textcontrol.fontConfig = control.fontConfig; |
||
924 | // textcontrol.isHighLight = control.isHighLight; |
||
925 | // textcontrol.paintMethod = 1; |
||
926 | |||
927 | // DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
||
928 | //} |
||
929 | |||
930 | //using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
||
931 | //{ |
||
932 | // linecontrol.Angle = control.Angle; |
||
933 | // linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 }); |
||
934 | // linecontrol.EndPoint = control.EndPoint; |
||
935 | // linecontrol.MidPoint = control.MidPoint; |
||
936 | // linecontrol.Name = "ArrowControl_Multi"; |
||
937 | // linecontrol.Opac = control.Opac; |
||
938 | // linecontrol.PointSet = control.PointSet; |
||
939 | // linecontrol.SizeSet = control.SizeSet; |
||
940 | // linecontrol.StartPoint = control.StartPoint; |
||
941 | // linecontrol.StrokeColor = control.StrokeColor; |
||
942 | // linecontrol.TransformPoint = control.TransformPoint; |
||
943 | |||
944 | // DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
||
945 | //} |
||
946 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
947 | Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
||
948 | Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
||
949 | Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
||
950 | bool isUnderLine = false; |
||
951 | string Text = ""; |
||
952 | double fontsize = 30; |
||
953 | |||
954 | System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
||
955 | Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
||
956 | List<Point> tempPoint = new List<Point>(); |
||
957 | |||
958 | double Angle = control.Angle; |
||
959 | |||
960 | if (Math.Abs(Angle).ToString() == "90") |
||
961 | { |
||
962 | Angle = 270; |
||
963 | } |
||
964 | else if (Math.Abs(Angle).ToString() == "270") |
||
965 | { |
||
966 | Angle = 90; |
||
967 | } |
||
968 | 8c3a888c | djkim | |
969 | 4f017ed3 | taeseongkim | var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
970 | tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
||
971 | tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
||
972 | tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
||
973 | tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
||
974 | |||
975 | var newStartPoint = tempStartPoint; |
||
976 | var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
||
977 | var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
||
978 | |||
979 | //Point testPoint = tempEndPoint; |
||
980 | //if (Angle != 0) |
||
981 | //{ |
||
982 | // testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed); |
||
983 | // //testPoint = Test(rect, newMidPoint); |
||
984 | //} |
||
985 | |||
986 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
987 | SolidColorBrush FontColor = _SetColor; |
||
988 | bool isHighlight = control.isHighLight; |
||
989 | double Opacity = control.Opac; |
||
990 | PaintSet Paint = PaintSet.None; |
||
991 | |||
992 | switch (control.ArrowStyle) |
||
993 | { |
||
994 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
||
995 | { |
||
996 | Paint = PaintSet.None; |
||
997 | } |
||
998 | break; |
||
999 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
||
1000 | { |
||
1001 | Paint = PaintSet.Hatch; |
||
1002 | } |
||
1003 | break; |
||
1004 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
||
1005 | { |
||
1006 | Paint = PaintSet.Fill; |
||
1007 | } |
||
1008 | break; |
||
1009 | default: |
||
1010 | break; |
||
1011 | } |
||
1012 | if (control.isHighLight) Paint |= PaintSet.Highlight; |
||
1013 | e0f00e26 | djkim | |
1014 | 4f017ed3 | taeseongkim | if (Paint == PaintSet.Hatch) |
1015 | { |
||
1016 | Text = control.ArrowText; |
||
1017 | } |
||
1018 | else |
||
1019 | { |
||
1020 | Text = control.ArrowText; |
||
1021 | } |
||
1022 | e0f00e26 | djkim | |
1023 | 4f017ed3 | taeseongkim | try |
1024 | { |
||
1025 | if (control.fontConfig.Count == 4) |
||
1026 | 7ca218b3 | KangIngu | { |
1027 | 4f017ed3 | taeseongkim | fontsize = Convert.ToDouble(control.fontConfig[3]); |
1028 | 7ca218b3 | KangIngu | } |
1029 | 8c3a888c | djkim | |
1030 | 4f017ed3 | taeseongkim | //강인구 수정(2018.04.17) |
1031 | 8c3a888c | djkim | var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
1032 | 4f017ed3 | taeseongkim | |
1033 | 8c3a888c | djkim | FontStyle fontStyle = FontStyles.Normal; |
1034 | if (FontStyles.Italic == TextStyle) |
||
1035 | { |
||
1036 | fontStyle = FontStyles.Italic; |
||
1037 | } |
||
1038 | |||
1039 | FontWeight fontWeight = FontWeights.Black; |
||
1040 | |||
1041 | var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
||
1042 | if (FontWeights.Bold == TextWeight) |
||
1043 | { |
||
1044 | fontWeight = FontWeights.Bold; |
||
1045 | } |
||
1046 | |||
1047 | TextDecorationCollection decoration = TextDecorations.Baseline; |
||
1048 | 4f017ed3 | taeseongkim | if (control.fontConfig.Count() == 5) |
1049 | 8c3a888c | djkim | { |
1050 | decoration = TextDecorations.Underline; |
||
1051 | } |
||
1052 | |||
1053 | 4f017ed3 | taeseongkim | if (control.isTrans) |
1054 | e0f00e26 | djkim | { |
1055 | 4f017ed3 | taeseongkim | //인구 수정 Arrow Text Style적용 되도록 변경 |
1056 | Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
||
1057 | newStartPoint, tempMidPoint, newEndPoint, control.isFixed, |
||
1058 | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
||
1059 | 4804a4fb | humkyung | } |
1060 | 8c3a888c | djkim | else |
1061 | { |
||
1062 | 4f017ed3 | taeseongkim | if (control.isFixed) |
1063 | e0f00e26 | djkim | { |
1064 | 4f017ed3 | taeseongkim | var testP = new Point(0, 0); |
1065 | e0f00e26 | djkim | if (control.isFixed) |
1066 | { |
||
1067 | 4f017ed3 | taeseongkim | if (tempPoint[1] == newEndPoint) |
1068 | e0f00e26 | djkim | { |
1069 | 4f017ed3 | taeseongkim | testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
1070 | } |
||
1071 | else if (tempPoint[3] == newEndPoint) |
||
1072 | { |
||
1073 | testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
||
1074 | } |
||
1075 | else if (tempPoint[0] == newEndPoint) |
||
1076 | { |
||
1077 | testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
||
1078 | } |
||
1079 | else if (tempPoint[2] == newEndPoint) |
||
1080 | { |
||
1081 | testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
||
1082 | e0f00e26 | djkim | } |
1083 | } |
||
1084 | 4f017ed3 | taeseongkim | //인구 수정 Arrow Text Style적용 되도록 변경 |
1085 | Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
||
1086 | tempStartPoint, testP, tempEndPoint, control.isFixed, |
||
1087 | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
||
1088 | FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
||
1089 | } |
||
1090 | else |
||
1091 | { |
||
1092 | //인구 수정 Arrow Text Style적용 되도록 변경 |
||
1093 | Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
||
1094 | newStartPoint, tempMidPoint, tempEndPoint, control.isFixed, |
||
1095 | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
||
1096 | e0f00e26 | djkim | } |
1097 | 8c3a888c | djkim | } |
1098 | 4f017ed3 | taeseongkim | } |
1099 | catch (Exception ex) |
||
1100 | { |
||
1101 | throw ex; |
||
1102 | } |
||
1103 | |||
1104 | e0f00e26 | djkim | } |
1105 | break; |
||
1106 | #endregion |
||
1107 | #region SignControl |
||
1108 | case "SignControl": |
||
1109 | using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
||
1110 | { |
||
1111 | |||
1112 | double Angle = control.Angle; |
||
1113 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1114 | Point TopRightPoint = GetPdfPointSystem(control.TR); |
||
1115 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1116 | Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
||
1117 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1118 | double Opacity = control.Opac; |
||
1119 | string UserNumber = control.UserNumber; |
||
1120 | 16fe076c | humkyung | Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
1121 | e0f00e26 | djkim | } |
1122 | break; |
||
1123 | #endregion |
||
1124 | #region MyRegion |
||
1125 | case "DateControl": |
||
1126 | using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
||
1127 | { |
||
1128 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1129 | string Text = control.Text; |
||
1130 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1131 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1132 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1133 | SolidColorBrush FontColor = _SetColor; |
||
1134 | double Angle = control.Angle; |
||
1135 | double Opacity = control.Opac; |
||
1136 | c206d293 | taeseongkim | Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
1137 | f633b10b | KangIngu | } |
1138 | e0f00e26 | djkim | break; |
1139 | #endregion |
||
1140 | #region SymControlN (APPROVED) |
||
1141 | case "SymControlN": |
||
1142 | using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
||
1143 | 8c3a888c | djkim | { |
1144 | e0f00e26 | djkim | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1145 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1146 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1147 | SolidColorBrush FontColor = _SetColor; |
||
1148 | double Angle = control.Angle; |
||
1149 | double Opacity = control.Opac; |
||
1150 | |||
1151 | c206d293 | taeseongkim | var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
1152 | |||
1153 | if (stamp.Count() > 0) |
||
1154 | { |
||
1155 | var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE); |
||
1156 | |||
1157 | Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata); |
||
1158 | } |
||
1159 | |||
1160 | e0f00e26 | djkim | string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
1161 | c206d293 | taeseongkim | |
1162 | e0f00e26 | djkim | } |
1163 | break; |
||
1164 | case "SymControl": |
||
1165 | using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
||
1166 | { |
||
1167 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1168 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1169 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1170 | SolidColorBrush FontColor = _SetColor; |
||
1171 | double Angle = control.Angle; |
||
1172 | double Opacity = control.Opac; |
||
1173 | 8c3a888c | djkim | |
1174 | e0f00e26 | djkim | string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
1175 | c206d293 | taeseongkim | Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
1176 | 8c3a888c | djkim | } |
1177 | e0f00e26 | djkim | break; |
1178 | #endregion |
||
1179 | #region Image |
||
1180 | case "ImgControl": |
||
1181 | using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
||
1182 | { |
||
1183 | double Angle = control.Angle; |
||
1184 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1185 | Point TopRightPoint = GetPdfPointSystem(control.TR); |
||
1186 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1187 | Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
||
1188 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1189 | double Opacity = control.Opac; |
||
1190 | string FilePath = control.ImagePath; |
||
1191 | //Uri uri = new Uri(s.ImagePath); |
||
1192 | |||
1193 | 16fe076c | humkyung | Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
1194 | e0f00e26 | djkim | } |
1195 | break; |
||
1196 | #endregion |
||
1197 | default: |
||
1198 | c206d293 | taeseongkim | StatusChange($"{ControlT.Name} Not Support", 0); |
1199 | e0f00e26 | djkim | break; |
1200 | } |
||
1201 | 8c3a888c | djkim | } |
1202 | e0f00e26 | djkim | catch (Exception ex) |
1203 | { |
||
1204 | ab590000 | taeseongkim | StatusChange($"markupItem : {markupItem.ID}" + ex.ToString(), 0); |
1205 | e0f00e26 | djkim | } |
1206 | 8c3a888c | djkim | } |
1207 | abaa85b4 | djkim | } |
1208 | e0f00e26 | djkim | pdfStamper.Outlines = root; |
1209 | pdfStamper.Close(); |
||
1210 | pdfReader.Close(); |
||
1211 | 7ca218b3 | KangIngu | } |
1212 | abaa85b4 | djkim | } |
1213 | e0f00e26 | djkim | #endregion |
1214 | 7ca218b3 | KangIngu | } |
1215 | if (tempFileInfo.Exists) |
||
1216 | { |
||
1217 | tempFileInfo.Delete(); |
||
1218 | } |
||
1219 | |||
1220 | if (File.Exists(pdfFilePath)) |
||
1221 | { |
||
1222 | try |
||
1223 | { |
||
1224 | 6e5f7eaf | djkim | FinalPDFPath = new FileInfo(pdfFilePath); |
1225 | |||
1226 | string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
||
1227 | string destfilepath = Path.Combine(pdfmovepath,FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
||
1228 | if (File.Exists(destfilepath)) |
||
1229 | File.Delete(destfilepath); |
||
1230 | File.Move(FinalPDFPath.FullName, destfilepath); |
||
1231 | FinalPDFPath = new FileInfo(destfilepath); |
||
1232 | 7ca218b3 | KangIngu | File.Delete(pdfFilePath); |
1233 | } |
||
1234 | catch (Exception ex) |
||
1235 | { |
||
1236 | 6e5f7eaf | djkim | SetNotice(finaldata.ID, "File move error: " + ex.ToString()); |
1237 | 7ca218b3 | KangIngu | } |
1238 | |||
1239 | return true; |
||
1240 | } |
||
1241 | } |
||
1242 | 7aa36857 | humkyung | catch (Exception ex) |
1243 | 7ca218b3 | KangIngu | { |
1244 | 782ad7b1 | taeseongkim | SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString()); |
1245 | 7ca218b3 | KangIngu | } |
1246 | return false; |
||
1247 | } |
||
1248 | 4f017ed3 | taeseongkim | |
1249 | /// <summary> |
||
1250 | /// kcom의 화살표방향과 틀려 추가함 |
||
1251 | /// </summary> |
||
1252 | /// <param name="PageAngle"></param> |
||
1253 | /// <param name="endP"></param> |
||
1254 | /// <param name="ps">box Points</param> |
||
1255 | /// <param name="IsFixed"></param> |
||
1256 | /// <returns></returns> |
||
1257 | private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed) |
||
1258 | { |
||
1259 | Point testP = endP; |
||
1260 | |||
1261 | try |
||
1262 | { |
||
1263 | switch (Math.Abs(PageAngle).ToString()) |
||
1264 | { |
||
1265 | case "90": |
||
1266 | testP = new Point(endP.X + 50, endP.Y); |
||
1267 | break; |
||
1268 | case "270": |
||
1269 | testP = new Point(endP.X - 50, endP.Y); |
||
1270 | break; |
||
1271 | } |
||
1272 | |||
1273 | //20180910 LJY 각도에 따라. |
||
1274 | switch (Math.Abs(PageAngle).ToString()) |
||
1275 | { |
||
1276 | case "90": |
||
1277 | if (IsFixed) |
||
1278 | { |
||
1279 | if (ps[0] == endP) //상단 |
||
1280 | { |
||
1281 | testP = new Point(endP.X, endP.Y + 50); |
||
1282 | //System.Diagnostics.Debug.WriteLine("상단"+ testP); |
||
1283 | } |
||
1284 | else if (ps[1] == endP) //하단 |
||
1285 | { |
||
1286 | testP = new Point(endP.X, endP.Y - 50); |
||
1287 | //System.Diagnostics.Debug.WriteLine("하단"+ testP); |
||
1288 | } |
||
1289 | else if (ps[2] == endP) //좌단 |
||
1290 | { |
||
1291 | testP = new Point(endP.X - 50, endP.Y); |
||
1292 | //System.Diagnostics.Debug.WriteLine("좌단"+ testP); |
||
1293 | } |
||
1294 | else if (ps[3] == endP) //우단 |
||
1295 | { |
||
1296 | testP = new Point(endP.X + 50, endP.Y); |
||
1297 | //System.Diagnostics.Debug.WriteLine("우단"+ testP); |
||
1298 | } |
||
1299 | } |
||
1300 | break; |
||
1301 | case "270": |
||
1302 | if (IsFixed) |
||
1303 | { |
||
1304 | if (ps[0] == endP) //상단 |
||
1305 | { |
||
1306 | testP = new Point(endP.X, endP.Y - 50); |
||
1307 | //System.Diagnostics.Debug.WriteLine("상단" + testP); |
||
1308 | } |
||
1309 | else if (ps[1] == endP) //하단 |
||
1310 | { |
||
1311 | testP = new Point(endP.X, endP.Y + 50); |
||
1312 | //System.Diagnostics.Debug.WriteLine("하단" + testP); |
||
1313 | } |
||
1314 | else if (ps[2] == endP) //좌단 |
||
1315 | { |
||
1316 | testP = new Point(endP.X + 50, endP.Y); |
||
1317 | //System.Diagnostics.Debug.WriteLine("좌단" + testP); |
||
1318 | } |
||
1319 | else if (ps[3] == endP) //우단 |
||
1320 | { |
||
1321 | testP = new Point(endP.X - 50, endP.Y); |
||
1322 | //System.Diagnostics.Debug.WriteLine("우단" + testP); |
||
1323 | } |
||
1324 | } |
||
1325 | break; |
||
1326 | default: |
||
1327 | if (IsFixed) |
||
1328 | { |
||
1329 | |||
1330 | if (ps[0] == endP) //상단 |
||
1331 | { |
||
1332 | testP = new Point(endP.X, endP.Y - 50); |
||
1333 | //System.Diagnostics.Debug.WriteLine("상단"); |
||
1334 | } |
||
1335 | else if (ps[1] == endP) //하단 |
||
1336 | { |
||
1337 | testP = new Point(endP.X, endP.Y + 50); |
||
1338 | //System.Diagnostics.Debug.WriteLine("하단"); |
||
1339 | } |
||
1340 | else if (ps[2] == endP) //좌단 |
||
1341 | { |
||
1342 | testP = new Point(endP.X - 50, endP.Y); |
||
1343 | //System.Diagnostics.Debug.WriteLine("좌단"); |
||
1344 | } |
||
1345 | else if (ps[3] == endP) //우단 |
||
1346 | { |
||
1347 | testP = new Point(endP.X + 50, endP.Y); |
||
1348 | //System.Diagnostics.Debug.WriteLine("우단"); |
||
1349 | } |
||
1350 | } |
||
1351 | break; |
||
1352 | } |
||
1353 | |||
1354 | } |
||
1355 | catch (Exception) |
||
1356 | { |
||
1357 | } |
||
1358 | |||
1359 | return testP; |
||
1360 | } |
||
1361 | |||
1362 | private Point Test(Rect rect,Point point) |
||
1363 | { |
||
1364 | Point result = new Point(); |
||
1365 | |||
1366 | Point newPoint = new Point(); |
||
1367 | |||
1368 | double oldNear = 0; |
||
1369 | double newNear = 0; |
||
1370 | |||
1371 | oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result); |
||
1372 | |||
1373 | newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint); |
||
1374 | |||
1375 | if (newNear < oldNear) |
||
1376 | { |
||
1377 | oldNear = newNear; |
||
1378 | result = newPoint; |
||
1379 | } |
||
1380 | |||
1381 | newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint); |
||
1382 | |||
1383 | if (newNear < oldNear) |
||
1384 | { |
||
1385 | oldNear = newNear; |
||
1386 | result = newPoint; |
||
1387 | } |
||
1388 | |||
1389 | |||
1390 | newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint); |
||
1391 | |||
1392 | if (newNear < oldNear) |
||
1393 | { |
||
1394 | oldNear = newNear; |
||
1395 | result = newPoint; |
||
1396 | } |
||
1397 | |||
1398 | return result; |
||
1399 | } |
||
1400 | |||
1401 | private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, SolidColorBrush setColor) |
||
1402 | { |
||
1403 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1404 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1405 | Point MidPoint = GetPdfPointSystem(control.MidPoint); |
||
1406 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1407 | DoubleCollection DashSize = control.DashSize; |
||
1408 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1409 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
1410 | |||
1411 | double Opacity = control.Opac; |
||
1412 | |||
1413 | if (EndPoint == MidPoint) |
||
1414 | { |
||
1415 | Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
||
1416 | } |
||
1417 | else |
||
1418 | { |
||
1419 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity); |
||
1420 | } |
||
1421 | |||
1422 | Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity); |
||
1423 | |||
1424 | } |
||
1425 | |||
1426 | private void DrawLine(S_LineControl control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, SolidColorBrush setColor) |
||
1427 | { |
||
1428 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1429 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1430 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1431 | DoubleCollection DashSize = control.DashSize; |
||
1432 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1433 | |||
1434 | var Opacity = control.Opac; |
||
1435 | string UserID = control.UserID; |
||
1436 | double Interval = control.Interval; |
||
1437 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
1438 | Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, setColor, Opacity); |
||
1439 | switch (control.LineStyleSet) |
||
1440 | { |
||
1441 | case LineStyleSet.ArrowLine: |
||
1442 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
||
1443 | break; |
||
1444 | case LineStyleSet.CancelLine: |
||
1445 | { |
||
1446 | var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X))); |
||
1447 | var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y))); |
||
1448 | |||
1449 | if (x > y) |
||
1450 | { |
||
1451 | StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0)); |
||
1452 | EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0)); |
||
1453 | Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, setColor, Opacity); |
||
1454 | } |
||
1455 | } |
||
1456 | break; |
||
1457 | case LineStyleSet.TwinLine: |
||
1458 | { |
||
1459 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
||
1460 | Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
||
1461 | } |
||
1462 | break; |
||
1463 | case LineStyleSet.DimLine: |
||
1464 | { |
||
1465 | Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
||
1466 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
||
1467 | Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
||
1468 | } |
||
1469 | break; |
||
1470 | default: |
||
1471 | break; |
||
1472 | } |
||
1473 | |||
1474 | } |
||
1475 | |||
1476 | private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,SolidColorBrush setColor) |
||
1477 | { |
||
1478 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1479 | string Text = control.Text; |
||
1480 | |||
1481 | bool isUnderline = false; |
||
1482 | control.BoxW -= scaleWidth; |
||
1483 | control.BoxH -= scaleHeight; |
||
1484 | System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH); |
||
1485 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1486 | Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH)); |
||
1487 | |||
1488 | List<Point> pointSet = new List<Point>(); |
||
1489 | pointSet.Add(StartPoint); |
||
1490 | pointSet.Add(EndPoint); |
||
1491 | |||
1492 | PaintSet paint = PaintSet.None; |
||
1493 | switch (control.paintMethod) |
||
1494 | { |
||
1495 | case 1: |
||
1496 | { |
||
1497 | paint = PaintSet.Fill; |
||
1498 | } |
||
1499 | break; |
||
1500 | case 2: |
||
1501 | { |
||
1502 | paint = PaintSet.Hatch; |
||
1503 | } |
||
1504 | break; |
||
1505 | default: |
||
1506 | break; |
||
1507 | } |
||
1508 | if (control.isHighLight) paint |= PaintSet.Highlight; |
||
1509 | |||
1510 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
1511 | double TextSize = Convert.ToDouble(data2[1]); |
||
1512 | SolidColorBrush FontColor = setColor; |
||
1513 | double Angle = control.Angle; |
||
1514 | double Opacity = control.Opac; |
||
1515 | FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]); |
||
1516 | var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
||
1517 | |||
1518 | FontStyle fontStyle = FontStyles.Normal; |
||
1519 | if (FontStyles.Italic == TextStyle) |
||
1520 | { |
||
1521 | fontStyle = FontStyles.Italic; |
||
1522 | } |
||
1523 | |||
1524 | FontWeight fontWeight = FontWeights.Black; |
||
1525 | |||
1526 | var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
||
1527 | //강인구 수정(2018.04.17) |
||
1528 | if (FontWeights.Bold == TextWeight) |
||
1529 | //if (FontWeights.ExtraBold == TextWeight) |
||
1530 | { |
||
1531 | fontWeight = FontWeights.Bold; |
||
1532 | } |
||
1533 | |||
1534 | TextDecorationCollection decoration = TextDecorations.Baseline; |
||
1535 | if (control.fontConfig.Count() == 4) |
||
1536 | { |
||
1537 | decoration = TextDecorations.Underline; |
||
1538 | } |
||
1539 | |||
1540 | Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
||
1541 | } |
||
1542 | c206d293 | taeseongkim | |
1543 | 7ca218b3 | KangIngu | |
1544 | 40cf5bf7 | humkyung | ~MarkupToPDF() |
1545 | { |
||
1546 | this.Dispose(false); |
||
1547 | } |
||
1548 | |||
1549 | private bool disposed; |
||
1550 | |||
1551 | 7ca218b3 | KangIngu | public void Dispose() |
1552 | { |
||
1553 | 40cf5bf7 | humkyung | this.Dispose(true); |
1554 | GC.SuppressFinalize(this); |
||
1555 | } |
||
1556 | |||
1557 | protected virtual void Dispose(bool disposing) |
||
1558 | { |
||
1559 | if (this.disposed) return; |
||
1560 | if (disposing) |
||
1561 | { |
||
1562 | // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
||
1563 | } |
||
1564 | // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
||
1565 | this.disposed = true; |
||
1566 | 8c3a888c | djkim | } |
1567 | 7f01e35f | ljiyeon | |
1568 | 7ca218b3 | KangIngu | #endregion |
1569 | } |
||
1570 | } |