markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 14daef55
이력 | 보기 | 이력해설 | 다운로드 (78.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 | e0f00e26 | djkim | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
703 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
704 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
705 | DoubleCollection DashSize = control.DashSize; |
||
706 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
707 | |||
708 | var Opacity = control.Opac; |
||
709 | string UserID = control.UserID; |
||
710 | double Interval = control.Interval; |
||
711 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
712 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity); |
713 | e0f00e26 | djkim | switch (control.LineStyleSet) |
714 | { |
||
715 | case LineStyleSet.ArrowLine: |
||
716 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity); |
717 | e0f00e26 | djkim | break; |
718 | case LineStyleSet.CancelLine: |
||
719 | 8c3a888c | djkim | { |
720 | e0f00e26 | djkim | var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X))); |
721 | var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y))); |
||
722 | |||
723 | if (x > y) |
||
724 | { |
||
725 | StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0)); |
||
726 | EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0)); |
||
727 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity); |
728 | e0f00e26 | djkim | } |
729 | 8c3a888c | djkim | } |
730 | e0f00e26 | djkim | break; |
731 | case LineStyleSet.TwinLine: |
||
732 | { |
||
733 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity); |
734 | Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity); |
||
735 | e0f00e26 | djkim | } |
736 | break; |
||
737 | case LineStyleSet.DimLine: |
||
738 | { |
||
739 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity); |
740 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity); |
||
741 | Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity); |
||
742 | e0f00e26 | djkim | } |
743 | break; |
||
744 | default: |
||
745 | break; |
||
746 | } |
||
747 | 7ca218b3 | KangIngu | |
748 | |||
749 | e0f00e26 | djkim | } |
750 | 8c3a888c | djkim | } |
751 | e0f00e26 | djkim | break; |
752 | #endregion |
||
753 | #region ArrowControlMulti |
||
754 | case "ArrowControl_Multi": |
||
755 | 8c3a888c | djkim | { |
756 | e0f00e26 | djkim | using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
757 | { |
||
758 | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
759 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
760 | Point MidPoint = GetPdfPointSystem(control.MidPoint); |
||
761 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
762 | DoubleCollection DashSize = control.DashSize; |
||
763 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
764 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
765 | abaa85b4 | djkim | |
766 | e0f00e26 | djkim | double Opacity = control.Opac; |
767 | abaa85b4 | djkim | |
768 | e0f00e26 | djkim | if (EndPoint == MidPoint) |
769 | { |
||
770 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity); |
771 | e0f00e26 | djkim | } |
772 | else |
||
773 | { |
||
774 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
775 | e0f00e26 | djkim | } |
776 | 7ca218b3 | KangIngu | |
777 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
778 | abaa85b4 | djkim | |
779 | e0f00e26 | djkim | } |
780 | 8c3a888c | djkim | } |
781 | e0f00e26 | djkim | break; |
782 | #endregion |
||
783 | #region PolyControl |
||
784 | case "PolygonControl": |
||
785 | using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item)) |
||
786 | 7ca218b3 | KangIngu | { |
787 | 8c3a888c | djkim | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
788 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
789 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
790 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
791 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
792 | e0f00e26 | djkim | double Opacity = control.Opac; |
793 | DoubleCollection DashSize = control.DashSize; |
||
794 | 8c3a888c | djkim | |
795 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
796 | 8c3a888c | djkim | } |
797 | e0f00e26 | djkim | break; |
798 | #endregion |
||
799 | c206d293 | taeseongkim | #region ArcControl or ArrowArcControl |
800 | e0f00e26 | djkim | case "ArcControl": |
801 | c206d293 | taeseongkim | case "ArrowArcControl": |
802 | 8c3a888c | djkim | { |
803 | e0f00e26 | djkim | using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
804 | abaa85b4 | djkim | { |
805 | e0f00e26 | djkim | string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
806 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
807 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
808 | Point MidPoint = GetPdfPointSystem(control.MidPoint); |
||
809 | DoubleCollection DashSize = control.DashSize; |
||
810 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
811 | |||
812 | var Opacity = control.Opac; |
||
813 | string UserID = control.UserID; |
||
814 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
||
815 | bool IsTransOn = control.IsTransOn; |
||
816 | |||
817 | if (control.IsTransOn) |
||
818 | 8c3a888c | djkim | { |
819 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
820 | Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
||
821 | 8c3a888c | djkim | } |
822 | else |
||
823 | { |
||
824 | 16fe076c | humkyung | Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
825 | 8c3a888c | djkim | } |
826 | e0f00e26 | djkim | |
827 | c206d293 | taeseongkim | if (ControlT.Name == "ArrowArcControl") |
828 | { |
||
829 | Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
||
830 | Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
||
831 | } |
||
832 | abaa85b4 | djkim | } |
833 | 8c3a888c | djkim | } |
834 | e0f00e26 | djkim | break; |
835 | #endregion |
||
836 | #region RectangleControl |
||
837 | case "RectangleControl": |
||
838 | using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
||
839 | 7ca218b3 | KangIngu | { |
840 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
841 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
842 | var PaintStyle = control.PaintState; |
||
843 | double Angle = control.Angle; |
||
844 | DoubleCollection DashSize = control.DashSize; |
||
845 | double Opacity = control.Opac; |
||
846 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
847 | |||
848 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
849 | 7ca218b3 | KangIngu | } |
850 | e0f00e26 | djkim | break; |
851 | #endregion |
||
852 | #region TriControl |
||
853 | case "TriControl": |
||
854 | using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(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 | var PaintStyle = control.Paint; |
||
859 | double Angle = control.Angle; |
||
860 | //StrokeColor = _SetColor, //색상은 레드 |
||
861 | DoubleCollection DashSize = control.DashSize; |
||
862 | double Opacity = control.Opac; |
||
863 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
864 | 7ca218b3 | KangIngu | |
865 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
866 | 7ca218b3 | KangIngu | } |
867 | e0f00e26 | djkim | break; |
868 | #endregion |
||
869 | #region CircleControl |
||
870 | case "CircleControl": |
||
871 | using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
||
872 | 7ca218b3 | KangIngu | { |
873 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
874 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
875 | var StartPoint = GetPdfPointSystem(control.StartPoint); |
||
876 | var EndPoint = GetPdfPointSystem(control.EndPoint); |
||
877 | var PaintStyle = control.PaintState; |
||
878 | double Angle = control.Angle; |
||
879 | DoubleCollection DashSize = control.DashSize; |
||
880 | double Opacity = control.Opac; |
||
881 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
882 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
883 | e0f00e26 | djkim | |
884 | 7ca218b3 | KangIngu | } |
885 | e0f00e26 | djkim | break; |
886 | #endregion |
||
887 | #region RectCloudControl |
||
888 | case "RectCloudControl": |
||
889 | using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
||
890 | { |
||
891 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
892 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
893 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
894 | double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
||
895 | |||
896 | double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
||
897 | |||
898 | var PaintStyle = control.PaintState; |
||
899 | double Opacity = control.Opac; |
||
900 | DoubleCollection DashSize = control.DashSize; |
||
901 | 7ca218b3 | KangIngu | |
902 | e0f00e26 | djkim | //드로잉 방식이 표현되지 않음 |
903 | var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
||
904 | |||
905 | double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
||
906 | bool reverse = (area < 0); |
||
907 | if (PaintStyle == PaintSet.None) |
||
908 | { |
||
909 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
910 | } |
||
911 | else |
||
912 | { |
||
913 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
914 | } |
||
915 | } |
||
916 | break; |
||
917 | #endregion |
||
918 | #region CloudControl |
||
919 | case "CloudControl": |
||
920 | using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
||
921 | 7ca218b3 | KangIngu | { |
922 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
923 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
924 | double Toler = control.Toler; |
||
925 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
926 | double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
||
927 | var PaintStyle = control.PaintState; |
||
928 | double Opacity = control.Opac; |
||
929 | bool isTransOn = control.IsTrans; |
||
930 | bool isChain = control.IsChain; |
||
931 | |||
932 | DoubleCollection DashSize = control.DashSize; |
||
933 | |||
934 | if (isChain) |
||
935 | { |
||
936 | 16fe076c | humkyung | Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
937 | e0f00e26 | djkim | } |
938 | else |
||
939 | { |
||
940 | if (isTransOn) |
||
941 | 8c3a888c | djkim | { |
942 | e0f00e26 | djkim | double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
943 | bool reverse = (area < 0); |
||
944 | |||
945 | if (PaintStyle == PaintSet.None) |
||
946 | { |
||
947 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
948 | } |
||
949 | else |
||
950 | { |
||
951 | Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
||
952 | } |
||
953 | 8c3a888c | djkim | } |
954 | e0f00e26 | djkim | else |
955 | 8c3a888c | djkim | { |
956 | 16fe076c | humkyung | Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
957 | 8c3a888c | djkim | } |
958 | e0f00e26 | djkim | } |
959 | 7ca218b3 | KangIngu | } |
960 | e0f00e26 | djkim | break; |
961 | #endregion |
||
962 | #region TEXT |
||
963 | case "TextControl": |
||
964 | using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
||
965 | 7ca218b3 | KangIngu | { |
966 | e0f00e26 | djkim | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
967 | string Text = control.Text; |
||
968 | 8c3a888c | djkim | |
969 | e0f00e26 | djkim | bool isUnderline = false; |
970 | control.BoxW -= scaleWidth; |
||
971 | control.BoxH -= scaleHeight; |
||
972 | System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH); |
||
973 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
974 | Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH)); |
||
975 | |||
976 | List<Point> pointSet = new List<Point>(); |
||
977 | pointSet.Add(StartPoint); |
||
978 | pointSet.Add(EndPoint); |
||
979 | |||
980 | PaintSet paint = PaintSet.None; |
||
981 | switch (control.paintMethod) |
||
982 | 7ca218b3 | KangIngu | { |
983 | e0f00e26 | djkim | case 1: |
984 | { |
||
985 | paint = PaintSet.Fill; |
||
986 | } |
||
987 | break; |
||
988 | case 2: |
||
989 | { |
||
990 | paint = PaintSet.Hatch; |
||
991 | } |
||
992 | break; |
||
993 | default: |
||
994 | break; |
||
995 | 7ca218b3 | KangIngu | } |
996 | e0f00e26 | djkim | if (control.isHighLight) paint |= PaintSet.Highlight; |
997 | 8c3a888c | djkim | |
998 | e0f00e26 | djkim | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
999 | double TextSize = Convert.ToDouble(data2[1]); |
||
1000 | SolidColorBrush FontColor = _SetColor; |
||
1001 | double Angle = control.Angle; |
||
1002 | double Opacity = control.Opac; |
||
1003 | c206d293 | taeseongkim | FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]); |
1004 | 8c3a888c | djkim | var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
1005 | c206d293 | taeseongkim | |
1006 | 8c3a888c | djkim | FontStyle fontStyle = FontStyles.Normal; |
1007 | if (FontStyles.Italic == TextStyle) |
||
1008 | { |
||
1009 | fontStyle = FontStyles.Italic; |
||
1010 | } |
||
1011 | |||
1012 | FontWeight fontWeight = FontWeights.Black; |
||
1013 | |||
1014 | var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
||
1015 | e0f00e26 | djkim | //강인구 수정(2018.04.17) |
1016 | 8c3a888c | djkim | if (FontWeights.Bold == TextWeight) |
1017 | e0f00e26 | djkim | //if (FontWeights.ExtraBold == TextWeight) |
1018 | 8c3a888c | djkim | { |
1019 | fontWeight = FontWeights.Bold; |
||
1020 | } |
||
1021 | |||
1022 | TextDecorationCollection decoration = TextDecorations.Baseline; |
||
1023 | e0f00e26 | djkim | if (control.fontConfig.Count() == 4) |
1024 | 8c3a888c | djkim | { |
1025 | decoration = TextDecorations.Underline; |
||
1026 | } |
||
1027 | |||
1028 | 16fe076c | humkyung | Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1029 | e0f00e26 | djkim | } |
1030 | break; |
||
1031 | #endregion |
||
1032 | #region ArrowTextControl |
||
1033 | case "ArrowTextControl": |
||
1034 | using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
||
1035 | { |
||
1036 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1037 | Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
||
1038 | Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
||
1039 | Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
||
1040 | bool isUnderLine = false; |
||
1041 | string Text = ""; |
||
1042 | double fontsize = 30; |
||
1043 | |||
1044 | System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
||
1045 | Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
||
1046 | List<Point> tempPoint = new List<Point>(); |
||
1047 | |||
1048 | var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
||
1049 | |||
1050 | tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
||
1051 | tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
||
1052 | tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
||
1053 | tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
||
1054 | double Angle = control.Angle; |
||
1055 | var newStartPoint = tempStartPoint; |
||
1056 | var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
||
1057 | var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
||
1058 | |||
1059 | double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
||
1060 | SolidColorBrush FontColor = _SetColor; |
||
1061 | bool isHighlight = control.isHighLight; |
||
1062 | double Opacity = control.Opac; |
||
1063 | PaintSet Paint = PaintSet.None; |
||
1064 | |||
1065 | switch (control.ArrowStyle) |
||
1066 | 7ca218b3 | KangIngu | { |
1067 | e0f00e26 | djkim | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
1068 | { |
||
1069 | Paint = PaintSet.None; |
||
1070 | } |
||
1071 | break; |
||
1072 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
||
1073 | { |
||
1074 | Paint = PaintSet.Hatch; |
||
1075 | } |
||
1076 | break; |
||
1077 | case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
||
1078 | { |
||
1079 | Paint = PaintSet.Fill; |
||
1080 | } |
||
1081 | break; |
||
1082 | default: |
||
1083 | break; |
||
1084 | } |
||
1085 | if (control.isHighLight) Paint |= PaintSet.Highlight; |
||
1086 | |||
1087 | if (Paint == PaintSet.Hatch) |
||
1088 | { |
||
1089 | Text = control.ArrowText; |
||
1090 | 4804a4fb | humkyung | } |
1091 | 8c3a888c | djkim | else |
1092 | { |
||
1093 | e0f00e26 | djkim | Text = control.ArrowText; |
1094 | } |
||
1095 | |||
1096 | try |
||
1097 | { |
||
1098 | if (control.fontConfig.Count == 4) |
||
1099 | 8c3a888c | djkim | { |
1100 | e0f00e26 | djkim | fontsize = Convert.ToDouble(control.fontConfig[3]); |
1101 | 8c3a888c | djkim | } |
1102 | e0f00e26 | djkim | |
1103 | //강인구 수정(2018.04.17) |
||
1104 | var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
||
1105 | |||
1106 | FontStyle fontStyle = FontStyles.Normal; |
||
1107 | if (FontStyles.Italic == TextStyle) |
||
1108 | { |
||
1109 | fontStyle = FontStyles.Italic; |
||
1110 | } |
||
1111 | |||
1112 | FontWeight fontWeight = FontWeights.Black; |
||
1113 | |||
1114 | var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
||
1115 | if (FontWeights.Bold == TextWeight) |
||
1116 | { |
||
1117 | fontWeight = FontWeights.Bold; |
||
1118 | } |
||
1119 | |||
1120 | TextDecorationCollection decoration = TextDecorations.Baseline; |
||
1121 | if (control.fontConfig.Count() == 5) |
||
1122 | { |
||
1123 | decoration = TextDecorations.Underline; |
||
1124 | } |
||
1125 | |||
1126 | if (control.isTrans) |
||
1127 | 8c3a888c | djkim | { |
1128 | //인구 수정 Arrow Text Style적용 되도록 변경 |
||
1129 | 16fe076c | humkyung | Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1130 | newStartPoint, tempMidPoint, control.isFixed, |
||
1131 | c206d293 | taeseongkim | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1132 | 8c3a888c | djkim | } |
1133 | e0f00e26 | djkim | else |
1134 | { |
||
1135 | if (control.isFixed) |
||
1136 | { |
||
1137 | var testP = new Point(0, 0); |
||
1138 | if (control.isFixed) |
||
1139 | { |
||
1140 | if (tempPoint[1] == newEndPoint) |
||
1141 | { |
||
1142 | testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
||
1143 | } |
||
1144 | else if (tempPoint[3] == newEndPoint) |
||
1145 | { |
||
1146 | testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
||
1147 | } |
||
1148 | else if (tempPoint[0] == newEndPoint) |
||
1149 | { |
||
1150 | testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
||
1151 | } |
||
1152 | else if (tempPoint[2] == newEndPoint) |
||
1153 | { |
||
1154 | testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
||
1155 | } |
||
1156 | } |
||
1157 | //인구 수정 Arrow Text Style적용 되도록 변경 |
||
1158 | 16fe076c | humkyung | Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1159 | tempStartPoint, testP, control.isFixed , |
||
1160 | e0f00e26 | djkim | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
1161 | c206d293 | taeseongkim | FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1162 | e0f00e26 | djkim | } |
1163 | else |
||
1164 | { |
||
1165 | //인구 수정 Arrow Text Style적용 되도록 변경 |
||
1166 | 16fe076c | humkyung | Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1167 | newStartPoint, tempMidPoint, control.isFixed, |
||
1168 | c206d293 | taeseongkim | LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1169 | e0f00e26 | djkim | } |
1170 | } |
||
1171 | 8c3a888c | djkim | } |
1172 | e0f00e26 | djkim | catch (Exception ex) |
1173 | { |
||
1174 | 16fe076c | humkyung | throw ex; |
1175 | e0f00e26 | djkim | } |
1176 | } |
||
1177 | break; |
||
1178 | #endregion |
||
1179 | #region SignControl |
||
1180 | case "SignControl": |
||
1181 | using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
||
1182 | { |
||
1183 | |||
1184 | double Angle = control.Angle; |
||
1185 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1186 | Point TopRightPoint = GetPdfPointSystem(control.TR); |
||
1187 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1188 | Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
||
1189 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1190 | double Opacity = control.Opac; |
||
1191 | string UserNumber = control.UserNumber; |
||
1192 | 16fe076c | humkyung | Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
1193 | e0f00e26 | djkim | } |
1194 | break; |
||
1195 | #endregion |
||
1196 | #region MyRegion |
||
1197 | case "DateControl": |
||
1198 | using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
||
1199 | { |
||
1200 | string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
1201 | string Text = control.Text; |
||
1202 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1203 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1204 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1205 | SolidColorBrush FontColor = _SetColor; |
||
1206 | double Angle = control.Angle; |
||
1207 | double Opacity = control.Opac; |
||
1208 | c206d293 | taeseongkim | Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
1209 | f633b10b | KangIngu | } |
1210 | e0f00e26 | djkim | break; |
1211 | #endregion |
||
1212 | #region SymControlN (APPROVED) |
||
1213 | case "SymControlN": |
||
1214 | using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
||
1215 | 8c3a888c | djkim | { |
1216 | e0f00e26 | djkim | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1217 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1218 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1219 | SolidColorBrush FontColor = _SetColor; |
||
1220 | double Angle = control.Angle; |
||
1221 | double Opacity = control.Opac; |
||
1222 | |||
1223 | c206d293 | taeseongkim | var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
1224 | |||
1225 | if (stamp.Count() > 0) |
||
1226 | { |
||
1227 | var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE); |
||
1228 | |||
1229 | Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata); |
||
1230 | } |
||
1231 | |||
1232 | e0f00e26 | djkim | string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
1233 | c206d293 | taeseongkim | |
1234 | e0f00e26 | djkim | } |
1235 | break; |
||
1236 | case "SymControl": |
||
1237 | using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
||
1238 | { |
||
1239 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1240 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1241 | List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
||
1242 | SolidColorBrush FontColor = _SetColor; |
||
1243 | double Angle = control.Angle; |
||
1244 | double Opacity = control.Opac; |
||
1245 | 8c3a888c | djkim | |
1246 | e0f00e26 | djkim | string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
1247 | c206d293 | taeseongkim | Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
1248 | 8c3a888c | djkim | } |
1249 | e0f00e26 | djkim | break; |
1250 | #endregion |
||
1251 | #region Image |
||
1252 | case "ImgControl": |
||
1253 | using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
||
1254 | { |
||
1255 | double Angle = control.Angle; |
||
1256 | Point StartPoint = GetPdfPointSystem(control.StartPoint); |
||
1257 | Point TopRightPoint = GetPdfPointSystem(control.TR); |
||
1258 | Point EndPoint = GetPdfPointSystem(control.EndPoint); |
||
1259 | Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
||
1260 | List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
||
1261 | double Opacity = control.Opac; |
||
1262 | string FilePath = control.ImagePath; |
||
1263 | //Uri uri = new Uri(s.ImagePath); |
||
1264 | |||
1265 | 16fe076c | humkyung | Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
1266 | e0f00e26 | djkim | } |
1267 | break; |
||
1268 | #endregion |
||
1269 | default: |
||
1270 | c206d293 | taeseongkim | StatusChange($"{ControlT.Name} Not Support", 0); |
1271 | e0f00e26 | djkim | break; |
1272 | } |
||
1273 | 8c3a888c | djkim | } |
1274 | e0f00e26 | djkim | catch (Exception ex) |
1275 | { |
||
1276 | ab590000 | taeseongkim | StatusChange($"markupItem : {markupItem.ID}" + ex.ToString(), 0); |
1277 | e0f00e26 | djkim | } |
1278 | 8c3a888c | djkim | } |
1279 | abaa85b4 | djkim | } |
1280 | e0f00e26 | djkim | pdfStamper.Outlines = root; |
1281 | pdfStamper.Close(); |
||
1282 | pdfReader.Close(); |
||
1283 | 7ca218b3 | KangIngu | } |
1284 | abaa85b4 | djkim | } |
1285 | e0f00e26 | djkim | #endregion |
1286 | 7ca218b3 | KangIngu | } |
1287 | if (tempFileInfo.Exists) |
||
1288 | { |
||
1289 | tempFileInfo.Delete(); |
||
1290 | } |
||
1291 | |||
1292 | if (File.Exists(pdfFilePath)) |
||
1293 | { |
||
1294 | try |
||
1295 | { |
||
1296 | 6e5f7eaf | djkim | FinalPDFPath = new FileInfo(pdfFilePath); |
1297 | |||
1298 | string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
||
1299 | string destfilepath = Path.Combine(pdfmovepath,FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
||
1300 | if (File.Exists(destfilepath)) |
||
1301 | File.Delete(destfilepath); |
||
1302 | File.Move(FinalPDFPath.FullName, destfilepath); |
||
1303 | FinalPDFPath = new FileInfo(destfilepath); |
||
1304 | 7ca218b3 | KangIngu | File.Delete(pdfFilePath); |
1305 | } |
||
1306 | catch (Exception ex) |
||
1307 | { |
||
1308 | 6e5f7eaf | djkim | SetNotice(finaldata.ID, "File move error: " + ex.ToString()); |
1309 | 7ca218b3 | KangIngu | } |
1310 | |||
1311 | return true; |
||
1312 | } |
||
1313 | } |
||
1314 | 7aa36857 | humkyung | catch (Exception ex) |
1315 | 7ca218b3 | KangIngu | { |
1316 | 782ad7b1 | taeseongkim | SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString()); |
1317 | 7ca218b3 | KangIngu | } |
1318 | return false; |
||
1319 | } |
||
1320 | c206d293 | taeseongkim | |
1321 | 7ca218b3 | KangIngu | |
1322 | 40cf5bf7 | humkyung | ~MarkupToPDF() |
1323 | { |
||
1324 | this.Dispose(false); |
||
1325 | } |
||
1326 | |||
1327 | private bool disposed; |
||
1328 | |||
1329 | 7ca218b3 | KangIngu | public void Dispose() |
1330 | { |
||
1331 | 40cf5bf7 | humkyung | this.Dispose(true); |
1332 | GC.SuppressFinalize(this); |
||
1333 | } |
||
1334 | |||
1335 | protected virtual void Dispose(bool disposing) |
||
1336 | { |
||
1337 | if (this.disposed) return; |
||
1338 | if (disposing) |
||
1339 | { |
||
1340 | // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
||
1341 | } |
||
1342 | // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
||
1343 | this.disposed = true; |
||
1344 | 8c3a888c | djkim | } |
1345 | 7f01e35f | ljiyeon | |
1346 | 7ca218b3 | KangIngu | #endregion |
1347 | } |
||
1348 | } |