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