markus / FinalService / KCOM_FinalService / MarkupToPDF / MarkupToPDF.cs @ 51c6ce90
이력 | 보기 | 이력해설 | 다운로드 (93.8 KB)
1 |
using IFinalPDF; |
---|---|
2 |
using iTextSharp.text.pdf; |
3 |
using KCOMDataModel.Common; |
4 |
using KCOMDataModel.DataModel; |
5 |
using MarkupToPDF.Controls.Common; |
6 |
using MarkupToPDF.Serialize.Core; |
7 |
using MarkupToPDF.Serialize.S_Control; |
8 |
using 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 |
var groups = MarkupDataSet.GroupBy(x => x.PAGENUMBER); |
600 |
foreach (var group in groups) |
601 |
{ |
602 |
int PageNumber = group.Key; |
603 |
#region ZIndex 값으로 정렬한다. |
604 |
var items = new List<Tuple<string, S_BaseControl>>(); |
605 |
foreach (var item in group) |
606 |
{ |
607 |
var tokens = item.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries).ToList(); |
608 |
items.AddRange(tokens.ConvertAll(x => |
609 |
{ |
610 |
var str = JsonSerializerHelper.UnCompressString(x); |
611 |
var control = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(str); |
612 |
return new Tuple<string, S_BaseControl>(str, control); |
613 |
})); |
614 |
} |
615 |
|
616 |
var zgroups = items.GroupBy(x => x.Item2.ZIndex).OrderBy(x => x.Key); |
617 |
#endregion |
618 |
|
619 |
foreach (var zgroup in zgroups) |
620 |
{ |
621 |
var ordered = zgroup.OrderBy(x => x.Item2.Index); |
622 |
foreach (var order in ordered) |
623 |
{ |
624 |
/// 2020.11.13 김태성 |
625 |
/// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함. |
626 |
var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == PageNumber); |
627 |
if (pageitems.Any()) |
628 |
{ |
629 |
var currentPage = pageitems.First(); |
630 |
pdfSize = pdfReader.GetPageSizeWithRotation(PageNumber); |
631 |
lastPageNo = PageNumber; |
632 |
|
633 |
iTextSharp.text.Rectangle mediaBox = pdfReader.GetPageSize(PageNumber); |
634 |
var cropBox = pdfReader.GetCropBox(PageNumber); |
635 |
|
636 |
/// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다 |
637 |
if (cropBox != null && |
638 |
(cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom)) |
639 |
{ |
640 |
PdfDictionary dict = pdfReader.GetPageN(PageNumber); |
641 |
|
642 |
PdfArray oNewMediaBox = new PdfArray(); |
643 |
oNewMediaBox.Add(new PdfNumber(cropBox.Left)); |
644 |
oNewMediaBox.Add(new PdfNumber(cropBox.Top)); |
645 |
oNewMediaBox.Add(new PdfNumber(cropBox.Right)); |
646 |
oNewMediaBox.Add(new PdfNumber(cropBox.Bottom)); |
647 |
dict.Put(PdfName.MEDIABOX, oNewMediaBox); |
648 |
|
649 |
pdfSize = cropBox; |
650 |
} |
651 |
|
652 |
scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
653 |
scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
654 |
|
655 |
pdfLink.CURRENT_PAGE = PageNumber; |
656 |
_entity.SaveChanges(); |
657 |
|
658 |
PdfContentByte contentByte = pdfStamper.GetOverContent(PageNumber); |
659 |
var item = order.Item1; |
660 |
var ControlT = order.Item2; |
661 |
|
662 |
try |
663 |
{ |
664 |
switch (ControlT.Name) |
665 |
{ |
666 |
#region LINE |
667 |
case "LineControl": |
668 |
{ |
669 |
using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item)) |
670 |
{ |
671 |
DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
672 |
} |
673 |
} |
674 |
break; |
675 |
#endregion |
676 |
#region ArrowControlMulti |
677 |
case "ArrowControl_Multi": |
678 |
{ |
679 |
using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
680 |
{ |
681 |
DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
682 |
} |
683 |
} |
684 |
break; |
685 |
#endregion |
686 |
#region PolyControl |
687 |
case "PolygonControl": |
688 |
using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item)) |
689 |
{ |
690 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
691 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
692 |
var PaintStyle = control.PaintState; |
693 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
694 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
695 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
696 |
double Opacity = control.Opac; |
697 |
DoubleCollection DashSize = control.DashSize; |
698 |
|
699 |
Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity); |
700 |
//Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
701 |
} |
702 |
break; |
703 |
#endregion |
704 |
#region ArcControl or ArrowArcControl |
705 |
case "ArcControl": |
706 |
case "ArrowArcControl": |
707 |
{ |
708 |
using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
709 |
{ |
710 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
711 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
712 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
713 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
714 |
DoubleCollection DashSize = control.DashSize; |
715 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
716 |
|
717 |
var Opacity = control.Opac; |
718 |
string UserID = control.UserID; |
719 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
720 |
bool IsTransOn = control.IsTransOn; |
721 |
|
722 |
if (control.IsTransOn) |
723 |
{ |
724 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
725 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
726 |
} |
727 |
else |
728 |
{ |
729 |
Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, LineSize, contentByte, _SetColor, Opacity); |
730 |
} |
731 |
|
732 |
if (ControlT.Name == "ArrowArcControl") |
733 |
{ |
734 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
735 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
736 |
} |
737 |
} |
738 |
} |
739 |
break; |
740 |
#endregion |
741 |
#region RectangleControl |
742 |
case "RectangleControl": |
743 |
using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
744 |
{ |
745 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
746 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
747 |
var PaintStyle = control.PaintState; |
748 |
double Angle = control.Angle; |
749 |
DoubleCollection DashSize = control.DashSize; |
750 |
double Opacity = control.Opac; |
751 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
752 |
|
753 |
Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
754 |
} |
755 |
break; |
756 |
#endregion |
757 |
#region TriControl |
758 |
case "TriControl": |
759 |
using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item)) |
760 |
{ |
761 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
762 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
763 |
var PaintStyle = control.Paint; |
764 |
double Angle = control.Angle; |
765 |
//StrokeColor = _SetColor, //색상은 레드 |
766 |
DoubleCollection DashSize = control.DashSize; |
767 |
double Opacity = control.Opac; |
768 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
769 |
|
770 |
Controls_PDF.DrawSet_Shape.DrawTriangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle | PaintSet.Outline, Opacity); |
771 |
} |
772 |
break; |
773 |
#endregion |
774 |
#region CircleControl |
775 |
case "CircleControl": |
776 |
using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
777 |
{ |
778 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
779 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
780 |
var StartPoint = GetPdfPointSystem(control.StartPoint); |
781 |
var EndPoint = GetPdfPointSystem(control.EndPoint); |
782 |
var PaintStyle = control.PaintState; |
783 |
double Angle = control.Angle; |
784 |
DoubleCollection DashSize = control.DashSize; |
785 |
double Opacity = control.Opac; |
786 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
787 |
Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
788 |
|
789 |
} |
790 |
break; |
791 |
#endregion |
792 |
#region RectCloudControl |
793 |
case "RectCloudControl": |
794 |
using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
795 |
{ |
796 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
797 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
798 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
799 |
double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
800 |
|
801 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
802 |
|
803 |
var PaintStyle = control.PaintState; |
804 |
double Opacity = control.Opac; |
805 |
DoubleCollection DashSize = control.DashSize; |
806 |
|
807 |
//드로잉 방식이 표현되지 않음 |
808 |
var rotate = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
809 |
|
810 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
811 |
bool reverse = (area < 0); |
812 |
|
813 |
Controls_PDF.DrawSet_Cloud.DrawCloudRect(PointSet, LineSize, (int)rotate, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
814 |
} |
815 |
break; |
816 |
#endregion |
817 |
#region CloudControl |
818 |
case "CloudControl": |
819 |
using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
820 |
{ |
821 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
822 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
823 |
double Toler = control.Toler; |
824 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
825 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
826 |
var PaintStyle = control.PaintState; |
827 |
double Opacity = control.Opac; |
828 |
bool isTransOn = control.IsTrans; |
829 |
bool isChain = control.IsChain; |
830 |
|
831 |
DoubleCollection DashSize = control.DashSize; |
832 |
|
833 |
if (isChain) |
834 |
{ |
835 |
Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
836 |
} |
837 |
else |
838 |
{ |
839 |
if (isTransOn) |
840 |
{ |
841 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
842 |
bool reverse = (area < 0); |
843 |
|
844 |
if (PaintStyle == PaintSet.None) |
845 |
{ |
846 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
847 |
} |
848 |
else |
849 |
{ |
850 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
851 |
} |
852 |
} |
853 |
else |
854 |
{ |
855 |
Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
856 |
} |
857 |
} |
858 |
} |
859 |
break; |
860 |
#endregion |
861 |
#region TEXT |
862 |
case "TextControl": |
863 |
using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
864 |
{ |
865 |
DrawTextBox(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
866 |
} |
867 |
break; |
868 |
#endregion |
869 |
#region ArrowTextControl |
870 |
case "ArrowTextControl": |
871 |
using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
872 |
{ |
873 |
//using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
874 |
//{ |
875 |
// textcontrol.Angle = control.Angle; |
876 |
// textcontrol.BoxH = control.BoxHeight; |
877 |
// textcontrol.BoxW = control.BoxWidth; |
878 |
// textcontrol.EndPoint = control.EndPoint; |
879 |
// textcontrol.FontColor = "#FFFF0000"; |
880 |
// textcontrol.Name = "TextControl"; |
881 |
// textcontrol.Opac = control.Opac; |
882 |
// textcontrol.PointSet = new List<Point>(); |
883 |
// textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]); |
884 |
// textcontrol.StartPoint = control.StartPoint; |
885 |
// textcontrol.Text = control.ArrowText; |
886 |
// textcontrol.TransformPoint = control.TransformPoint; |
887 |
// textcontrol.UserID = null; |
888 |
// textcontrol.fontConfig = control.fontConfig; |
889 |
// textcontrol.isHighLight = control.isHighLight; |
890 |
// textcontrol.paintMethod = 1; |
891 |
|
892 |
// DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
893 |
//} |
894 |
|
895 |
//using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
896 |
//{ |
897 |
// linecontrol.Angle = control.Angle; |
898 |
// linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 }); |
899 |
// linecontrol.EndPoint = control.EndPoint; |
900 |
// linecontrol.MidPoint = control.MidPoint; |
901 |
// linecontrol.Name = "ArrowControl_Multi"; |
902 |
// linecontrol.Opac = control.Opac; |
903 |
// linecontrol.PointSet = control.PointSet; |
904 |
// linecontrol.SizeSet = control.SizeSet; |
905 |
// linecontrol.StartPoint = control.StartPoint; |
906 |
// linecontrol.StrokeColor = control.StrokeColor; |
907 |
// linecontrol.TransformPoint = control.TransformPoint; |
908 |
|
909 |
// DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
910 |
//} |
911 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
912 |
Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
913 |
Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
914 |
Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
915 |
bool isUnderLine = false; |
916 |
string Text = ""; |
917 |
double fontsize = 30; |
918 |
|
919 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
920 |
Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
921 |
List<Point> tempPoint = new List<Point>(); |
922 |
|
923 |
double Angle = control.Angle; |
924 |
|
925 |
if (Math.Abs(Angle).ToString() == "90") |
926 |
{ |
927 |
Angle = 270; |
928 |
} |
929 |
else if (Math.Abs(Angle).ToString() == "270") |
930 |
{ |
931 |
Angle = 90; |
932 |
} |
933 |
|
934 |
var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
935 |
tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
936 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
937 |
tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
938 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
939 |
|
940 |
var newStartPoint = tempStartPoint; |
941 |
var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
942 |
var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
943 |
|
944 |
//Point testPoint = tempEndPoint; |
945 |
//if (Angle != 0) |
946 |
//{ |
947 |
// testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed); |
948 |
// //testPoint = Test(rect, newMidPoint); |
949 |
//} |
950 |
|
951 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
952 |
System.Drawing.Color FontColor = _SetColor; |
953 |
bool isHighlight = control.isHighLight; |
954 |
double Opacity = control.Opac; |
955 |
PaintSet Paint = PaintSet.None; |
956 |
|
957 |
switch (control.ArrowStyle) |
958 |
{ |
959 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
960 |
{ |
961 |
Paint = PaintSet.None; |
962 |
} |
963 |
break; |
964 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
965 |
{ |
966 |
Paint = PaintSet.Hatch; |
967 |
} |
968 |
break; |
969 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
970 |
{ |
971 |
Paint = PaintSet.Fill; |
972 |
} |
973 |
break; |
974 |
default: |
975 |
break; |
976 |
} |
977 |
if (control.isHighLight) Paint |= PaintSet.Highlight; |
978 |
|
979 |
if (Paint == PaintSet.Hatch) |
980 |
{ |
981 |
Text = control.ArrowText; |
982 |
} |
983 |
else |
984 |
{ |
985 |
Text = control.ArrowText; |
986 |
} |
987 |
|
988 |
try |
989 |
{ |
990 |
if (control.fontConfig.Count == 4) |
991 |
{ |
992 |
fontsize = Convert.ToDouble(control.fontConfig[3]); |
993 |
} |
994 |
|
995 |
//강인구 수정(2018.04.17) |
996 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
997 |
|
998 |
FontStyle fontStyle = FontStyles.Normal; |
999 |
if (FontStyles.Italic == TextStyle) |
1000 |
{ |
1001 |
fontStyle = FontStyles.Italic; |
1002 |
} |
1003 |
|
1004 |
FontWeight fontWeight = FontWeights.Black; |
1005 |
|
1006 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
1007 |
if (FontWeights.Bold == TextWeight) |
1008 |
{ |
1009 |
fontWeight = FontWeights.Bold; |
1010 |
} |
1011 |
|
1012 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
1013 |
if (control.fontConfig.Count() == 5) |
1014 |
{ |
1015 |
decoration = TextDecorations.Underline; |
1016 |
} |
1017 |
|
1018 |
if (control.isTrans) |
1019 |
{ |
1020 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
1021 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1022 |
newStartPoint, tempMidPoint, newEndPoint, control.isFixed, |
1023 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1024 |
} |
1025 |
else |
1026 |
{ |
1027 |
if (control.isFixed) |
1028 |
{ |
1029 |
var testP = new Point(0, 0); |
1030 |
if (control.isFixed) |
1031 |
{ |
1032 |
if (tempPoint[1] == newEndPoint) |
1033 |
{ |
1034 |
testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
1035 |
} |
1036 |
else if (tempPoint[3] == newEndPoint) |
1037 |
{ |
1038 |
testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
1039 |
} |
1040 |
else if (tempPoint[0] == newEndPoint) |
1041 |
{ |
1042 |
testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
1043 |
} |
1044 |
else if (tempPoint[2] == newEndPoint) |
1045 |
{ |
1046 |
testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
1047 |
} |
1048 |
} |
1049 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
1050 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1051 |
tempStartPoint, testP, tempEndPoint, control.isFixed, |
1052 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
1053 |
FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1054 |
} |
1055 |
else |
1056 |
{ |
1057 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
1058 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
1059 |
newStartPoint, tempMidPoint, tempEndPoint, control.isFixed, |
1060 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1061 |
} |
1062 |
} |
1063 |
} |
1064 |
catch (Exception ex) |
1065 |
{ |
1066 |
throw ex; |
1067 |
} |
1068 |
|
1069 |
} |
1070 |
break; |
1071 |
#endregion |
1072 |
#region SignControl |
1073 |
case "SignControl": |
1074 |
using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
1075 |
{ |
1076 |
|
1077 |
double Angle = control.Angle; |
1078 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1079 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
1080 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1081 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
1082 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1083 |
double Opacity = control.Opac; |
1084 |
string UserNumber = control.UserNumber; |
1085 |
Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
1086 |
} |
1087 |
break; |
1088 |
#endregion |
1089 |
#region MyRegion |
1090 |
case "DateControl": |
1091 |
using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
1092 |
{ |
1093 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1094 |
string Text = control.Text; |
1095 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1096 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1097 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
1098 |
System.Drawing.Color FontColor = _SetColor; |
1099 |
double Angle = control.Angle; |
1100 |
double Opacity = control.Opac; |
1101 |
Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
1102 |
} |
1103 |
break; |
1104 |
#endregion |
1105 |
#region SymControlN (APPROVED) |
1106 |
case "SymControlN": |
1107 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
1108 |
{ |
1109 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1110 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1111 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
1112 |
System.Drawing.Color FontColor = _SetColor; |
1113 |
double Angle = control.Angle; |
1114 |
double Opacity = control.Opac; |
1115 |
|
1116 |
var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
1117 |
|
1118 |
if (stamp.Count() > 0) |
1119 |
{ |
1120 |
var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE); |
1121 |
|
1122 |
var Contents = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP_CONTENTS"); |
1123 |
|
1124 |
if (Contents?.Count() > 0) |
1125 |
{ |
1126 |
foreach (var content in Contents) |
1127 |
{ |
1128 |
xamldata = xamldata.Replace(content.PROPERTY, System.Security.SecurityElement.Escape(content.VALUE)); |
1129 |
} |
1130 |
} |
1131 |
|
1132 |
Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata); |
1133 |
} |
1134 |
|
1135 |
string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
1136 |
|
1137 |
} |
1138 |
break; |
1139 |
case "SymControl": |
1140 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
1141 |
{ |
1142 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1143 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1144 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
1145 |
System.Drawing.Color FontColor = _SetColor; |
1146 |
double Angle = control.Angle; |
1147 |
double Opacity = control.Opac; |
1148 |
|
1149 |
string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
1150 |
Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
1151 |
} |
1152 |
break; |
1153 |
#endregion |
1154 |
#region Image |
1155 |
case "ImgControl": |
1156 |
using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
1157 |
{ |
1158 |
double Angle = control.Angle; |
1159 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1160 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
1161 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1162 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
1163 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1164 |
double Opacity = control.Opac; |
1165 |
string FilePath = control.ImagePath; |
1166 |
//Uri uri = new Uri(s.ImagePath); |
1167 |
|
1168 |
Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
1169 |
} |
1170 |
break; |
1171 |
#endregion |
1172 |
default: |
1173 |
StatusChange($"{ControlT.Name} Not Support", 0); |
1174 |
break; |
1175 |
} |
1176 |
|
1177 |
} |
1178 |
catch (Exception ex) |
1179 |
{ |
1180 |
StatusChange($"markupItem : {ControlT.Name}" + ex.ToString(), 0); |
1181 |
} |
1182 |
finally |
1183 |
{ |
1184 |
} |
1185 |
} |
1186 |
} |
1187 |
} |
1188 |
} |
1189 |
|
1190 |
if (StatusChanged != null) |
1191 |
{ |
1192 |
StatusChanged(this, new StatusChangedEventArgs { CurrentPage = lastPageNo, Message = "" }); |
1193 |
} |
1194 |
//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); |
1195 |
//pdfStamper.AddFileAttachment("F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", pfs); |
1196 |
|
1197 |
pdfStamper.Outlines = root; |
1198 |
pdfStamper.Close(); |
1199 |
pdfReader.Close(); |
1200 |
} |
1201 |
} |
1202 |
} |
1203 |
#endregion |
1204 |
} |
1205 |
|
1206 |
if (tempFileInfo.Exists) |
1207 |
{ |
1208 |
#if !DEBUG |
1209 |
tempFileInfo.Delete(); |
1210 |
#endif |
1211 |
} |
1212 |
|
1213 |
if (File.Exists(pdfFilePath)) |
1214 |
{ |
1215 |
string destfilepath = null; |
1216 |
try |
1217 |
{ |
1218 |
FinalPDFPath = new FileInfo(pdfFilePath); |
1219 |
|
1220 |
/// 정리 필요함. DB로 변경 |
1221 |
string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
1222 |
|
1223 |
if(!string.IsNullOrEmpty(pdfmovepath)) |
1224 |
{ |
1225 |
_FinalPDFStorgeLocal = pdfmovepath; |
1226 |
} |
1227 |
|
1228 |
destfilepath = Path.Combine(_FinalPDFStorgeLocal, FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
1229 |
|
1230 |
if (File.Exists(destfilepath)) |
1231 |
File.Delete(destfilepath); |
1232 |
|
1233 |
File.Move(FinalPDFPath.FullName, destfilepath); |
1234 |
FinalPDFPath = new FileInfo(destfilepath); |
1235 |
File.Delete(pdfFilePath); |
1236 |
} |
1237 |
catch (Exception ex) |
1238 |
{ |
1239 |
SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString()); |
1240 |
} |
1241 |
|
1242 |
return true; |
1243 |
} |
1244 |
} |
1245 |
catch (Exception ex) |
1246 |
{ |
1247 |
SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString()); |
1248 |
} |
1249 |
return false; |
1250 |
} |
1251 |
|
1252 |
/// <summary> |
1253 |
/// kcom의 화살표방향과 틀려 추가함 |
1254 |
/// </summary> |
1255 |
/// <param name="PageAngle"></param> |
1256 |
/// <param name="endP"></param> |
1257 |
/// <param name="ps">box Points</param> |
1258 |
/// <param name="IsFixed"></param> |
1259 |
/// <returns></returns> |
1260 |
private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed) |
1261 |
{ |
1262 |
Point testP = endP; |
1263 |
|
1264 |
try |
1265 |
{ |
1266 |
switch (Math.Abs(PageAngle).ToString()) |
1267 |
{ |
1268 |
case "90": |
1269 |
testP = new Point(endP.X + 50, endP.Y); |
1270 |
break; |
1271 |
case "270": |
1272 |
testP = new Point(endP.X - 50, endP.Y); |
1273 |
break; |
1274 |
} |
1275 |
|
1276 |
//20180910 LJY 각도에 따라. |
1277 |
switch (Math.Abs(PageAngle).ToString()) |
1278 |
{ |
1279 |
case "90": |
1280 |
if (IsFixed) |
1281 |
{ |
1282 |
if (ps[0] == endP) //상단 |
1283 |
{ |
1284 |
testP = new Point(endP.X, endP.Y + 50); |
1285 |
//System.Diagnostics.Debug.WriteLine("상단"+ testP); |
1286 |
} |
1287 |
else if (ps[1] == endP) //하단 |
1288 |
{ |
1289 |
testP = new Point(endP.X, endP.Y - 50); |
1290 |
//System.Diagnostics.Debug.WriteLine("하단"+ testP); |
1291 |
} |
1292 |
else if (ps[2] == endP) //좌단 |
1293 |
{ |
1294 |
testP = new Point(endP.X - 50, endP.Y); |
1295 |
//System.Diagnostics.Debug.WriteLine("좌단"+ testP); |
1296 |
} |
1297 |
else if (ps[3] == endP) //우단 |
1298 |
{ |
1299 |
testP = new Point(endP.X + 50, endP.Y); |
1300 |
//System.Diagnostics.Debug.WriteLine("우단"+ testP); |
1301 |
} |
1302 |
} |
1303 |
break; |
1304 |
case "270": |
1305 |
if (IsFixed) |
1306 |
{ |
1307 |
if (ps[0] == endP) //상단 |
1308 |
{ |
1309 |
testP = new Point(endP.X, endP.Y - 50); |
1310 |
//System.Diagnostics.Debug.WriteLine("상단" + testP); |
1311 |
} |
1312 |
else if (ps[1] == endP) //하단 |
1313 |
{ |
1314 |
testP = new Point(endP.X, endP.Y + 50); |
1315 |
//System.Diagnostics.Debug.WriteLine("하단" + testP); |
1316 |
} |
1317 |
else if (ps[2] == endP) //좌단 |
1318 |
{ |
1319 |
testP = new Point(endP.X + 50, endP.Y); |
1320 |
//System.Diagnostics.Debug.WriteLine("좌단" + testP); |
1321 |
} |
1322 |
else if (ps[3] == endP) //우단 |
1323 |
{ |
1324 |
testP = new Point(endP.X - 50, endP.Y); |
1325 |
//System.Diagnostics.Debug.WriteLine("우단" + testP); |
1326 |
} |
1327 |
} |
1328 |
break; |
1329 |
default: |
1330 |
if (IsFixed) |
1331 |
{ |
1332 |
|
1333 |
if (ps[0] == endP) //상단 |
1334 |
{ |
1335 |
testP = new Point(endP.X, endP.Y - 50); |
1336 |
//System.Diagnostics.Debug.WriteLine("상단"); |
1337 |
} |
1338 |
else if (ps[1] == endP) //하단 |
1339 |
{ |
1340 |
testP = new Point(endP.X, endP.Y + 50); |
1341 |
//System.Diagnostics.Debug.WriteLine("하단"); |
1342 |
} |
1343 |
else if (ps[2] == endP) //좌단 |
1344 |
{ |
1345 |
testP = new Point(endP.X - 50, endP.Y); |
1346 |
//System.Diagnostics.Debug.WriteLine("좌단"); |
1347 |
} |
1348 |
else if (ps[3] == endP) //우단 |
1349 |
{ |
1350 |
testP = new Point(endP.X + 50, endP.Y); |
1351 |
//System.Diagnostics.Debug.WriteLine("우단"); |
1352 |
} |
1353 |
} |
1354 |
break; |
1355 |
} |
1356 |
|
1357 |
} |
1358 |
catch (Exception) |
1359 |
{ |
1360 |
} |
1361 |
|
1362 |
return testP; |
1363 |
} |
1364 |
|
1365 |
private Point Test(Rect rect,Point point) |
1366 |
{ |
1367 |
Point result = new Point(); |
1368 |
|
1369 |
Point newPoint = new Point(); |
1370 |
|
1371 |
double oldNear = 0; |
1372 |
double newNear = 0; |
1373 |
|
1374 |
oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result); |
1375 |
|
1376 |
newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint); |
1377 |
|
1378 |
if (newNear < oldNear) |
1379 |
{ |
1380 |
oldNear = newNear; |
1381 |
result = newPoint; |
1382 |
} |
1383 |
|
1384 |
newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint); |
1385 |
|
1386 |
if (newNear < oldNear) |
1387 |
{ |
1388 |
oldNear = newNear; |
1389 |
result = newPoint; |
1390 |
} |
1391 |
|
1392 |
|
1393 |
newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint); |
1394 |
|
1395 |
if (newNear < oldNear) |
1396 |
{ |
1397 |
oldNear = newNear; |
1398 |
result = newPoint; |
1399 |
} |
1400 |
|
1401 |
return result; |
1402 |
} |
1403 |
|
1404 |
private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor) |
1405 |
{ |
1406 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1407 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1408 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
1409 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1410 |
DoubleCollection DashSize = control.DashSize; |
1411 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1412 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
1413 |
|
1414 |
double Opacity = control.Opac; |
1415 |
|
1416 |
if (EndPoint == MidPoint) |
1417 |
{ |
1418 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1419 |
} |
1420 |
else |
1421 |
{ |
1422 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, setColor, Opacity); |
1423 |
} |
1424 |
|
1425 |
Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, setColor, Opacity); |
1426 |
|
1427 |
} |
1428 |
|
1429 |
private void DrawLine(S_LineControl control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, System.Drawing.Color setColor) |
1430 |
{ |
1431 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1432 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1433 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
1434 |
DoubleCollection DashSize = control.DashSize; |
1435 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
1436 |
|
1437 |
var Opacity = control.Opac; |
1438 |
string UserID = control.UserID; |
1439 |
double Interval = control.Interval; |
1440 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First()), scaleWidth); |
1441 |
Controls_PDF.DrawSet_Line.DrawLine(StartPoint, EndPoint, LineSize, contentByte, control.DashSize, setColor, Opacity); |
1442 |
switch (control.LineStyleSet) |
1443 |
{ |
1444 |
case LineStyleSet.ArrowLine: |
1445 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1446 |
break; |
1447 |
case LineStyleSet.CancelLine: |
1448 |
{ |
1449 |
var x = Math.Abs((Math.Abs(control.StartPoint.X) - Math.Abs(control.EndPoint.X))); |
1450 |
var y = Math.Abs((Math.Abs(control.StartPoint.Y) - Math.Abs(control.EndPoint.Y))); |
1451 |
|
1452 |
Point newStartPoint = new Point(); |
1453 |
Point newEndPoint = new Point(); |
1454 |
|
1455 |
if (x > y) |
1456 |
{ |
1457 |
newStartPoint = new Point(control.StartPoint.X, control.StartPoint.Y + control.Interval); |
1458 |
newEndPoint = new Point(control.EndPoint.X, control.EndPoint.Y + control.Interval); |
1459 |
} |
1460 |
else |
1461 |
{ |
1462 |
newStartPoint = new Point(control.StartPoint.X + control.Interval, control.StartPoint.Y); |
1463 |
newEndPoint = new Point(control.EndPoint.X + control.Interval, control.EndPoint.Y); |
1464 |
} |
1465 |
|
1466 |
newStartPoint = GetPdfPointSystem(newStartPoint); |
1467 |
newEndPoint = GetPdfPointSystem(newEndPoint); |
1468 |
|
1469 |
Controls_PDF.DrawSet_Line.DrawLine(newStartPoint, newEndPoint, LineSize, contentByte, DashSize, setColor, Opacity); |
1470 |
} |
1471 |
break; |
1472 |
case LineStyleSet.TwinLine: |
1473 |
{ |
1474 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1475 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
1476 |
} |
1477 |
break; |
1478 |
case LineStyleSet.DimLine: |
1479 |
{ |
1480 |
Controls_PDF.DrawSet_Arrow.DimAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
1481 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, StartPoint, LineSize, contentByte, setColor, Opacity); |
1482 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, EndPoint, LineSize, contentByte, setColor, Opacity); |
1483 |
} |
1484 |
break; |
1485 |
default: |
1486 |
break; |
1487 |
} |
1488 |
|
1489 |
} |
1490 |
|
1491 |
private void DrawTextBox(S_TextControl control,PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2,System.Drawing.Color setColor) |
1492 |
{ |
1493 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1494 |
string Text = control.Text; |
1495 |
|
1496 |
bool isUnderline = false; |
1497 |
control.BoxW -= scaleWidth; |
1498 |
control.BoxH -= scaleHeight; |
1499 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxW, (float)control.BoxH); |
1500 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
1501 |
Point EndPoint = GetPdfPointSystem(new Point(control.StartPoint.X + control.BoxW, control.StartPoint.Y + control.BoxH)); |
1502 |
|
1503 |
List<Point> pointSet = new List<Point>(); |
1504 |
pointSet.Add(StartPoint); |
1505 |
pointSet.Add(EndPoint); |
1506 |
|
1507 |
PaintSet paint = PaintSet.None; |
1508 |
switch (control.paintMethod) |
1509 |
{ |
1510 |
case 1: |
1511 |
{ |
1512 |
paint = PaintSet.Fill; |
1513 |
} |
1514 |
break; |
1515 |
case 2: |
1516 |
{ |
1517 |
paint = PaintSet.Hatch; |
1518 |
} |
1519 |
break; |
1520 |
default: |
1521 |
break; |
1522 |
} |
1523 |
if (control.isHighLight) paint |= PaintSet.Highlight; |
1524 |
|
1525 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First()), scaleWidth); |
1526 |
double TextSize = Convert.ToDouble(data2[1]); |
1527 |
System.Drawing.Color FontColor = setColor; |
1528 |
double Angle = control.Angle; |
1529 |
double Opacity = control.Opac; |
1530 |
FontFamily fontfamilly = FontHelper.GetFontFamily(control.fontConfig[0]); |
1531 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
1532 |
|
1533 |
FontStyle fontStyle = FontStyles.Normal; |
1534 |
if (FontStyles.Italic == TextStyle) |
1535 |
{ |
1536 |
fontStyle = FontStyles.Italic; |
1537 |
} |
1538 |
|
1539 |
FontWeight fontWeight = FontWeights.Black; |
1540 |
|
1541 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
1542 |
//강인구 수정(2018.04.17) |
1543 |
if (FontWeights.Bold == TextWeight) |
1544 |
//if (FontWeights.ExtraBold == TextWeight) |
1545 |
{ |
1546 |
fontWeight = FontWeights.Bold; |
1547 |
} |
1548 |
|
1549 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
1550 |
if (control.fontConfig.Count() == 4) |
1551 |
{ |
1552 |
decoration = TextDecorations.Underline; |
1553 |
} |
1554 |
|
1555 |
Controls_PDF.DrawSet_Text.DrawString(StartPoint, EndPoint, LineSize, contentByte, setColor, paint, TextSize, fontfamilly, fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
1556 |
} |
1557 |
|
1558 |
|
1559 |
~MarkupToPDF() |
1560 |
{ |
1561 |
this.Dispose(false); |
1562 |
} |
1563 |
|
1564 |
private bool disposed; |
1565 |
|
1566 |
public void Dispose() |
1567 |
{ |
1568 |
this.Dispose(true); |
1569 |
GC.SuppressFinalize(this); |
1570 |
} |
1571 |
|
1572 |
protected virtual void Dispose(bool disposing) |
1573 |
{ |
1574 |
if (this.disposed) return; |
1575 |
if (disposing) |
1576 |
{ |
1577 |
// IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
1578 |
} |
1579 |
// .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
1580 |
this.disposed = true; |
1581 |
} |
1582 |
|
1583 |
#endregion |
1584 |
} |
1585 |
} |