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