markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 50ffdad1
이력 | 보기 | 이력해설 | 다운로드 (93.9 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 Markus.Fonts; |
9 |
using System; |
10 |
using System.Collections.Generic; |
11 |
using System.Configuration; |
12 |
using System.IO; |
13 |
using System.Linq; |
14 |
using System.Net; |
15 |
using System.Runtime.InteropServices; |
16 |
using System.Text; |
17 |
using System.Web; |
18 |
using System.Windows; |
19 |
using System.Windows.Media; |
20 |
|
21 |
namespace MarkupToPDF |
22 |
{ |
23 |
public class MarkupToPDF : IDisposable |
24 |
{ |
25 |
public MarkupToPDF() |
26 |
{ |
27 |
} |
28 |
|
29 |
#region 초기 데이터 |
30 |
private FileInfo PdfFilePath = null; |
31 |
private FileInfo FinalPDFPath = null; |
32 |
private string _FinalPDFStorgeLocal = null; |
33 |
private string _FinalPDFStorgeRemote = null; |
34 |
private string OriginFileName = null; |
35 |
public FINAL_PDF FinalItem; |
36 |
public DOCINFO DocInfoItem = null; |
37 |
public List<DOCPAGE> DocPageItem = null; |
38 |
public MARKUP_INFO MarkupInfoItem = null; |
39 |
public List<MARKUP_DATA> MarkupDataSet = null; |
40 |
//private string _PrintPDFStorgeLocal = null; |
41 |
//private string _PrintPDFStorgeRemote = null; |
42 |
public event EventHandler<MakeFinalErrorArgs> FinalMakeError; |
43 |
public event EventHandler<EndFinalEventArgs> EndFinal; |
44 |
public event EventHandler<StatusChangedEventArgs> StatusChanged; |
45 |
|
46 |
private iTextSharp.text.Rectangle pdfSize { get; set; } |
47 |
private double pageW = 0; |
48 |
private double pageH = 0; |
49 |
|
50 |
//private const double zoomLevel = 3.0; |
51 |
private const double zoomLevel = 1.0; // 지금은 3배수로 곱하지 않고 있음 |
52 |
#endregion |
53 |
|
54 |
#region 메서드 |
55 |
public static bool IsLocalIPAddress(string host) |
56 |
{ |
57 |
try |
58 |
{ |
59 |
IPAddress[] hostIPs = Dns.GetHostAddresses(host); |
60 |
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); |
61 |
|
62 |
foreach (IPAddress hostIP in hostIPs) |
63 |
{ |
64 |
if (IPAddress.IsLoopback(hostIP)) return true; |
65 |
|
66 |
foreach (IPAddress localIP in localIPs) |
67 |
{ |
68 |
if (hostIP.Equals(localIP)) return true; |
69 |
} |
70 |
} |
71 |
} |
72 |
catch { } |
73 |
return false; |
74 |
} |
75 |
|
76 |
private void SetNotice(string finalID, string message) |
77 |
{ |
78 |
if (FinalMakeError != null) |
79 |
{ |
80 |
FinalMakeError(this, new MakeFinalErrorArgs { FinalID = finalID, Message = message }); |
81 |
} |
82 |
} |
83 |
|
84 |
private string GetFileName(string hrefLink) |
85 |
{ |
86 |
try |
87 |
{ |
88 |
if (hrefLink.Contains("vpcs_doclib")) |
89 |
{ |
90 |
return System.IO.Path.GetFileName(hrefLink.Replace("/", "\\")); |
91 |
} |
92 |
else |
93 |
{ |
94 |
Uri fileurl = new Uri(hrefLink); |
95 |
int index = hrefLink.IndexOf("?"); |
96 |
string filename = HttpUtility.ParseQueryString(fileurl.Query).Get("fileName"); |
97 |
return filename; |
98 |
} |
99 |
} |
100 |
catch (Exception ex) |
101 |
{ |
102 |
throw ex; |
103 |
} |
104 |
} |
105 |
|
106 |
public Point GetPdfPointSystem(Point point) |
107 |
{ |
108 |
/// 주어진 좌표를 pdf의 (Left, Top - Bottom(?)) 좌표에 맞추어 변환한다. |
109 |
/// Rotation 90 일 경우 pdfsize box 와 media box 가 달라 다른 계산식 적용 |
110 |
if (pdfSize.Rotation == 90) |
111 |
{ |
112 |
return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Top - (float)(point.Y / scaleHeight) - pdfSize.Bottom); |
113 |
} |
114 |
else |
115 |
{ |
116 |
return new Point(pdfSize.Left + (float)(point.X / scaleWidth), pdfSize.Height - (float)(point.Y / scaleHeight) + pdfSize.Bottom); |
117 |
} |
118 |
} |
119 |
|
120 |
public double GetPdfSize(double size) |
121 |
{ |
122 |
return (size / scaleWidth); |
123 |
} |
124 |
|
125 |
public List<Point> GetPdfPointSystem(List<Point> point) |
126 |
{ |
127 |
List<Point> dummy = new List<Point>(); |
128 |
foreach (var item in point) |
129 |
{ |
130 |
dummy.Add(GetPdfPointSystem(item)); |
131 |
} |
132 |
return dummy; |
133 |
} |
134 |
|
135 |
public double returnAngle(Point start, Point end) |
136 |
{ |
137 |
double angle = MathSet.getAngle(start.X, start.Y, end.X, end.Y); |
138 |
//angle *= -1; |
139 |
|
140 |
angle += 90; |
141 |
//if (angle < 0) |
142 |
//{ |
143 |
// angle = angle + 360; |
144 |
//} |
145 |
return angle; |
146 |
} |
147 |
|
148 |
#endregion |
149 |
|
150 |
public bool AddStamp(string stampData) |
151 |
{ |
152 |
bool result = false; |
153 |
|
154 |
try |
155 |
{ |
156 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
157 |
{ |
158 |
var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
159 |
|
160 |
if(stamp.Count() > 0) |
161 |
{ |
162 |
var xamldata = Serialize.Core.JsonSerializerHelper.CompressStamp(stampData); |
163 |
|
164 |
stamp.First().VALUE = xamldata; |
165 |
_entity.SaveChanges(); |
166 |
result = true; |
167 |
} |
168 |
} |
169 |
} |
170 |
catch (Exception) |
171 |
{ |
172 |
|
173 |
throw; |
174 |
} |
175 |
|
176 |
return result; |
177 |
|
178 |
} |
179 |
|
180 |
#region 생성자 & 소멸자 |
181 |
public void MakeFinalPDF(object _FinalPDF) |
182 |
{ |
183 |
DOCUMENT_ITEM documentItem; |
184 |
FINAL_PDF FinalPDF = (FINAL_PDF)_FinalPDF; |
185 |
FinalItem = FinalPDF; |
186 |
|
187 |
|
188 |
string PdfFilePathRoot = null; |
189 |
string TestFile = System.IO.Path.GetTempFileName(); |
190 |
|
191 |
#region 문서 경로를 가져오는 것과 Status를 Create (1단계) 로 수정 |
192 |
try |
193 |
{ |
194 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
195 |
{ |
196 |
var _properties = _entity.PROPERTIES.Where(pro => pro.PROPERTY == FinalPDF.PROJECT_NO); |
197 |
|
198 |
if (_properties.Count() > 0) |
199 |
{ |
200 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).Count() == 0) |
201 |
{ |
202 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : TileSourcePath Not Found."); |
203 |
return; |
204 |
} |
205 |
else |
206 |
{ |
207 |
PdfFilePathRoot = _properties.Where(t => t.TYPE == PropertiesType.Const_TileSorcePath).First().VALUE; |
208 |
} |
209 |
|
210 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).Count() == 0) |
211 |
{ |
212 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeLocal Not Found."); |
213 |
return; |
214 |
} |
215 |
else |
216 |
{ |
217 |
_FinalPDFStorgeLocal = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeLocal).First().VALUE; |
218 |
} |
219 |
|
220 |
|
221 |
if (_properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).Count() == 0) |
222 |
{ |
223 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : FinalPDFStorgeRemote Not Found."); |
224 |
return; |
225 |
} |
226 |
else |
227 |
{ |
228 |
_FinalPDFStorgeRemote = _properties.Where(t => t.TYPE == PropertiesType.Const_FinalPDFStorgeRemote).First().VALUE; |
229 |
} |
230 |
} |
231 |
else |
232 |
{ |
233 |
SetNotice(FinalPDF.ID, $"Project {FinalPDF.PROJECT_NO} : Final PDF Properties Not Found."); |
234 |
return; |
235 |
} |
236 |
|
237 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
238 |
|
239 |
if (finalList.Count() > 0) |
240 |
{ |
241 |
finalList.FirstOrDefault().START_DATETIME = DateTime.Now; |
242 |
finalList.FirstOrDefault().STATUS = (int)FinalStatus.Create; |
243 |
_entity.SaveChanges(); |
244 |
} |
245 |
|
246 |
} |
247 |
} |
248 |
catch (Exception ex) |
249 |
{ |
250 |
SetNotice(FinalPDF.ID, "프로퍼티 에러: " + ex.ToString()); |
251 |
return; |
252 |
} |
253 |
#endregion |
254 |
|
255 |
#region 문서 복사 |
256 |
try |
257 |
{ |
258 |
using (CIEntities _entity = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(FinalPDF.PROJECT_NO).ToString())) |
259 |
{ |
260 |
var _DOCINFO = _entity.DOCINFO.Where(doc => doc.ID == FinalPDF.DOCINFO_ID); |
261 |
|
262 |
if (_DOCINFO.Count() > 0) |
263 |
{ |
264 |
DocInfoItem = _DOCINFO.First(); |
265 |
|
266 |
DocPageItem = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == DocInfoItem.ID).ToList(); |
267 |
|
268 |
PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\" |
269 |
+ (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5)) |
270 |
+ @"\" + FinalPDF.DOCUMENT_ID + @"\"; |
271 |
|
272 |
var infoItems = _entity.MARKUP_INFO.Where(x => x.DOCINFO_ID == DocInfoItem.ID && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0); |
273 |
|
274 |
if (infoItems.Count() == 0) |
275 |
{ |
276 |
throw new InvalidOperationException("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
277 |
} |
278 |
else |
279 |
{ |
280 |
MarkupInfoItem = infoItems.First(); |
281 |
|
282 |
var markupInfoVerItems = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == MarkupInfoItem.ID).ToList(); |
283 |
|
284 |
if (markupInfoVerItems.Count() > 0) |
285 |
{ |
286 |
var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First(); |
287 |
|
288 |
MarkupDataSet = _entity.MARKUP_DATA.Where(x => x.MARKUPINFO_VERSION_ID == markupInfoVerItem.ID).OrderBy(d => d.PAGENUMBER).ToList(); |
289 |
} |
290 |
else |
291 |
{ |
292 |
throw new InvalidOperationException("MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
293 |
} |
294 |
} |
295 |
|
296 |
documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault(); |
297 |
if (documentItem == null) |
298 |
{ |
299 |
throw new InvalidOperationException("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
300 |
} |
301 |
|
302 |
var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 |
303 |
|
304 |
#region 파일 체크 |
305 |
if (_files.Count() == 1) |
306 |
{ |
307 |
/// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정 |
308 |
//if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
309 |
//{ |
310 |
OriginFileName = _files.First().Name; |
311 |
PdfFilePath = _files.First().CopyTo(TestFile, true); |
312 |
StatusChange($"Copy File file Count = 1 : {PdfFilePath}", 0); |
313 |
//} |
314 |
//else |
315 |
//{ |
316 |
// throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()); |
317 |
//} |
318 |
} |
319 |
else if (_files.Count() > 1) |
320 |
{ |
321 |
var originalFile = _files.FirstOrDefault(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))); |
322 |
|
323 |
if (originalFile == null) |
324 |
{ |
325 |
throw new FileNotFoundException("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
326 |
} |
327 |
else |
328 |
{ |
329 |
OriginFileName = originalFile.Name; |
330 |
PdfFilePath = originalFile.CopyTo(TestFile, true); |
331 |
StatusChange($"Copy File file Count > 1 : {PdfFilePath}", 0); |
332 |
} |
333 |
} |
334 |
else |
335 |
{ |
336 |
throw new FileNotFoundException("PDF를 찾지 못하였습니다"); |
337 |
} |
338 |
#endregion |
339 |
|
340 |
#region 예외처리 |
341 |
if (PdfFilePath == null) |
342 |
{ |
343 |
throw new InvalidOperationException("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
344 |
} |
345 |
if (!PdfFilePath.Exists) |
346 |
{ |
347 |
throw new FileNotFoundException("PDF원본이 존재하지 않습니다"); |
348 |
} |
349 |
#endregion |
350 |
|
351 |
} |
352 |
else |
353 |
{ |
354 |
throw new InvalidOperationException("일치하는 DocInfo가 없습니다"); |
355 |
} |
356 |
} |
357 |
} |
358 |
catch (Exception ex) |
359 |
{ |
360 |
if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다") |
361 |
{ |
362 |
SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
363 |
//System.Diagnostics.Process process = new System.Diagnostics.Process(); |
364 |
//process.StartInfo.FileName = "cmd"; |
365 |
//process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\""; |
366 |
//process.Start(); |
367 |
} |
368 |
else |
369 |
{ |
370 |
SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message); |
371 |
} |
372 |
} |
373 |
#endregion |
374 |
|
375 |
try |
376 |
{ |
377 |
|
378 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
379 |
{ |
380 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
381 |
if (finalList.Count() > 0) |
382 |
{ |
383 |
//TestFile = SetFlattingPDF(TestFile); |
384 |
//StatusChange($"SetFlattingPDF : {TestFile}", 0); |
385 |
|
386 |
SetStampInPDF(FinalItem, TestFile, MarkupInfoItem); |
387 |
|
388 |
StatusChange($"SetStampInPDF : {TestFile}", 0); |
389 |
} |
390 |
} |
391 |
if (EndFinal != null) |
392 |
{ |
393 |
EndFinal(this, new EndFinalEventArgs |
394 |
{ |
395 |
FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name, |
396 |
OriginPDFName = OriginFileName, |
397 |
FinalPDFPath = FinalPDFPath.FullName, |
398 |
Error = "", |
399 |
Message = "", |
400 |
FinalPDF = FinalPDF, |
401 |
}); |
402 |
} |
403 |
} |
404 |
catch (Exception ex) |
405 |
{ |
406 |
SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message); |
407 |
} |
408 |
} |
409 |
#endregion |
410 |
|
411 |
#region PDF |
412 |
public static float scaleWidth { get; set; } = 0; |
413 |
public static float scaleHeight { get; set; } = 0; |
414 |
|
415 |
private string SetFlattingPDF(string tempFileInfo) |
416 |
{ |
417 |
if (File.Exists(tempFileInfo)) |
418 |
{ |
419 |
FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName()); |
420 |
|
421 |
PdfReader pdfReader = new PdfReader(tempFileInfo); |
422 |
|
423 |
for (int i = 1; i <= pdfReader.NumberOfPages; i++) |
424 |
{ |
425 |
var mediaBox = pdfReader.GetPageSize(i); |
426 |
var cropbox = pdfReader.GetCropBox(i); |
427 |
|
428 |
//using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString())) |
429 |
//{ |
430 |
// _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE) |
431 |
//} |
432 |
var currentPage = DocPageItem.Find(d => d.PAGE_NUMBER == i); |
433 |
|
434 |
//scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width; |
435 |
//scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height; |
436 |
//scaleWidth = 2.0832634F; |
437 |
//scaleHeight = 3.0F; |
438 |
|
439 |
PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i)); |
440 |
//강인구 수정 |
441 |
//if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height)) |
442 |
//if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height)) |
443 |
//{ |
444 |
// var pageDict = pdfReader.GetPageN(i); |
445 |
// pageDict.Put(PdfName.MEDIABOX, rect); |
446 |
//} |
447 |
} |
448 |
|
449 |
var memStream = new MemoryStream(); |
450 |
var stamper = new PdfStamper(pdfReader, memStream) |
451 |
{ |
452 |
FormFlattening = true, |
453 |
//FreeTextFlattening = true, |
454 |
//AnnotationFlattening = true, |
455 |
}; |
456 |
|
457 |
stamper.Close(); |
458 |
pdfReader.Close(); |
459 |
var array = memStream.ToArray(); |
460 |
File.Delete(tempFileInfo); |
461 |
File.WriteAllBytes(TestFile.FullName, array); |
462 |
|
463 |
return TestFile.FullName; |
464 |
} |
465 |
else |
466 |
{ |
467 |
return tempFileInfo; |
468 |
} |
469 |
} |
470 |
|
471 |
public void flattenPdfFile(string src, ref string dest) |
472 |
{ |
473 |
PdfReader reader = new PdfReader(src); |
474 |
var memStream = new MemoryStream(); |
475 |
var stamper = new PdfStamper(reader, memStream) |
476 |
{ |
477 |
FormFlattening = true, |
478 |
FreeTextFlattening = true, |
479 |
AnnotationFlattening = true, |
480 |
}; |
481 |
|
482 |
stamper.Close(); |
483 |
var array = memStream.ToArray(); |
484 |
File.WriteAllBytes(dest, array); |
485 |
} |
486 |
|
487 |
public void StatusChange(string message,int CurrentPage) |
488 |
{ |
489 |
if(StatusChanged != null) |
490 |
{ |
491 |
//var sb = new StringBuilder(); |
492 |
//sb.AppendLine(message); |
493 |
|
494 |
StatusChanged(this, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = message }); |
495 |
} |
496 |
} |
497 |
|
498 |
/// <summary> |
499 |
/// PDF에 Markup 데이터를 쓴다. |
500 |
/// </summary> |
501 |
/// <param name="finaldata"></param> |
502 |
/// <param name="testFile"></param> |
503 |
/// <param name="markupInfo"></param> |
504 |
/// <returns></returns> |
505 |
public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo) |
506 |
{ |
507 |
try |
508 |
{ |
509 |
FileInfo tempFileInfo = new FileInfo(testFile); |
510 |
|
511 |
if (!Directory.Exists(_FinalPDFStorgeLocal)) |
512 |
{ |
513 |
Directory.CreateDirectory(_FinalPDFStorgeLocal); |
514 |
} |
515 |
|
516 |
string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name); |
517 |
|
518 |
|
519 |
using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
520 |
{ |
521 |
FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault(); |
522 |
|
523 |
#region 코멘트 적용 + 커버시트 |
524 |
using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) // |
525 |
{ |
526 |
StatusChange("comment Cover",0); |
527 |
|
528 |
using (PdfReader pdfReader = new PdfReader(pdfStream)) |
529 |
{ |
530 |
//List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>(); |
531 |
Dictionary<string, object> bookmark; |
532 |
List<Dictionary<string, object>> outlines; |
533 |
|
534 |
outlines = new List<Dictionary<string, object>>(); |
535 |
List<Dictionary<string, object>> root = new List<Dictionary<string, object>>(); |
536 |
|
537 |
var dic = new Dictionary<string, object>(); |
538 |
|
539 |
#region 북마크 생성 |
540 |
foreach (var data in MarkupDataSet) |
541 |
{ |
542 |
//StatusChange("MarkupDataSet", 0); |
543 |
|
544 |
string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID; |
545 |
|
546 |
string username = ""; |
547 |
string userdept = ""; |
548 |
|
549 |
using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString())) |
550 |
{ |
551 |
var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid); |
552 |
|
553 |
if(memberlist.Any()) |
554 |
{ |
555 |
username = memberlist[0].NAME; |
556 |
userdept = memberlist[0].DEPARTMENT; |
557 |
} |
558 |
} |
559 |
|
560 |
bookmark = new Dictionary<string, object>(); |
561 |
bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER)); |
562 |
bookmark.Add("Page", data.PAGENUMBER + " Fit"); |
563 |
bookmark.Add("Action", "GoTo"); |
564 |
bookmark.Add("Kids", outlines); |
565 |
root.Add(bookmark); |
566 |
} |
567 |
#endregion |
568 |
|
569 |
iTextSharp.text.Version.GetInstance(); |
570 |
|
571 |
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create))) |
572 |
{ |
573 |
try |
574 |
{ |
575 |
if (pdfStamper.AcroFields != null && pdfStamper.AcroFields.GenerateAppearances != true) |
576 |
{ |
577 |
pdfStamper.AcroFields.GenerateAppearances = true; |
578 |
} |
579 |
} |
580 |
catch (Exception ex) |
581 |
{ |
582 |
SetNotice(FinalItem.ID, "this pdf is not AcroForm."); |
583 |
} |
584 |
|
585 |
#region Markup 색상을 설정한다.(DB에 값이 있으면 DB 값으로 설정한다.) |
586 |
System.Drawing.Color _SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red); |
587 |
#endregion |
588 |
|
589 |
string[] delimiterChars = { "|DZ|" }; |
590 |
string[] delimiterChars2 = { "|" }; |
591 |
|
592 |
//pdfStamper.FormFlattening = true; //이미 선처리 작업함 |
593 |
pdfStamper.SetFullCompression(); |
594 |
_SetColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.Red); |
595 |
|
596 |
StringBuilder strLog = new StringBuilder(); |
597 |
int lastPageNo = 0; |
598 |
|
599 |
//strLog.Append($"Write {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")} markup Count : {MarkupDataSet.Count()} / "); |
600 |
|
601 |
var groups = MarkupDataSet.GroupBy(x => x.PAGENUMBER); |
602 |
foreach (var group in groups) |
603 |
{ |
604 |
int PageNumber = group.Key; |
605 |
#region ZIndex 값으로 정렬한다. |
606 |
var items = new List<Tuple<string, S_BaseControl>>(); |
607 |
foreach (var item in group) |
608 |
{ |
609 |
var tokens = item.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries).ToList(); |
610 |
items.AddRange(tokens.ConvertAll(x => |
611 |
{ |
612 |
var str = JsonSerializerHelper.UnCompressString(x); |
613 |
var control = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(str); |
614 |
return new Tuple<string, S_BaseControl>(str, control); |
615 |
})); |
616 |
} |
617 |
|
618 |
var zgroups = items.GroupBy(x => x.Item2.ZIndex).OrderBy(x => x.Key); |
619 |
#endregion |
620 |
|
621 |
foreach (var zgroup in zgroups) |
622 |
{ |
623 |
var ordered = zgroup.OrderBy(x => x.Item2.Index); |
624 |
foreach (var order in ordered) |
625 |
{ |
626 |
/// 2020.11.13 김태성 |
627 |
/// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함. |
628 |
var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == PageNumber); |
629 |
if (pageitems.Any()) |
630 |
{ |
631 |
var currentPage = pageitems.First(); |
632 |
pdfSize = pdfReader.GetPageSizeWithRotation(PageNumber); |
633 |
lastPageNo = PageNumber; |
634 |
|
635 |
iTextSharp.text.Rectangle mediaBox = pdfReader.GetPageSize(PageNumber); |
636 |
var cropBox = pdfReader.GetCropBox(PageNumber); |
637 |
|
638 |
/// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다 |
639 |
if (cropBox != null && |
640 |
(cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom)) |
641 |
{ |
642 |
PdfDictionary dict = pdfReader.GetPageN(PageNumber); |
643 |
|
644 |
PdfArray oNewMediaBox = new PdfArray(); |
645 |
oNewMediaBox.Add(new PdfNumber(cropBox.Left)); |
646 |
oNewMediaBox.Add(new PdfNumber(cropBox.Top)); |
647 |
oNewMediaBox.Add(new PdfNumber(cropBox.Right)); |
648 |
oNewMediaBox.Add(new PdfNumber(cropBox.Bottom)); |
649 |
dict.Put(PdfName.MEDIABOX, oNewMediaBox); |
650 |
|
651 |
pdfSize = cropBox; |
652 |
} |
653 |
|
654 |
scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
655 |
scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
656 |
|
657 |
pdfLink.CURRENT_PAGE = PageNumber; |
658 |
_entity.SaveChanges(); |
659 |
|
660 |
PdfContentByte contentByte = pdfStamper.GetOverContent(PageNumber); |
661 |
var item = order.Item1; |
662 |
var ControlT = order.Item2; |
663 |
|
664 |
try |
665 |
{ |
666 |
switch (ControlT.Name) |
667 |
{ |
668 |
#region LINE |
669 |
case "LineControl": |
670 |
{ |
671 |
using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item)) |
672 |
{ |
673 |
DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
674 |
} |
675 |
} |
676 |
break; |
677 |
#endregion |
678 |
#region ArrowControlMulti |
679 |
case "ArrowControl_Multi": |
680 |
{ |
681 |
using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
682 |
{ |
683 |
DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
684 |
} |
685 |
} |
686 |
break; |
687 |
#endregion |
688 |
#region PolyControl |
689 |
case "PolygonControl": |
690 |
using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item)) |
691 |
{ |
692 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
693 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
694 |
var PaintStyle = control.PaintState; |
695 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
696 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
697 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
698 |
double Opacity = control.Opac; |
699 |
DoubleCollection DashSize = control.DashSize; |
700 |
|
701 |
Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity); |
702 |
//Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
703 |
} |
704 |
break; |
705 |
#endregion |
706 |
#region ArcControl or ArrowArcControl |
707 |
case "ArcControl": |
708 |
case "ArrowArcControl": |
709 |
{ |
710 |
using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
711 |
{ |
712 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
713 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
714 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
715 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
716 |
DoubleCollection DashSize = control.DashSize; |
717 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
718 |
|
719 |
var Opacity = control.Opac; |
720 |
string UserID = control.UserID; |
721 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
722 |
bool IsTransOn = control.IsTransOn; |
723 |
|
724 |
if (control.IsTransOn) |
725 |
{ |
726 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
727 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
728 |
} |
729 |
else |
730 |
{ |
731 |
Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity); |
732 |
} |
733 |
|
734 |
if (ControlT.Name == "ArrowArcControl") |
735 |
{ |
736 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
737 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
738 |
} |
739 |
} |
740 |
} |
741 |
break; |
742 |
#endregion |
743 |
#region RectangleControl |
744 |
case "RectangleControl": |
745 |
using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
746 |
{ |
747 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
748 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
749 |
var PaintStyle = control.PaintState; |
750 |
double Angle = control.Angle; |
751 |
DoubleCollection DashSize = control.DashSize; |
752 |
double Opacity = control.Opac; |
753 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
754 |
|
755 |
Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
756 |
} |
757 |
break; |
758 |
#endregion |
759 |
#region TriControl |
760 |
case "TriControl": |
761 |
using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item)) |
762 |
{ |
763 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
764 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
765 |
var PaintStyle = control.Paint; |
766 |
double Angle = control.Angle; |
767 |
//StrokeColor = _SetColor, //색상은 레드 |
768 |
DoubleCollection DashSize = control.DashSize; |
769 |
double Opacity = control.Opac; |
770 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
771 |
|
772 |
Controls_PDF.DrawSet_Shape.DrawTriangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity); |
773 |
} |
774 |
break; |
775 |
#endregion |
776 |
#region CircleControl |
777 |
case "CircleControl": |
778 |
using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
779 |
{ |
780 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
781 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
782 |
var StartPoint = GetPdfPointSystem(control.StartPoint); |
783 |
var EndPoint = GetPdfPointSystem(control.EndPoint); |
784 |
var PaintStyle = control.PaintState; |
785 |
double Angle = control.Angle; |
786 |
DoubleCollection DashSize = control.DashSize; |
787 |
double Opacity = control.Opac; |
788 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
789 |
Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
790 |
|
791 |
} |
792 |
break; |
793 |
#endregion |
794 |
#region RectCloudControl |
795 |
case "RectCloudControl": |
796 |
using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
797 |
{ |
798 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
799 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
800 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
801 |
double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
802 |
|
803 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
804 |
|
805 |
var PaintStyle = control.PaintState; |
806 |
double Opacity = control.Opac; |
807 |
DoubleCollection DashSize = control.DashSize; |
808 |
|
809 |
//드로잉 방식이 표현되지 않음 |
810 |
var rotate = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
811 |
|
812 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
813 |
bool reverse = (area < 0); |
814 |
|
815 |
Controls_PDF.DrawSet_Cloud.DrawCloudRect(PointSet, LineSize, (int)rotate, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
816 |
} |
817 |
break; |
818 |
#endregion |
819 |
#region CloudControl |
820 |
case "CloudControl": |
821 |
using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
822 |
{ |
823 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
824 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
825 |
double Toler = control.Toler; |
826 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
827 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
828 |
var PaintStyle = control.PaintState; |
829 |
double Opacity = control.Opac; |
830 |
bool isTransOn = control.IsTrans; |
831 |
bool isChain = control.IsChain; |
832 |
|
833 |
DoubleCollection DashSize = control.DashSize; |
834 |
|
835 |
if (isChain) |
836 |
{ |
837 |
Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
838 |
} |
839 |
else |
840 |
{ |
841 |
if (isTransOn) |
842 |
{ |
843 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
844 |
bool reverse = (area < 0); |
845 |
|
846 |
if (PaintStyle == PaintSet.None) |
847 |
{ |
848 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
849 |
} |
850 |
else |
851 |
{ |
852 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
853 |
} |
854 |
} |
855 |
else |
856 |
{ |
857 |
Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
858 |
} |
859 |
} |
860 |
} |
861 |
break; |
862 |
#endregion |
863 |
#region TEXT |
864 |
case "TextControl": |
865 |
using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
866 |
{ |
867 |
DrawTextBox(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
868 |
} |
869 |
break; |
870 |
#endregion |
871 |
#region ArrowTextControl |
872 |
case "ArrowTextControl": |
873 |
using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
874 |
{ |
875 |
//using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
876 |
//{ |
877 |
// textcontrol.Angle = control.Angle; |
878 |
// textcontrol.BoxH = control.BoxHeight; |
879 |
// textcontrol.BoxW = control.BoxWidth; |
880 |
// textcontrol.EndPoint = control.EndPoint; |
881 |
// textcontrol.FontColor = "#FFFF0000"; |
882 |
// textcontrol.Name = "TextControl"; |
883 |
// textcontrol.Opac = control.Opac; |
884 |
// textcontrol.PointSet = new List<Point>(); |
885 |
// textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]); |
886 |
// textcontrol.StartPoint = control.StartPoint; |
887 |
// textcontrol.Text = control.ArrowText; |
888 |
// textcontrol.TransformPoint = control.TransformPoint; |
889 |
// textcontrol.UserID = null; |
890 |
// textcontrol.fontConfig = control.fontConfig; |
891 |
// textcontrol.isHighLight = control.isHighLight; |
892 |
// textcontrol.paintMethod = 1; |
893 |
|
894 |
// DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
895 |
//} |
896 |
|
897 |
//using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
898 |
//{ |
899 |
// linecontrol.Angle = control.Angle; |
900 |
// linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 }); |
901 |
// linecontrol.EndPoint = control.EndPoint; |
902 |
// linecontrol.MidPoint = control.MidPoint; |
903 |
// linecontrol.Name = "ArrowControl_Multi"; |
904 |
// linecontrol.Opac = control.Opac; |
905 |
// linecontrol.PointSet = control.PointSet; |
906 |
// linecontrol.SizeSet = control.SizeSet; |
907 |
// linecontrol.StartPoint = control.StartPoint; |
908 |
// linecontrol.StrokeColor = control.StrokeColor; |
909 |
// linecontrol.TransformPoint = control.TransformPoint; |
910 |
|
911 |
// DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
912 |
//} |
913 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
914 |
Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
915 |
Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
916 |
Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
917 |
bool isUnderLine = false; |
918 |
string Text = ""; |
919 |
double fontsize = 30; |
920 |
|
921 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
922 |
Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
923 |
List<Point> tempPoint = new List<Point>(); |
924 |
|
925 |
double Angle = control.Angle; |
926 |
|
927 |
if (Math.Abs(Angle).ToString() == "90") |
928 |
{ |
929 |
Angle = 270; |
930 |
} |
931 |
else if (Math.Abs(Angle).ToString() == "270") |
932 |
{ |
933 |
Angle = 90; |
934 |
} |
935 |
|
936 |
var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
937 |
tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
938 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
939 |
tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
940 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
941 |
|
942 |
var newStartPoint = tempStartPoint; |
943 |
var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
944 |
var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
945 |
|
946 |
//Point testPoint = tempEndPoint; |
947 |
//if (Angle != 0) |
948 |
//{ |
949 |
// testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed); |
950 |
// //testPoint = Test(rect, newMidPoint); |
951 |
//} |
952 |
|
953 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
954 |
System.Drawing.Color FontColor = _SetColor; |
955 |
bool isHighlight = control.isHighLight; |
956 |
double Opacity = control.Opac; |
957 |
PaintSet Paint = PaintSet.None; |
958 |
|
959 |
switch (control.ArrowStyle) |
960 |
{ |
961 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
962 |
{ |
963 |
Paint = PaintSet.None; |
964 |
} |
965 |
break; |
966 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
967 |
{ |
968 |
Paint = PaintSet.Hatch; |
969 |
} |
970 |
break; |
971 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
972 |
{ |
973 |
Paint = PaintSet.Fill; |
974 |
} |
975 |
break; |
976 |
default: |
977 |
break; |
978 |
} |
979 |
if (control.isHighLight) Paint |= PaintSet.Highlight; |
980 |
|
981 |
if (Paint == PaintSet.Hatch) |
982 |
{ |
983 |
Text = control.ArrowText; |
984 |
} |
985 |
else |
986 |
{ |
987 |
Text = control.ArrowText; |
988 |
} |
989 |
|
990 |
try |
991 |
{ |
992 |
if (control.fontConfig.Count == 4) |
993 |
{ |
994 |
fontsize = Convert.ToDouble(control.fontConfig[3]); |
995 |
} |
996 |
|
997 |
//강인구 수정(2018.04.17) |
998 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
999 |
|
1000 |
FontStyle fontStyle = FontStyles.Normal; |
1001 |
if (FontStyles.Italic == TextStyle) |
1002 |
{ |
1003 |
fontStyle = FontStyles.Italic; |
1004 |
} |
1005 |
|
1006 |
FontWeight fontWeight = FontWeights.Black; |
1007 |
|
1008 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
1009 |
if (FontWeights.Bold == TextWeight) |
1010 |
{ |
1011 |
fontWeight = FontWeights.Bold; |
1012 |
} |
1013 |
|
1014 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
1015 |
if (control.fontConfig.Count() == 5) |
1016 |
{ |
1017 |
decoration = TextDecorations.Underline; |
1018 |
} |
1019 |
|
1020 |
if (control.isTrans) |
1021 |
{ |
1022 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
1023 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1024 |
newStartPoint, tempMidPoint, newEndPoint, control.isFixed, |
1025 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1026 |
} |
1027 |
else |
1028 |
{ |
1029 |
if (control.isFixed) |
1030 |
{ |
1031 |
var testP = new Point(0, 0); |
1032 |
if (control.isFixed) |
1033 |
{ |
1034 |
if (tempPoint[1] == newEndPoint) |
1035 |
{ |
1036 |
testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
1037 |
} |
1038 |
else if (tempPoint[3] == newEndPoint) |
1039 |
{ |
1040 |
testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
1041 |
} |
1042 |
else if (tempPoint[0] == newEndPoint) |
1043 |
{ |
1044 |
testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
1045 |
} |
1046 |
else if (tempPoint[2] == newEndPoint) |
1047 |
{ |
1048 |
testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
1049 |
} |
1050 |
} |
1051 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
1052 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1053 |
tempStartPoint, testP, tempEndPoint, control.isFixed, |
1054 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
1055 |
FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1056 |
} |
1057 |
else |
1058 |
{ |
1059 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
1060 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1061 |
newStartPoint, tempMidPoint, tempEndPoint, control.isFixed, |
1062 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1063 |
} |
1064 |
} |
1065 |
} |
1066 |
catch (Exception ex) |
1067 |
{ |
1068 |
throw ex; |
1069 |
} |
1070 |
|
1071 |
} |
1072 |
break; |
1073 |
#endregion |
1074 |
#region SignControl |
1075 |
case "SignControl": |
1076 |
using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
1077 |
{ |
1078 |
|
1079 |
double Angle = control.Angle; |
1080 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1081 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
1082 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1083 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
1084 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1085 |
double Opacity = control.Opac; |
1086 |
string UserNumber = control.UserNumber; |
1087 |
Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
1088 |
} |
1089 |
break; |
1090 |
#endregion |
1091 |
#region MyRegion |
1092 |
case "DateControl": |
1093 |
using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
1094 |
{ |
1095 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1096 |
string Text = control.Text; |
1097 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1098 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1099 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
1100 |
System.Drawing.Color FontColor = _SetColor; |
1101 |
double Angle = control.Angle; |
1102 |
double Opacity = control.Opac; |
1103 |
Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
1104 |
} |
1105 |
break; |
1106 |
#endregion |
1107 |
#region SymControlN (APPROVED) |
1108 |
case "SymControlN": |
1109 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
1110 |
{ |
1111 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1112 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1113 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
1114 |
System.Drawing.Color FontColor = _SetColor; |
1115 |
double Angle = control.Angle; |
1116 |
double Opacity = control.Opac; |
1117 |
|
1118 |
var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
1119 |
|
1120 |
if (stamp.Count() > 0) |
1121 |
{ |
1122 |
var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE); |
1123 |
|
1124 |
var Contents = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP_CONTENTS"); |
1125 |
|
1126 |
if (Contents?.Count() > 0) |
1127 |
{ |
1128 |
foreach (var content in Contents) |
1129 |
{ |
1130 |
xamldata = xamldata.Replace(content.PROPERTY, System.Security.SecurityElement.Escape(content.VALUE)); |
1131 |
} |
1132 |
} |
1133 |
|
1134 |
Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata); |
1135 |
} |
1136 |
|
1137 |
string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
1138 |
|
1139 |
} |
1140 |
break; |
1141 |
case "SymControl": |
1142 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
1143 |
{ |
1144 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1145 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1146 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
1147 |
System.Drawing.Color FontColor = _SetColor; |
1148 |
double Angle = control.Angle; |
1149 |
double Opacity = control.Opac; |
1150 |
|
1151 |
string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
1152 |
Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
1153 |
} |
1154 |
break; |
1155 |
#endregion |
1156 |
#region Image |
1157 |
case "ImgControl": |
1158 |
using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
1159 |
{ |
1160 |
double Angle = control.Angle; |
1161 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1162 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
1163 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1164 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
1165 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1166 |
double Opacity = control.Opac; |
1167 |
string FilePath = control.ImagePath; |
1168 |
//Uri uri = new Uri(s.ImagePath); |
1169 |
|
1170 |
Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
1171 |
} |
1172 |
break; |
1173 |
#endregion |
1174 |
default: |
1175 |
StatusChange($"{ControlT.Name} Not Support", 0); |
1176 |
break; |
1177 |
} |
1178 |
|
1179 |
} |
1180 |
catch (Exception ex) |
1181 |
{ |
1182 |
StatusChange($"markupItem : {ControlT.Name}" + ex.ToString(), 0); |
1183 |
} |
1184 |
finally |
1185 |
{ |
1186 |
} |
1187 |
} |
1188 |
} |
1189 |
} |
1190 |
} |
1191 |
|
1192 |
if (StatusChanged != null) |
1193 |
{ |
1194 |
StatusChanged(this, new StatusChangedEventArgs { CurrentPage = lastPageNo, Message = "" }); |
1195 |
} |
1196 |
//PdfFileSpecification pfs = PdfFileSpecification.FileEmbedded(pdfStamper.Writer, @"C:\Users\kts\Documents\업무\CARS\엑셀양식\F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", "F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", null); |
1197 |
//pdfStamper.AddFileAttachment("F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", pfs); |
1198 |
|
1199 |
pdfStamper.Outlines = root; |
1200 |
pdfStamper.Close(); |
1201 |
pdfReader.Close(); |
1202 |
} |
1203 |
} |
1204 |
} |
1205 |
#endregion |
1206 |
} |
1207 |
|
1208 |
if (tempFileInfo.Exists) |
1209 |
{ |
1210 |
#if !DEBUG |
1211 |
tempFileInfo.Delete(); |
1212 |
#endif |
1213 |
} |
1214 |
|
1215 |
if (File.Exists(pdfFilePath)) |
1216 |
{ |
1217 |
string destfilepath = null; |
1218 |
try |
1219 |
{ |
1220 |
FinalPDFPath = new FileInfo(pdfFilePath); |
1221 |
|
1222 |
/// 정리 필요함. DB로 변경 |
1223 |
string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
1224 |
|
1225 |
if(!string.IsNullOrEmpty(pdfmovepath)) |
1226 |
{ |
1227 |
_FinalPDFStorgeLocal = pdfmovepath; |
1228 |
} |
1229 |
|
1230 |
destfilepath = Path.Combine(_FinalPDFStorgeLocal, FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
1231 |
|
1232 |
if (File.Exists(destfilepath)) |
1233 |
File.Delete(destfilepath); |
1234 |
|
1235 |
File.Move(FinalPDFPath.FullName, destfilepath); |
1236 |
FinalPDFPath = new FileInfo(destfilepath); |
1237 |
File.Delete(pdfFilePath); |
1238 |
} |
1239 |
catch (Exception ex) |
1240 |
{ |
1241 |
SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString()); |
1242 |
} |
1243 |
|
1244 |
return true; |
1245 |
} |
1246 |
} |
1247 |
catch (Exception ex) |
1248 |
{ |
1249 |
SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString()); |
1250 |
} |
1251 |
return false; |
1252 |
} |
1253 |
|
1254 |
/// <summary> |
1255 |
/// kcom의 화살표방향과 틀려 추가함 |
1256 |
/// </summary> |
1257 |
/// <param name="PageAngle"></param> |
1258 |
/// <param name="endP"></param> |
1259 |
/// <param name="ps">box Points</param> |
1260 |
/// <param name="IsFixed"></param> |
1261 |
/// <returns></returns> |
1262 |
private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed) |
1263 |
{ |
1264 |
Point testP = endP; |
1265 |
|
1266 |
try |
1267 |
{ |
1268 |
switch (Math.Abs(PageAngle).ToString()) |
1269 |
{ |
1270 |
case "90": |
1271 |
testP = new Point(endP.X + 50, endP.Y); |
1272 |
break; |
1273 |
case "270": |
1274 |
testP = new Point(endP.X - 50, endP.Y); |
1275 |
break; |
1276 |
} |
1277 |
|
1278 |
//20180910 LJY 각도에 따라. |
1279 |
switch (Math.Abs(PageAngle).ToString()) |
1280 |
{ |
1281 |
case "90": |
1282 |
if (IsFixed) |
1283 |
{ |
1284 |
if (ps[0] == endP) //상단 |
1285 |
{ |
1286 |
testP = new Point(endP.X, endP.Y + 50); |
1287 |
//System.Diagnostics.Debug.WriteLine("상단"+ testP); |
1288 |
} |
1289 |
else if (ps[1] == endP) //하단 |
1290 |
{ |
1291 |
testP = new Point(endP.X, endP.Y - 50); |
1292 |
//System.Diagnostics.Debug.WriteLine("하단"+ testP); |
1293 |
} |
1294 |
else if (ps[2] == endP) //좌단 |
1295 |
{ |
1296 |
testP = new Point(endP.X - 50, endP.Y); |
1297 |
//System.Diagnostics.Debug.WriteLine("좌단"+ testP); |
1298 |
} |
1299 |
else if (ps[3] == endP) //우단 |
1300 |
{ |
1301 |
testP = new Point(endP.X + 50, endP.Y); |
1302 |
//System.Diagnostics.Debug.WriteLine("우단"+ testP); |
1303 |
} |
1304 |
} |
1305 |
break; |
1306 |
case "270": |
1307 |
if (IsFixed) |
1308 |
{ |
1309 |
if (ps[0] == endP) //상단 |
1310 |
{ |
1311 |
testP = new Point(endP.X, endP.Y - 50); |
1312 |
//System.Diagnostics.Debug.WriteLine("상단" + testP); |
1313 |
} |
1314 |
else if (ps[1] == endP) //하단 |
1315 |
{ |
1316 |
testP = new Point(endP.X, endP.Y + 50); |
1317 |
//System.Diagnostics.Debug.WriteLine("하단" + testP); |
1318 |
} |
1319 |
else if (ps[2] == endP) //좌단 |
1320 |
{ |
1321 |
testP = new Point(endP.X + 50, endP.Y); |
1322 |
//System.Diagnostics.Debug.WriteLine("좌단" + testP); |
1323 |
} |
1324 |
else if (ps[3] == endP) //우단 |
1325 |
{ |
1326 |
testP = new Point(endP.X - 50, endP.Y); |
1327 |
//System.Diagnostics.Debug.WriteLine("우단" + testP); |
1328 |
} |
1329 |
} |
1330 |
break; |
1331 |
default: |
1332 |
if (IsFixed) |
1333 |
{ |
1334 |
|
1335 |
if (ps[0] == endP) //상단 |
1336 |
{ |
1337 |
testP = new Point(endP.X, endP.Y - 50); |
1338 |
//System.Diagnostics.Debug.WriteLine("상단"); |
1339 |
} |
1340 |
else if (ps[1] == endP) //하단 |
1341 |
{ |
1342 |
testP = new Point(endP.X, endP.Y + 50); |
1343 |
//System.Diagnostics.Debug.WriteLine("하단"); |
1344 |
} |
1345 |
else if (ps[2] == endP) //좌단 |
1346 |
{ |
1347 |
testP = new Point(endP.X - 50, endP.Y); |
1348 |
//System.Diagnostics.Debug.WriteLine("좌단"); |
1349 |
} |
1350 |
else if (ps[3] == endP) //우단 |
1351 |
{ |
1352 |
testP = new Point(endP.X + 50, endP.Y); |
1353 |
//System.Diagnostics.Debug.WriteLine("우단"); |
1354 |
} |
1355 |
} |
1356 |
break; |
1357 |
} |
1358 |
|
1359 |
} |
1360 |
catch (Exception) |
1361 |
{ |
1362 |
} |
1363 |
|
1364 |
return testP; |
1365 |
} |
1366 |
|
1367 |
private Point Test(Rect rect,Point point) |
1368 |
{ |
1369 |
Point result = new Point(); |
1370 |
|
1371 |
Point newPoint = new Point(); |
1372 |
|
1373 |
double oldNear = 0; |
1374 |
double newNear = 0; |
1375 |
|
1376 |
oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result); |
1377 |
|
1378 |
newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint); |
1379 |
|
1380 |
if (newNear < oldNear) |
1381 |
{ |
1382 |
oldNear = newNear; |
1383 |
result = newPoint; |
1384 |
} |
1385 |
|
1386 |
newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint); |
1387 |
|
1388 |
if (newNear < oldNear) |
1389 |
{ |
1390 |
oldNear = newNear; |
1391 |
result = newPoint; |
1392 |
} |
1393 |
|
1394 |
|
1395 |
newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint); |
1396 |
|
1397 |
if (newNear < oldNear) |
1398 |
{ |
1399 |
oldNear = newNear; |
1400 |
result = newPoint; |
1401 |
} |
1402 |
|
1403 |
return result; |
1404 |
} |
1405 |
|
1406 |
private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor) |
1407 |
{ |
1408 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1409 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1410 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
1411 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1412 |
DoubleCollection DashSize = control.DashSize; |
1413 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1414 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
1415 |
|
1416 |
double Opacity = control.Opac; |
1417 |
|
1418 |
if (EndPoint == MidPoint) |
1419 |
{ |
1420 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1421 |
} |
1422 |
else |
1423 |
{ |
1424 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity); |
1425 |
} |
1426 |
|
1427 |
Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity); |
1428 |
|
1429 |
} |
1430 |
|
1431 |
private void DrawLine(S_LineControl control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor) |
1432 |
{ |
1433 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1434 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1435 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1436 |
DoubleCollection DashSize = control.DashSize; |
1437 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1438 |
|
1439 |
var Opacity = control.Opac; |
1440 |
string UserID = control.UserID; |
1441 |
double Interval = control.Interval; |
1442 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
1443 |
Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, setColor, Opacity); |
1444 |
switch (control.LineStyleSet) |
1445 |
{ |
1446 |
case LineStyleSet.ArrowLine: |
1447 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1448 |
break; |
1449 |
case LineStyleSet.CancelLine: |
1450 |
{ |
1451 |
var x = Math.Abs((Math.Abs(control.StartPoint.X) - Math.Abs(control.EndPoint.X))); |
1452 |
var y = Math.Abs((Math.Abs(control.StartPoint.Y) - Math.Abs(control.EndPoint.Y))); |
1453 |
|
1454 |
Point newStartPoint = new Point(); |
1455 |
Point newEndPoint = new Point(); |
1456 |
|
1457 |
if (x > y) |
1458 |
{ |
1459 |
newStartPoint = new Point(control.StartPoint.X, control.StartPoint.Y + control.Interval); |
1460 |
newEndPoint = new Point(control.EndPoint.X, control.EndPoint.Y + control.Interval); |
1461 |
} |
1462 |
else |
1463 |
{ |
1464 |
newStartPoint = new Point(control.StartPoint.X + control.Interval, control.StartPoint.Y); |
1465 |
newEndPoint = new Point(control.EndPoint.X + control.Interval, control.EndPoint.Y); |
1466 |
} |
1467 |
|
1468 |
newStartPoint = GetPdfPointSystem(newStartPoint); |
1469 |
newEndPoint = GetPdfPointSystem(newEndPoint); |
1470 |
|
1471 |
Controls_PDF.DrawSet_Line.DrawLine(newStartPoint, newEndPoint, LineSize, contentByte, DashSize, setColor, Opacity); |
1472 |
} |
1473 |
break; |
1474 |
case LineStyleSet.TwinLine: |
1475 |
{ |
1476 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1477 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
1478 |
} |
1479 |
break; |
1480 |
case LineStyleSet.DimLine: |
1481 |
{ |
1482 |
Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
1483 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1484 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
1485 |
} |
1486 |
break; |
1487 |
default: |
1488 |
break; |
1489 |
} |
1490 |
|
1491 |
} |
1492 |
|
1493 |
private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,System.Drawing.Color setColor) |
1494 |
{ |
1495 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1496 |
string Text = control.Text; |
1497 |
|
1498 |
bool isUnderline = false; |
1499 |
control.BoxW -= scaleWidth; |
1500 |
control.BoxH -= scaleHeight; |
1501 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH); |
1502 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1503 |
Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH)); |
1504 |
|
1505 |
List<Point> pointSet = new List<Point>(); |
1506 |
pointSet.Add(StartPoint); |
1507 |
pointSet.Add(EndPoint); |
1508 |
|
1509 |
PaintSet paint = PaintSet.None; |
1510 |
switch (control.paintMethod) |
1511 |
{ |
1512 |
case 1: |
1513 |
{ |
1514 |
paint = PaintSet.Fill; |
1515 |
} |
1516 |
break; |
1517 |
case 2: |
1518 |
{ |
1519 |
paint = PaintSet.Hatch; |
1520 |
} |
1521 |
break; |
1522 |
default: |
1523 |
break; |
1524 |
} |
1525 |
if (control.isHighLight) paint |= PaintSet.Highlight; |
1526 |
|
1527 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
1528 |
double TextSize = Convert.ToDouble(data2[1]); |
1529 |
System.Drawing.Color FontColor = setColor; |
1530 |
double Angle = control.Angle; |
1531 |
double Opacity = control.Opac; |
1532 |
FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]); |
1533 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
1534 |
|
1535 |
FontStyle fontStyle = FontStyles.Normal; |
1536 |
if (FontStyles.Italic == TextStyle) |
1537 |
{ |
1538 |
fontStyle = FontStyles.Italic; |
1539 |
} |
1540 |
|
1541 |
FontWeight fontWeight = FontWeights.Black; |
1542 |
|
1543 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
1544 |
//강인구 수정(2018.04.17) |
1545 |
if (FontWeights.Bold == TextWeight) |
1546 |
//if (FontWeights.ExtraBold == TextWeight) |
1547 |
{ |
1548 |
fontWeight = FontWeights.Bold; |
1549 |
} |
1550 |
|
1551 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
1552 |
if (control.fontConfig.Count() == 4) |
1553 |
{ |
1554 |
decoration = TextDecorations.Underline; |
1555 |
} |
1556 |
|
1557 |
Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1558 |
} |
1559 |
|
1560 |
|
1561 |
~MarkupToPDF() |
1562 |
{ |
1563 |
this.Dispose(false); |
1564 |
} |
1565 |
|
1566 |
private bool disposed; |
1567 |
|
1568 |
public void Dispose() |
1569 |
{ |
1570 |
this.Dispose(true); |
1571 |
GC.SuppressFinalize(this); |
1572 |
} |
1573 |
|
1574 |
protected virtual void Dispose(bool disposing) |
1575 |
{ |
1576 |
if (this.disposed) return; |
1577 |
if (disposing) |
1578 |
{ |
1579 |
// IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
1580 |
} |
1581 |
// .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
1582 |
this.disposed = true; |
1583 |
} |
1584 |
|
1585 |
#endregion |
1586 |
} |
1587 |
} |