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