markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ abaa85b4
이력 | 보기 | 이력해설 | 다운로드 (62.7 KB)
1 |
using IFinalPDF; |
---|---|
2 |
using iTextSharp.text.pdf; |
3 |
using KCOMDataModel.Common; |
4 |
using KCOMDataModel.DataModel; |
5 |
using MarkupToPDF.Common; |
6 |
using MarkupToPDF.Controls.Common; |
7 |
using MarkupToPDF.Serialize.Core; |
8 |
using MarkupToPDF.Serialize.S_Control; |
9 |
using System; |
10 |
using System.Collections.Generic; |
11 |
using System.Configuration; |
12 |
using System.IO; |
13 |
using System.Linq; |
14 |
using System.Net; |
15 |
using System.Runtime.InteropServices; |
16 |
using System.Text; |
17 |
using System.Web; |
18 |
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 |
public CommonLib.MARKUS_API.FINAL_PDF FinalItem; |
33 |
public CommonLib.MARKUS_API.DOCINFO DocInfoItem = null; |
34 |
public List<CommonLib.MARKUS_API.DOCPAGE> DocPageItem = null; |
35 |
public CommonLib.MARKUS_API.MARKUP_INFO MarkupInfoItem = null; |
36 |
public List<CommonLib.MARKUS_API.MARKUP_DATA> MarkupDataSet = null; |
37 |
//private string _PrintPDFStorgeLocal = null; |
38 |
//private string _PrintPDFStorgeRemote = null; |
39 |
public event EventHandler<MakeFinalErrorArgs> FinalMakeError; |
40 |
public event EventHandler<EndFinalEventArgs> EndFinal; |
41 |
|
42 |
private iTextSharp.text.Rectangle pdfSize { get; set; } |
43 |
private double pageW = 0; |
44 |
private double pageH = 0; |
45 |
|
46 |
//private const double zoomLevel = 3.0; |
47 |
private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음 |
48 |
#endregion |
49 |
|
50 |
#region 메서드 |
51 |
public static bool IsLocalIPAddress(string host) |
52 |
{ |
53 |
try |
54 |
{ |
55 |
IPAddress[] hostIPs = Dns.GetHostAddresses(host); |
56 |
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); |
57 |
|
58 |
foreach (IPAddress hostIP in hostIPs) |
59 |
{ |
60 |
if (IPAddress.IsLoopback(hostIP)) return true; |
61 |
|
62 |
foreach (IPAddress localIP in localIPs) |
63 |
{ |
64 |
if (hostIP.Equals(localIP)) return true; |
65 |
} |
66 |
} |
67 |
} |
68 |
catch { } |
69 |
return false; |
70 |
} |
71 |
|
72 |
private void SetNotice(string finalID , string message) |
73 |
{ |
74 |
if (FinalMakeError != null) |
75 |
{ |
76 |
FinalMakeError(this, new MakeFinalErrorArgs { FinalID = finalID, Message = message }); |
77 |
} |
78 |
} |
79 |
|
80 |
private string GetFileName(string hrefLink) |
81 |
{ |
82 |
try |
83 |
{ |
84 |
if (hrefLink.Contains("vpcs_doclib")) |
85 |
{ |
86 |
return System.IO.Path.GetFileName(hrefLink.Replace("/", "\\")); |
87 |
} |
88 |
else |
89 |
{ |
90 |
Uri fileurl = new Uri(hrefLink); |
91 |
int index = hrefLink.IndexOf("?"); |
92 |
string filename = HttpUtility.ParseQueryString(fileurl.Query).Get("fileName"); |
93 |
return filename; |
94 |
} |
95 |
} |
96 |
catch (Exception ex) |
97 |
{ |
98 |
throw ex; |
99 |
} |
100 |
} |
101 |
|
102 |
public Point GetPdfPointSystem(Point point) |
103 |
{ |
104 |
point = new Point(point.X + pdfSize.Left * scaleWidth, point.Y - pdfSize.Bottom * scaleHeight); |
105 |
return new Point((float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight)); |
106 |
} |
107 |
|
108 |
public double GetPdfSize(double size) |
109 |
{ |
110 |
return (size / scaleWidth); |
111 |
} |
112 |
|
113 |
public List<Point> GetPdfPointSystem(List<Point> point) |
114 |
{ |
115 |
List<Point> dummy = new List<Point>(); |
116 |
foreach (var item in point) |
117 |
{ |
118 |
dummy.Add(GetPdfPointSystem(item)); |
119 |
} |
120 |
return dummy; |
121 |
} |
122 |
|
123 |
public double returnAngle(Point start, Point end) |
124 |
{ |
125 |
double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y); |
126 |
//angle *= -1; |
127 |
|
128 |
angle += 90; |
129 |
//if (angle < 0) |
130 |
//{ |
131 |
// angle = angle + 360; |
132 |
//} |
133 |
return angle; |
134 |
} |
135 |
|
136 |
#endregion |
137 |
|
138 |
#region 생성자 & 소멸자 |
139 |
public void MakeFinalPDF(object _FinalPDF) |
140 |
{ |
141 |
|
142 |
CommonLib.MARKUS_API.DOCUMENT_ITEM documentItem; |
143 |
CommonLib.MARKUS_API.FINAL_PDF FinalPDF = (CommonLib.MARKUS_API.FINAL_PDF)_FinalPDF; |
144 |
FinalItem = FinalPDF; |
145 |
|
146 |
|
147 |
string PdfFilePathRoot = null; |
148 |
string TestFile = System.IO.Path.GetTempFileName(); |
149 |
|
150 |
#region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정 |
151 |
try |
152 |
{ |
153 |
using (DataController dc = new DataController()) |
154 |
{ |
155 |
var _properties = dc.GetProperties(FinalPDF.PROJECT_NO); |
156 |
if(_properties != null) |
157 |
{ |
158 |
PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).FirstOrDefault().VALUE; |
159 |
_FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE; |
160 |
_FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE; |
161 |
} |
162 |
else |
163 |
{ |
164 |
SetNotice(FinalPDF.ID, "프로퍼티를 가지고 올 수 없습니다."); |
165 |
return; |
166 |
} |
167 |
dc.SetFinalStatus(FinalPDF.ID, CommonLib.MARKUS_API.FinalStatus.Create); |
168 |
} |
169 |
} |
170 |
catch (Exception ex) |
171 |
{ |
172 |
SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString()); |
173 |
return; |
174 |
} |
175 |
#endregion |
176 |
|
177 |
#region 문서 복사 |
178 |
try |
179 |
{ |
180 |
using (DataController dc = new DataController()) |
181 |
{ |
182 |
//var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID); |
183 |
string project_no = FinalPDF.PROJECT_NO; |
184 |
string docinfo_id = FinalPDF.DOCINFO_ID; |
185 |
|
186 |
var _DOCINFO = dc.GetDocInfo(project_no, docinfo_id); |
187 |
if (_DOCINFO != null) |
188 |
{ |
189 |
DocInfoItem = _DOCINFO; |
190 |
DocPageItem = dc.GetDocpage(project_no, docinfo_id); |
191 |
|
192 |
PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\" |
193 |
+ (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() |
194 |
+ @"\" + FinalPDF.DOCUMENT_ID + @"\"; |
195 |
|
196 |
MarkupInfoItem = dc.GetMarkupInfo(project_no, docinfo_id); |
197 |
|
198 |
if (MarkupInfoItem == null) |
199 |
{ |
200 |
throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
201 |
} |
202 |
else |
203 |
{ |
204 |
MarkupDataSet = dc.GetMarkupData(project_no, docinfo_id); |
205 |
if (MarkupDataSet == null) |
206 |
{ |
207 |
throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
208 |
} |
209 |
} |
210 |
documentItem = dc.GetDocumentItem(project_no, DocInfoItem.DOCUMENT_ID); |
211 |
if (documentItem == null) |
212 |
{ |
213 |
throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
214 |
} |
215 |
var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 |
216 |
|
217 |
#region 파일 체크 |
218 |
if (_files.Count() == 1) |
219 |
{ |
220 |
if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
221 |
{ |
222 |
OriginFileName = _files.First().Name; |
223 |
PdfFilePath = _files.First().CopyTo(TestFile, true); |
224 |
} |
225 |
else |
226 |
{ |
227 |
throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()); |
228 |
} |
229 |
} |
230 |
else if (_files.Count() > 1) |
231 |
{ |
232 |
var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault(); |
233 |
|
234 |
if (originalFile == null) |
235 |
{ |
236 |
throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
237 |
} |
238 |
else |
239 |
{ |
240 |
OriginFileName = originalFile.Name; |
241 |
PdfFilePath = originalFile.CopyTo(TestFile, true); |
242 |
} |
243 |
} |
244 |
else |
245 |
{ |
246 |
throw new Exception("PDF를 찾지 못하였습니다"); |
247 |
} |
248 |
#endregion |
249 |
|
250 |
#region 예외처리 |
251 |
if (PdfFilePath == null) |
252 |
{ |
253 |
throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
254 |
} |
255 |
if (!PdfFilePath.Exists) |
256 |
{ |
257 |
throw new Exception("PDF원본이 존재하지 않습니다"); |
258 |
} |
259 |
#endregion |
260 |
} |
261 |
else |
262 |
{ |
263 |
throw new Exception("일치하는 DocInfo가 없습니다"); |
264 |
} |
265 |
} |
266 |
|
267 |
|
268 |
} |
269 |
catch (Exception ex) |
270 |
{ |
271 |
if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다") |
272 |
{ |
273 |
SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
274 |
System.Diagnostics.Process process = new System.Diagnostics.Process(); |
275 |
process.StartInfo.FileName = "cmd"; |
276 |
process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\""; |
277 |
process.Start(); |
278 |
} |
279 |
else |
280 |
{ |
281 |
SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message); |
282 |
} |
283 |
} |
284 |
#endregion |
285 |
|
286 |
try |
287 |
{ |
288 |
TestFile = SetFlattingPDF(TestFile); |
289 |
SetStampInPDF(FinalItem, TestFile, MarkupInfoItem); |
290 |
|
291 |
if (EndFinal != null) |
292 |
{ |
293 |
EndFinal(this, new EndFinalEventArgs |
294 |
{ |
295 |
OriginPDFName = OriginFileName, |
296 |
FinalPDFPath = FinalPDFPath.FullName, |
297 |
Error = "", |
298 |
Message = "", |
299 |
FinalPDF = FinalPDF, |
300 |
}); |
301 |
} |
302 |
} |
303 |
catch (Exception ex) |
304 |
{ |
305 |
|
306 |
throw; |
307 |
} |
308 |
} |
309 |
#endregion |
310 |
|
311 |
#region PDF |
312 |
public static float scaleWidth = 0; |
313 |
public static float scaleHeight = 0; |
314 |
|
315 |
private string SetFlattingPDF(string tempFileInfo) |
316 |
{ |
317 |
if (File.Exists(tempFileInfo)) |
318 |
{ |
319 |
FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName()); |
320 |
|
321 |
PdfReader pdfReader = new PdfReader(tempFileInfo); |
322 |
for (int i = 1; i < pdfReader.NumberOfPages; i++) |
323 |
{ |
324 |
var mediaBox = pdfReader.GetPageSize(i); |
325 |
var cropbox = pdfReader.GetCropBox(i); |
326 |
|
327 |
var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault(); |
328 |
|
329 |
PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i)); |
330 |
} |
331 |
|
332 |
var memStream = new MemoryStream(); |
333 |
var stamper = new PdfStamper(pdfReader, memStream) |
334 |
{ |
335 |
FormFlattening = true, |
336 |
FreeTextFlattening = true, |
337 |
AnnotationFlattening = true, |
338 |
}; |
339 |
|
340 |
stamper.Close(); |
341 |
pdfReader.Close(); |
342 |
var array = memStream.ToArray(); |
343 |
File.Delete(tempFileInfo); |
344 |
File.WriteAllBytes(TestFile.FullName, array); |
345 |
|
346 |
return TestFile.FullName; |
347 |
} |
348 |
else |
349 |
{ |
350 |
return tempFileInfo; |
351 |
} |
352 |
} |
353 |
|
354 |
public void flattenPdfFile(string src, ref string dest) |
355 |
{ |
356 |
PdfReader reader = new PdfReader(src); |
357 |
var memStream = new MemoryStream(); |
358 |
var stamper = new PdfStamper(reader, memStream) |
359 |
{ |
360 |
FormFlattening = true, |
361 |
FreeTextFlattening = true, |
362 |
AnnotationFlattening = true, |
363 |
}; |
364 |
|
365 |
stamper.Close(); |
366 |
var array = memStream.ToArray(); |
367 |
File.WriteAllBytes(dest, array); |
368 |
} |
369 |
|
370 |
public bool SetStampInPDF(CommonLib.MARKUS_API.FINAL_PDF finaldata, string testFile, CommonLib.MARKUS_API.MARKUP_INFO markupInfo) |
371 |
{ |
372 |
string pdfFilePath = null; |
373 |
|
374 |
FileInfo tempFileInfo = new FileInfo(testFile); |
375 |
|
376 |
if (!Directory.Exists(_FinalPDFStorgeLocal)) |
377 |
{ |
378 |
Directory.CreateDirectory(_FinalPDFStorgeLocal); |
379 |
} |
380 |
pdfFilePath = _FinalPDFStorgeLocal + @"\" + tempFileInfo.Name; |
381 |
|
382 |
#region 코멘트 적용 + 커버시트 |
383 |
using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) // |
384 |
{ |
385 |
PdfReader pdfReader = new PdfReader(pdfStream); |
386 |
//List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>(); |
387 |
Dictionary<string, object> bookmark; |
388 |
List<Dictionary<string, object>> outlines; |
389 |
outlines = new List<Dictionary<string, object>>(); |
390 |
List<Dictionary<string, object>> root = new List<Dictionary<string, object>>(); |
391 |
|
392 |
var dic = new Dictionary<string, object>(); |
393 |
foreach (var data in MarkupDataSet) |
394 |
{ |
395 |
|
396 |
string userid = string.Empty; |
397 |
string username = string.Empty; |
398 |
string userdept = string.Empty; |
399 |
using (DataController dataController = new DataController()) |
400 |
{ |
401 |
var member = dataController.GetCommentMemberInfo(finaldata.PROJECT_NO, data.ID); |
402 |
userid = member.ID; |
403 |
username = member.NAME; |
404 |
userdept = member.DEPARTMENT; |
405 |
} |
406 |
|
407 |
bookmark = new Dictionary<string, object>(); |
408 |
bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER)); |
409 |
bookmark.Add("Page", data.PAGENUMBER + " Fit"); |
410 |
bookmark.Add("Action", "GoTo"); |
411 |
bookmark.Add("Kids", outlines); |
412 |
root.Add(bookmark); |
413 |
} |
414 |
|
415 |
|
416 |
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create))) |
417 |
{ |
418 |
var _SetColor = new SolidColorBrush(Colors.Red); |
419 |
|
420 |
string[] delimiterChars = { "|DZ|" }; |
421 |
string[] delimiterChars2 = { "|" }; |
422 |
|
423 |
//pdfStamper.FormFlattening = true; //이미 선처리 작업함 |
424 |
pdfStamper.SetFullCompression(); |
425 |
_SetColor = new SolidColorBrush(Colors.Red); |
426 |
|
427 |
foreach (var markupItem in MarkupDataSet) |
428 |
{ |
429 |
pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER); |
430 |
var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER).FirstOrDefault(); |
431 |
|
432 |
mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER); |
433 |
var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER); |
434 |
|
435 |
//scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width; |
436 |
//scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height; |
437 |
|
438 |
//강인구 테스트 |
439 |
scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
440 |
scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
441 |
|
442 |
if (cropBox != null && cropBox.Width < mediaBox.Width || cropBox.Height < mediaBox.Height) |
443 |
{ |
444 |
mediaBox = cropBox; |
445 |
} |
446 |
using (DataController dc = new DataController()) |
447 |
{ |
448 |
dc.SetFinalCurrentPage(finaldata.ID, markupItem.PAGENUMBER); |
449 |
} |
450 |
|
451 |
string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
452 |
|
453 |
PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER); |
454 |
|
455 |
|
456 |
foreach (var data in markedData) |
457 |
{ |
458 |
var item = JsonSerializerHelper.UnCompressString(data); |
459 |
var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); |
460 |
|
461 |
try |
462 |
{ |
463 |
switch (ControlT.Name) |
464 |
{ |
465 |
#region LINE |
466 |
case "LineControl": |
467 |
{ |
468 |
using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item)) |
469 |
{ |
470 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
471 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
472 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
473 |
DoubleCollection DashSize = control.DashSize; |
474 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
475 |
|
476 |
var Opacity = control.Opac; |
477 |
string UserID = control.UserID; |
478 |
double Interval = control.Interval; |
479 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
480 |
Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, _SetColor, Opacity); |
481 |
switch (control.LineStyleSet) |
482 |
{ |
483 |
case LineStyleSet.ArrowLine: |
484 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
485 |
break; |
486 |
case LineStyleSet.CancelLine: |
487 |
{ |
488 |
var x = Math.Abs((Math.Abs(StartPoint.X) - Math.Abs(EndPoint.X))); |
489 |
var y = Math.Abs((Math.Abs(StartPoint.Y) - Math.Abs(EndPoint.Y))); |
490 |
|
491 |
if (x > y) |
492 |
{ |
493 |
StartPoint = new Point(StartPoint.X, StartPoint.Y - (float)(control.Interval / 3.0)); |
494 |
EndPoint = new Point(EndPoint.X, EndPoint.Y - (float)(control.Interval / 3.0)); |
495 |
Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, Opacity); |
496 |
} |
497 |
} |
498 |
break; |
499 |
case LineStyleSet.TwinLine: |
500 |
{ |
501 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
502 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
503 |
} |
504 |
break; |
505 |
case LineStyleSet.DimLine: |
506 |
{ |
507 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.DimAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
508 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
509 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
510 |
} |
511 |
break; |
512 |
default: |
513 |
break; |
514 |
} |
515 |
|
516 |
|
517 |
} |
518 |
} |
519 |
break; |
520 |
#endregion |
521 |
#region ArrowControlMulti |
522 |
case "ArrowControl_Multi": |
523 |
{ |
524 |
using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
525 |
{ |
526 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
527 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
528 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
529 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
530 |
DoubleCollection DashSize = control.DashSize; |
531 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
532 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
533 |
|
534 |
double Opacity = control.Opac; |
535 |
|
536 |
if (EndPoint == MidPoint) |
537 |
{ |
538 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
539 |
} |
540 |
else |
541 |
{ |
542 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
543 |
} |
544 |
|
545 |
Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
546 |
|
547 |
} |
548 |
} |
549 |
break; |
550 |
#endregion |
551 |
#region PolyControl |
552 |
case "PolygonControl": |
553 |
using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item)) |
554 |
{ |
555 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
556 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
557 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
558 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
559 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
560 |
double Opacity = control.Opac; |
561 |
DoubleCollection DashSize = control.DashSize; |
562 |
|
563 |
Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
564 |
} |
565 |
break; |
566 |
#endregion |
567 |
#region ArcControl |
568 |
case "ArcControl": |
569 |
{ |
570 |
using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
571 |
{ |
572 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
573 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
574 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
575 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
576 |
DoubleCollection DashSize = control.DashSize; |
577 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
578 |
|
579 |
var Opacity = control.Opac; |
580 |
string UserID = control.UserID; |
581 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
582 |
bool IsTransOn = control.IsTransOn; |
583 |
|
584 |
if (control.IsTransOn) |
585 |
{ |
586 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
587 |
Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
588 |
} |
589 |
else |
590 |
{ |
591 |
Controls_PDF.HoneyPDFLib_DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
592 |
} |
593 |
|
594 |
} |
595 |
} |
596 |
break; |
597 |
#endregion |
598 |
#region RectangleControl |
599 |
case "RectangleControl": |
600 |
using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
601 |
{ |
602 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
603 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
604 |
var PaintStyle = control.PaintState; |
605 |
double Angle = control.Angle; |
606 |
DoubleCollection DashSize = control.DashSize; |
607 |
double Opacity = control.Opac; |
608 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
609 |
|
610 |
Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
611 |
} |
612 |
break; |
613 |
#endregion |
614 |
#region TriControl |
615 |
case "TriControl": |
616 |
using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item)) |
617 |
{ |
618 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
619 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
620 |
var PaintStyle = control.Paint; |
621 |
double Angle = control.Angle; |
622 |
//StrokeColor = _SetColor, //색상은 레드 |
623 |
DoubleCollection DashSize = control.DashSize; |
624 |
double Opacity = control.Opac; |
625 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
626 |
|
627 |
Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
628 |
} |
629 |
break; |
630 |
#endregion |
631 |
#region CircleControl |
632 |
case "CircleControl": |
633 |
using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
634 |
{ |
635 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
636 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
637 |
var StartPoint = GetPdfPointSystem(control.StartPoint); |
638 |
var EndPoint = GetPdfPointSystem(control.EndPoint); |
639 |
var PaintStyle = control.PaintState; |
640 |
double Angle = control.Angle; |
641 |
DoubleCollection DashSize = control.DashSize; |
642 |
double Opacity = control.Opac; |
643 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
644 |
Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
645 |
|
646 |
} |
647 |
break; |
648 |
#endregion |
649 |
#region RectCloudControl |
650 |
case "RectCloudControl": |
651 |
using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
652 |
{ |
653 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
654 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
655 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
656 |
double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
657 |
|
658 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
659 |
|
660 |
var PaintStyle = control.PaintState; |
661 |
double Opacity = control.Opac; |
662 |
DoubleCollection DashSize = control.DashSize; |
663 |
|
664 |
//드로잉 방식이 표현되지 않음 |
665 |
var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
666 |
|
667 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
668 |
bool reverse = (area < 0); |
669 |
if (PaintStyle == PaintSet.None) |
670 |
{ |
671 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
672 |
} |
673 |
else |
674 |
{ |
675 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
676 |
} |
677 |
} |
678 |
break; |
679 |
#endregion |
680 |
#region CloudControl |
681 |
case "CloudControl": |
682 |
using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
683 |
{ |
684 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
685 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
686 |
double Toler = control.Toler; |
687 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
688 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
689 |
var PaintStyle = control.PaintState; |
690 |
double Opacity = control.Opac; |
691 |
bool isTransOn = control.IsTrans; |
692 |
bool isChain = control.IsChain; |
693 |
|
694 |
DoubleCollection DashSize = control.DashSize; |
695 |
|
696 |
if (isChain) |
697 |
{ |
698 |
Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
699 |
} |
700 |
else |
701 |
{ |
702 |
if (isTransOn) |
703 |
{ |
704 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
705 |
bool reverse = (area < 0); |
706 |
|
707 |
if (PaintStyle == PaintSet.None) |
708 |
{ |
709 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
710 |
} |
711 |
else |
712 |
{ |
713 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
714 |
} |
715 |
} |
716 |
else |
717 |
{ |
718 |
Controls_PDF.HoneyPDFLib_DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
719 |
} |
720 |
} |
721 |
} |
722 |
break; |
723 |
#endregion |
724 |
#region TEXT |
725 |
case "TextControl": |
726 |
using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
727 |
{ |
728 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
729 |
string Text = control.Text; |
730 |
|
731 |
bool isUnderline = false; |
732 |
control.BoxW -= scaleWidth; |
733 |
control.BoxH -= scaleHeight; |
734 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH); |
735 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
736 |
Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH)); |
737 |
|
738 |
List<Point> pointSet = new List<Point>(); |
739 |
pointSet.Add(StartPoint); |
740 |
pointSet.Add(EndPoint); |
741 |
|
742 |
PaintSet paint = PaintSet.None; |
743 |
switch (control.paintMethod) |
744 |
{ |
745 |
case 1: |
746 |
{ |
747 |
paint = PaintSet.Fill; |
748 |
} |
749 |
break; |
750 |
case 2: |
751 |
{ |
752 |
paint = PaintSet.Hatch; |
753 |
} |
754 |
break; |
755 |
default: |
756 |
break; |
757 |
} |
758 |
if (control.isHighLight) paint |= PaintSet.Highlight; |
759 |
|
760 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
761 |
double TextSize = Convert.ToDouble(data2[1]); |
762 |
SolidColorBrush FontColor = _SetColor; |
763 |
double Angle = control.Angle; |
764 |
double Opacity = control.Opac; |
765 |
FontFamily fontfamilly = new FontFamily(control.fontConfig[0]); |
766 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
767 |
|
768 |
FontStyle fontStyle = FontStyles.Normal; |
769 |
if (FontStyles.Italic == TextStyle) |
770 |
{ |
771 |
fontStyle = FontStyles.Italic; |
772 |
} |
773 |
|
774 |
FontWeight fontWeight = FontWeights.Black; |
775 |
|
776 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
777 |
//강인구 수정(2018.04.17) |
778 |
if (FontWeights.Bold == TextWeight) |
779 |
//if (FontWeights.ExtraBold == TextWeight) |
780 |
{ |
781 |
fontWeight = FontWeights.Bold; |
782 |
} |
783 |
|
784 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
785 |
if (control.fontConfig.Count() == 4) |
786 |
{ |
787 |
decoration = TextDecorations.Underline; |
788 |
} |
789 |
|
790 |
Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, _SetColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
791 |
} |
792 |
break; |
793 |
#endregion |
794 |
#region ArrowTextControl |
795 |
case "ArrowTextControl": |
796 |
using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
797 |
{ |
798 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
799 |
Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
800 |
Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
801 |
Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
802 |
bool isUnderLine = false; |
803 |
string Text = ""; |
804 |
double fontsize = 30; |
805 |
|
806 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
807 |
Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
808 |
List<Point> tempPoint = new List<Point>(); |
809 |
|
810 |
var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
811 |
|
812 |
tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
813 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
814 |
tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
815 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
816 |
double Angle = control.Angle; |
817 |
var newStartPoint = tempStartPoint; |
818 |
var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
819 |
var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
820 |
|
821 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
822 |
SolidColorBrush FontColor = _SetColor; |
823 |
bool isHighlight = control.isHighLight; |
824 |
double Opacity = control.Opac; |
825 |
PaintSet Paint = PaintSet.None; |
826 |
|
827 |
switch (control.ArrowStyle) |
828 |
{ |
829 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
830 |
{ |
831 |
Paint = PaintSet.None; |
832 |
} |
833 |
break; |
834 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
835 |
{ |
836 |
Paint = PaintSet.Hatch; |
837 |
} |
838 |
break; |
839 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
840 |
{ |
841 |
Paint = PaintSet.Fill; |
842 |
} |
843 |
break; |
844 |
default: |
845 |
break; |
846 |
} |
847 |
if (control.isHighLight) Paint |= PaintSet.Highlight; |
848 |
|
849 |
if (Paint == PaintSet.Hatch) |
850 |
{ |
851 |
Text = control.ArrowText; |
852 |
} |
853 |
else |
854 |
{ |
855 |
Text = control.ArrowText; |
856 |
} |
857 |
|
858 |
try |
859 |
{ |
860 |
if (control.fontConfig.Count == 4) |
861 |
{ |
862 |
fontsize = Convert.ToDouble(control.fontConfig[3]); |
863 |
} |
864 |
|
865 |
//강인구 수정(2018.04.17) |
866 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
867 |
|
868 |
FontStyle fontStyle = FontStyles.Normal; |
869 |
if (FontStyles.Italic == TextStyle) |
870 |
{ |
871 |
fontStyle = FontStyles.Italic; |
872 |
} |
873 |
|
874 |
FontWeight fontWeight = FontWeights.Black; |
875 |
|
876 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
877 |
if (FontWeights.Bold == TextWeight) |
878 |
{ |
879 |
fontWeight = FontWeights.Bold; |
880 |
} |
881 |
|
882 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
883 |
if (control.fontConfig.Count() == 5) |
884 |
{ |
885 |
decoration = TextDecorations.Underline; |
886 |
} |
887 |
|
888 |
if (control.isTrans) |
889 |
{ |
890 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
891 |
Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
892 |
newStartPoint, tempMidPoint, |
893 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
894 |
} |
895 |
else |
896 |
{ |
897 |
if (control.isFixed) |
898 |
{ |
899 |
var testP = new Point(0, 0); |
900 |
if (control.isFixed) |
901 |
{ |
902 |
if (tempPoint[1] == newEndPoint) |
903 |
{ |
904 |
testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
905 |
} |
906 |
else if (tempPoint[3] == newEndPoint) |
907 |
{ |
908 |
testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
909 |
} |
910 |
else if (tempPoint[0] == newEndPoint) |
911 |
{ |
912 |
testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
913 |
} |
914 |
else if (tempPoint[2] == newEndPoint) |
915 |
{ |
916 |
testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
917 |
} |
918 |
} |
919 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
920 |
Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
921 |
tempStartPoint, testP, |
922 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
923 |
new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
924 |
} |
925 |
else |
926 |
{ |
927 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
928 |
Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
929 |
newStartPoint, newMidPoint, |
930 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, new FontFamily(), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
931 |
} |
932 |
} |
933 |
} |
934 |
catch (Exception ex) |
935 |
{ |
936 |
|
937 |
} |
938 |
} |
939 |
break; |
940 |
#endregion |
941 |
#region SignControl |
942 |
case "SignControl": |
943 |
using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
944 |
{ |
945 |
|
946 |
double Angle = control.Angle; |
947 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
948 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
949 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
950 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
951 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
952 |
double Opacity = control.Opac; |
953 |
string UserNumber = control.UserNumber; |
954 |
Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
955 |
} |
956 |
break; |
957 |
#endregion |
958 |
#region MyRegion |
959 |
case "DateControl": |
960 |
using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
961 |
{ |
962 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
963 |
string Text = control.Text; |
964 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
965 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
966 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
967 |
SolidColorBrush FontColor = _SetColor; |
968 |
double Angle = control.Angle; |
969 |
double Opacity = control.Opac; |
970 |
Controls_PDF.HoneyPDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
971 |
} |
972 |
break; |
973 |
#endregion |
974 |
#region SymControlN (APPROVED) |
975 |
case "SymControlN": |
976 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
977 |
{ |
978 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
979 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
980 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
981 |
SolidColorBrush FontColor = _SetColor; |
982 |
double Angle = control.Angle; |
983 |
double Opacity = control.Opac; |
984 |
|
985 |
string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
986 |
Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawApproval(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
987 |
} |
988 |
break; |
989 |
case "SymControl": |
990 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
991 |
{ |
992 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
993 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
994 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
995 |
SolidColorBrush FontColor = _SetColor; |
996 |
double Angle = control.Angle; |
997 |
double Opacity = control.Opac; |
998 |
|
999 |
string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
1000 |
Controls_PDF.HoneyPDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
1001 |
} |
1002 |
break; |
1003 |
#endregion |
1004 |
#region Image |
1005 |
case "ImgControl": |
1006 |
using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
1007 |
{ |
1008 |
double Angle = control.Angle; |
1009 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1010 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
1011 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1012 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
1013 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1014 |
double Opacity = control.Opac; |
1015 |
string FilePath = control.ImagePath; |
1016 |
//Uri uri = new Uri(s.ImagePath); |
1017 |
|
1018 |
Controls_PDF.HoneyPDFLib_DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
1019 |
} |
1020 |
break; |
1021 |
#endregion |
1022 |
default: |
1023 |
break; |
1024 |
} |
1025 |
} |
1026 |
catch (Exception ex) |
1027 |
{ |
1028 |
|
1029 |
} |
1030 |
} |
1031 |
} |
1032 |
pdfStamper.Outlines = root; |
1033 |
pdfStamper.Close(); |
1034 |
pdfReader.Close(); |
1035 |
} |
1036 |
} |
1037 |
#endregion |
1038 |
|
1039 |
try |
1040 |
{ |
1041 |
if (tempFileInfo.Exists) |
1042 |
{ |
1043 |
tempFileInfo.Delete(); |
1044 |
} |
1045 |
|
1046 |
if (File.Exists(pdfFilePath)) |
1047 |
{ |
1048 |
|
1049 |
FinalPDFPath = new FileInfo(pdfFilePath); |
1050 |
|
1051 |
///TODO : 복사할 경로를 configuration으로 빼주세요 |
1052 |
|
1053 |
string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
1054 |
File.Move(FinalPDFPath.FullName, pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
1055 |
FinalPDFPath = new FileInfo(pdfmovepath + FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
1056 |
|
1057 |
try |
1058 |
{ |
1059 |
File.Delete(pdfFilePath); |
1060 |
} |
1061 |
catch (Exception ex) |
1062 |
{ |
1063 |
System.Diagnostics.Debug.Write("삭제 불가" + ex.Message); |
1064 |
} |
1065 |
// |
1066 |
|
1067 |
return true; |
1068 |
} |
1069 |
} |
1070 |
catch (Exception ex) |
1071 |
{ |
1072 |
|
1073 |
throw; |
1074 |
} |
1075 |
|
1076 |
return false; |
1077 |
} |
1078 |
|
1079 |
public void Dispose() |
1080 |
{ |
1081 |
throw new NotImplementedException(); |
1082 |
} |
1083 |
|
1084 |
#endregion |
1085 |
} |
1086 |
} |