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