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