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