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