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