개정판 e56c1739
Fix: PDF 생성 시 ZIndex로 소팅하여 생성하도록 수정
Change-Id: I2956dadd2a80fa82fa666843934cdc791ad9dfcc
FinalService/KCOM_FinalService/KCOM_FinalService/Remoting/RemFinalPDFStation.cs | ||
---|---|---|
55 | 55 |
|
56 | 56 |
if (!Environment.UserInteractive) |
57 | 57 |
{ |
58 |
|
|
59 | 58 |
TryReFinal(); |
60 | 59 |
} |
61 |
|
|
62 | 60 |
} |
63 | 61 |
|
64 | 62 |
public RemFinalPDFStation(Logger eventLog,string RemotingPort) |
FinalService/KCOM_FinalService/MarkupToPDF/MarkupToPDF - 복사본.cs | ||
---|---|---|
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.First(); |
|
342 |
|
|
343 |
DocPageItem = _entity.DOCPAGE.Where(x => x.DOCINFO_ID == DocInfoItem.ID).ToList(); |
|
344 |
|
|
345 |
PdfFilePathRoot = PdfFilePathRoot + @"\" + FinalPDF.PROJECT_NO + "_Tile" + @"\" |
|
346 |
+ (FinalPDF.DOCUMENT_ID.All(char.IsDigit) ? (System.Convert.ToInt64(FinalPDF.DOCUMENT_ID) / 100).ToString() : FinalPDF.DOCUMENT_ID.Substring(0, 5)) |
|
347 |
+ @"\" + FinalPDF.DOCUMENT_ID + @"\"; |
|
348 |
|
|
349 |
var infoItems = _entity.MARKUP_INFO.Where(x=>x.DOCINFO_ID == DocInfoItem.ID && x.CONSOLIDATE == 1 && x.AVOID_CONSOLIDATE == 0 && x.PART_CONSOLIDATE == 0); |
|
350 |
|
|
351 |
if (infoItems.Count() == 0) |
|
352 |
{ |
|
353 |
throw new Exception("콘솔리데잇이 작업 요청 후에 수정 / 삭제 되었습니다"); |
|
354 |
} |
|
355 |
else |
|
356 |
{ |
|
357 |
MarkupInfoItem = infoItems.First(); |
|
358 |
|
|
359 |
var markupInfoVerItems = _entity.MARKUP_INFO_VERSION.Where(x => x.MARKUPINFO_ID == MarkupInfoItem.ID).ToList(); |
|
360 |
|
|
361 |
if (markupInfoVerItems.Count() > 0) |
|
362 |
{ |
|
363 |
var markupInfoVerItem = markupInfoVerItems.OrderByDescending(x => x.CREATE_DATE).First(); |
|
364 |
|
|
365 |
MarkupDataSet = _entity.MARKUP_DATA.Where(x=>x.MARKUPINFO_VERSION_ID == markupInfoVerItem.ID).OrderBy(d => d.PAGENUMBER).ToList(); |
|
366 |
} |
|
367 |
else |
|
368 |
{ |
|
369 |
throw new Exception("MARKUP_INFO_VERSION 이 존재 하지 않습니다"); |
|
370 |
} |
|
371 |
} |
|
372 |
|
|
373 |
documentItem = _entity.DOCUMENT_ITEM.Where(data => data.DOCUMENT_ID == DocInfoItem.DOCUMENT_ID && data.PROJECT_NO == FinalPDF.PROJECT_NO).FirstOrDefault(); |
|
374 |
if (documentItem == null) |
|
375 |
{ |
|
376 |
throw new Exception("DocInfo와 DocumentItem의 documentItemID가 같지 않습니다. 데이터를 확인해주세요"); |
|
377 |
} |
|
378 |
|
|
379 |
var _files = new DirectoryInfo(PdfFilePathRoot).GetFiles("*.pdf"); //해당 폴더에 파일을 |
|
380 |
|
|
381 |
#region 파일 체크 |
|
382 |
if (_files.Count() == 1) |
|
383 |
{ |
|
384 |
/// 문서 관리 시스템의 원본 PDF 파일과 비교 --> 삭제될 예정 |
|
385 |
//if (_files.First().Name.ToLower() == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower())) |
|
386 |
//{ |
|
387 |
OriginFileName = _files.First().Name; |
|
388 |
PdfFilePath = _files.First().CopyTo(TestFile, true); |
|
389 |
StatusChange($"Copy File file Count = 1 : {PdfFilePath}", 0); |
|
390 |
//} |
|
391 |
//else |
|
392 |
//{ |
|
393 |
// throw new Exception("현재 폴더 내 파일명이 데이터베이스와 상이합니다.filename:" + _files.First().Name.ToLower() + ",url:" + HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE).ToLower()); |
|
394 |
//} |
|
395 |
} |
|
396 |
else if (_files.Count() > 1) |
|
397 |
{ |
|
398 |
var originalFile = _files.Where(data => data.Name == GetFileName(HttpUtility.UrlDecode(documentItem.ORIGINAL_FILE))).FirstOrDefault(); |
|
399 |
|
|
400 |
if (originalFile == null) |
|
401 |
{ |
|
402 |
throw new Exception("해당 폴더에 복수로 PDF들 존재하고 document_Item의 문서는 존재하지 않습니다"); |
|
403 |
} |
|
404 |
else |
|
405 |
{ |
|
406 |
OriginFileName = originalFile.Name; |
|
407 |
PdfFilePath = originalFile.CopyTo(TestFile, true); |
|
408 |
StatusChange($"Copy File file Count > 1 : {PdfFilePath}", 0); |
|
409 |
} |
|
410 |
} |
|
411 |
else |
|
412 |
{ |
|
413 |
throw new FileNotFoundException("PDF를 찾지 못하였습니다"); |
|
414 |
} |
|
415 |
#endregion |
|
416 |
|
|
417 |
#region 예외처리 |
|
418 |
if (PdfFilePath == null) |
|
419 |
{ |
|
420 |
throw new Exception("작업에 필요한 PDF가 정상적으로 복사되지 않았거나 DB정보가 상이합니다"); |
|
421 |
} |
|
422 |
if (!PdfFilePath.Exists) |
|
423 |
{ |
|
424 |
throw new Exception("PDF원본이 존재하지 않습니다"); |
|
425 |
} |
|
426 |
#endregion |
|
427 |
|
|
428 |
} |
|
429 |
else |
|
430 |
{ |
|
431 |
throw new Exception("일치하는 DocInfo가 없습니다"); |
|
432 |
} |
|
433 |
} |
|
434 |
} |
|
435 |
catch (Exception ex) |
|
436 |
{ |
|
437 |
if (ex.Message == "사용 가능한" || ex.Message == "작업을 완료했습니다") |
|
438 |
{ |
|
439 |
SetNotice(FinalPDF.ID, "Desktop 내 힙메모리 부족으로 서비스 진행이 되지 않아 재시작 합니다"); |
|
440 |
//System.Diagnostics.Process process = new System.Diagnostics.Process(); |
|
441 |
//process.StartInfo.FileName = "cmd"; |
|
442 |
//process.StartInfo.Arguments = "/c net stop \"FinalService\" & net start \"FinalService\""; |
|
443 |
//process.Start(); |
|
444 |
} |
|
445 |
else |
|
446 |
{ |
|
447 |
SetNotice(FinalPDF.ID, "PDF를 Stamp 중 에러 : " + ex.Message); |
|
448 |
} |
|
449 |
} |
|
450 |
#endregion |
|
451 |
|
|
452 |
try |
|
453 |
{ |
|
454 |
|
|
455 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
456 |
{ |
|
457 |
var finalList = _entity.FINAL_PDF.Where(final => final.ID == FinalPDF.ID); |
|
458 |
|
|
459 |
if (finalList.Count() > 0) |
|
460 |
{ |
|
461 |
//TestFile = SetFlattingPDF(TestFile); |
|
462 |
//StatusChange($"SetFlattingPDF : {TestFile}", 0); |
|
463 |
|
|
464 |
SetStampInPDF(FinalItem, TestFile, MarkupInfoItem); |
|
465 |
|
|
466 |
StatusChange($"SetStampInPDF : {TestFile}", 0); |
|
467 |
} |
|
468 |
} |
|
469 |
if (EndFinal != null) |
|
470 |
{ |
|
471 |
EndFinal(this, new EndFinalEventArgs |
|
472 |
{ |
|
473 |
FinalPDFRemotePath = _FinalPDFStorgeRemote + @"\" + FinalPDFPath.Name, |
|
474 |
OriginPDFName = OriginFileName, |
|
475 |
FinalPDFPath = FinalPDFPath.FullName, |
|
476 |
Error = "", |
|
477 |
Message = "", |
|
478 |
FinalPDF = FinalPDF, |
|
479 |
}); |
|
480 |
} |
|
481 |
} |
|
482 |
catch (Exception ex) |
|
483 |
{ |
|
484 |
SetNotice(FinalPDF.ID, "MarkFinalPDF Error : " + ex.Message); |
|
485 |
} |
|
486 |
} |
|
487 |
#endregion |
|
488 |
|
|
489 |
#region PDF |
|
490 |
public static float scaleWidth = 0; |
|
491 |
public static float scaleHeight = 0; |
|
492 |
|
|
493 |
private string SetFlattingPDF(string tempFileInfo) |
|
494 |
{ |
|
495 |
if (File.Exists(tempFileInfo)) |
|
496 |
{ |
|
497 |
FileInfo TestFile = new FileInfo(System.IO.Path.GetTempFileName()); |
|
498 |
|
|
499 |
PdfReader pdfReader = new PdfReader(tempFileInfo); |
|
500 |
|
|
501 |
for (int i = 1; i <= pdfReader.NumberOfPages; i++) |
|
502 |
{ |
|
503 |
var mediaBox = pdfReader.GetPageSize(i); |
|
504 |
var cropbox = pdfReader.GetCropBox(i); |
|
505 |
|
|
506 |
//using (CIEntities _entity = new CIEntities(ConnectStringBuilder.ProjectCIConnectString().ToString())) |
|
507 |
//{ |
|
508 |
// _entity.DOCPAGE.Where(d=>d.DOCINFO_ID == DocInfoItem.DOCPAGE) |
|
509 |
//} |
|
510 |
var currentPage = DocPageItem.Where(d => d.PAGE_NUMBER == i).FirstOrDefault(); |
|
511 |
|
|
512 |
//scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / mediaBox.Width; |
|
513 |
//scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / mediaBox.Height; |
|
514 |
//scaleWidth = 2.0832634F; |
|
515 |
//scaleHeight = 3.0F; |
|
516 |
|
|
517 |
PdfRectangle rect = new PdfRectangle(cropbox, pdfReader.GetPageRotation(i)); |
|
518 |
//강인구 수정 |
|
519 |
//if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < cropbox.Height)) |
|
520 |
//if (cropbox != null && (cropbox.Width < mediaBox.Width || cropbox.Height < mediaBox.Height)) |
|
521 |
//{ |
|
522 |
// var pageDict = pdfReader.GetPageN(i); |
|
523 |
// pageDict.Put(PdfName.MEDIABOX, rect); |
|
524 |
//} |
|
525 |
} |
|
526 |
|
|
527 |
var memStream = new MemoryStream(); |
|
528 |
var stamper = new PdfStamper(pdfReader, memStream) |
|
529 |
{ |
|
530 |
FormFlattening = true, |
|
531 |
//FreeTextFlattening = true, |
|
532 |
//AnnotationFlattening = true, |
|
533 |
}; |
|
534 |
|
|
535 |
stamper.Close(); |
|
536 |
pdfReader.Close(); |
|
537 |
var array = memStream.ToArray(); |
|
538 |
File.Delete(tempFileInfo); |
|
539 |
File.WriteAllBytes(TestFile.FullName, array); |
|
540 |
|
|
541 |
return TestFile.FullName; |
|
542 |
} |
|
543 |
else |
|
544 |
{ |
|
545 |
return tempFileInfo; |
|
546 |
} |
|
547 |
} |
|
548 |
|
|
549 |
public void flattenPdfFile(string src, ref string dest) |
|
550 |
{ |
|
551 |
PdfReader reader = new PdfReader(src); |
|
552 |
var memStream = new MemoryStream(); |
|
553 |
var stamper = new PdfStamper(reader, memStream) |
|
554 |
{ |
|
555 |
FormFlattening = true, |
|
556 |
FreeTextFlattening = true, |
|
557 |
AnnotationFlattening = true, |
|
558 |
}; |
|
559 |
|
|
560 |
stamper.Close(); |
|
561 |
var array = memStream.ToArray(); |
|
562 |
File.WriteAllBytes(dest, array); |
|
563 |
} |
|
564 |
|
|
565 |
public void StatusChange(string message,int CurrentPage) |
|
566 |
{ |
|
567 |
if(StatusChanged != null) |
|
568 |
{ |
|
569 |
//var sb = new StringBuilder(); |
|
570 |
//sb.AppendLine(message); |
|
571 |
|
|
572 |
StatusChanged(this, new StatusChangedEventArgs { CurrentPage = CurrentPage, Message = message }); |
|
573 |
} |
|
574 |
} |
|
575 |
|
|
576 |
public bool SetStampInPDF(FINAL_PDF finaldata, string testFile, MARKUP_INFO markupInfo) |
|
577 |
{ |
|
578 |
try |
|
579 |
{ |
|
580 |
|
|
581 |
FileInfo tempFileInfo = new FileInfo(testFile); |
|
582 |
|
|
583 |
if (!Directory.Exists(_FinalPDFStorgeLocal)) |
|
584 |
{ |
|
585 |
Directory.CreateDirectory(_FinalPDFStorgeLocal); |
|
586 |
} |
|
587 |
string pdfFilePath = Path.Combine(_FinalPDFStorgeLocal, tempFileInfo.Name); |
|
588 |
|
|
589 |
|
|
590 |
using (KCOMEntities _entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString())) |
|
591 |
{ |
|
592 |
FINAL_PDF pdfLink = _entity.FINAL_PDF.Where(data => data.ID == finaldata.ID).FirstOrDefault(); |
|
593 |
|
|
594 |
#region 코멘트 적용 + 커버시트 |
|
595 |
using (Stream pdfStream = new FileInfo(testFile).Open(FileMode.Open, FileAccess.ReadWrite)) // |
|
596 |
{ |
|
597 |
StatusChange("comment Cover",0); |
|
598 |
|
|
599 |
PdfReader pdfReader = new PdfReader(pdfStream); |
|
600 |
//List<Dictionary<string, object>> lstoutlineTop = new List<Dictionary<string, object>>(); |
|
601 |
Dictionary<string, object> bookmark; |
|
602 |
List<Dictionary<string, object>> outlines; |
|
603 |
|
|
604 |
outlines = new List<Dictionary<string, object>>(); |
|
605 |
List<Dictionary<string, object>> root = new List<Dictionary<string, object>>(); |
|
606 |
|
|
607 |
var dic = new Dictionary<string, object>(); |
|
608 |
|
|
609 |
foreach (var data in MarkupDataSet) |
|
610 |
{ |
|
611 |
//StatusChange("MarkupDataSet", 0); |
|
612 |
|
|
613 |
string userid = data.MARKUP_INFO_VERSION.MARKUP_INFO.USER_ID; |
|
614 |
|
|
615 |
string username = ""; |
|
616 |
string userdept = ""; |
|
617 |
|
|
618 |
using (CIEntities cIEntities = new CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(finaldata.PROJECT_NO).ToString())) |
|
619 |
{ |
|
620 |
var memberlist = KCOMDataModel.Common.ObjectQuery.GetMemberQuery(cIEntities, userid); |
|
621 |
|
|
622 |
if(memberlist.Count() > 0) |
|
623 |
{ |
|
624 |
username = memberlist.First().NAME; |
|
625 |
userdept = memberlist.First().DEPARTMENT; |
|
626 |
} |
|
627 |
} |
|
628 |
|
|
629 |
bookmark = new Dictionary<string, object>(); |
|
630 |
bookmark.Add("Title", string.Format("User:{0}[{1}] Commented Page : {2}", username, userdept, data.PAGENUMBER)); |
|
631 |
bookmark.Add("Page", data.PAGENUMBER + " Fit"); |
|
632 |
bookmark.Add("Action", "GoTo"); |
|
633 |
bookmark.Add("Kids", outlines); |
|
634 |
root.Add(bookmark); |
|
635 |
} |
|
636 |
|
|
637 |
|
|
638 |
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(pdfFilePath, FileMode.Create))) |
|
639 |
{ |
|
640 |
AcroFields pdfFormFields = pdfStamper.AcroFields; |
|
641 |
|
|
642 |
try |
|
643 |
{ |
|
644 |
if (pdfFormFields.GenerateAppearances != true) |
|
645 |
{ |
|
646 |
pdfFormFields.GenerateAppearances = true; |
|
647 |
} |
|
648 |
} |
|
649 |
catch (Exception ex) |
|
650 |
{ |
|
651 |
SetNotice(FinalItem.ID, "this pdf is not AcroForm."); |
|
652 |
} |
|
653 |
|
|
654 |
var _SetColor = new SolidColorBrush(Colors.Red); |
|
655 |
|
|
656 |
string[] delimiterChars = { "|DZ|" }; |
|
657 |
string[] delimiterChars2 = { "|" }; |
|
658 |
|
|
659 |
//pdfStamper.FormFlattening = true; //이미 선처리 작업함 |
|
660 |
pdfStamper.SetFullCompression(); |
|
661 |
_SetColor = new SolidColorBrush(Colors.Red); |
|
662 |
|
|
663 |
StringBuilder strLog = new StringBuilder(); |
|
664 |
int lastPageNo = 0; |
|
665 |
|
|
666 |
strLog.Append($"Write {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")} markup Count : {MarkupDataSet.Count()} / "); |
|
667 |
|
|
668 |
foreach (var markupItem in MarkupDataSet) |
|
669 |
{ |
|
670 |
/// 2020.11.13 김태성 |
|
671 |
/// 원본 PDF의 페이지수가 변경된 경우 이전 markup의 페이지를 찾지 못해 수정함. |
|
672 |
var pageitems = DocPageItem.Where(d => d.PAGE_NUMBER == markupItem.PAGENUMBER); |
|
673 |
|
|
674 |
if(pageitems.Count() > 0) |
|
675 |
{ |
|
676 |
var currentPage = pageitems.First(); |
|
677 |
pdfSize = pdfReader.GetPageSizeWithRotation(markupItem.PAGENUMBER); |
|
678 |
lastPageNo = markupItem.PAGENUMBER; |
|
679 |
//try |
|
680 |
//{ |
|
681 |
|
|
682 |
//} |
|
683 |
//catch (Exception ex) |
|
684 |
//{ |
|
685 |
// SetNotice(finaldata.ID, $"GetPageSizeWithRotation Error PageNO : {markupItem.PAGENUMBER} " + ex.ToString()); |
|
686 |
//} |
|
687 |
//finally |
|
688 |
//{ |
|
689 |
// pdfSize = new iTextSharp.text.Rectangle(0, 0, float.Parse(currentPage.PAGE_WIDTH), float.Parse(currentPage.PAGE_HEIGHT)); |
|
690 |
//} |
|
691 |
|
|
692 |
mediaBox = pdfReader.GetPageSize(markupItem.PAGENUMBER); |
|
693 |
var cropBox = pdfReader.GetCropBox(markupItem.PAGENUMBER); |
|
694 |
|
|
695 |
/// media box와 crop box가 다를 경우 media box를 crop box와 일치시킨다 |
|
696 |
if (cropBox != null && |
|
697 |
(cropBox.Left != mediaBox.Left || cropBox.Top != mediaBox.Top || cropBox.Right != mediaBox.Right || cropBox.Bottom != mediaBox.Bottom)) |
|
698 |
{ |
|
699 |
PdfDictionary dict = pdfReader.GetPageN(markupItem.PAGENUMBER); |
|
700 |
|
|
701 |
PdfArray oNewMediaBox = new PdfArray(); |
|
702 |
oNewMediaBox.Add(new PdfNumber(cropBox.Left)); |
|
703 |
oNewMediaBox.Add(new PdfNumber(cropBox.Top)); |
|
704 |
oNewMediaBox.Add(new PdfNumber(cropBox.Right)); |
|
705 |
oNewMediaBox.Add(new PdfNumber(cropBox.Bottom)); |
|
706 |
dict.Put(PdfName.MEDIABOX, oNewMediaBox); |
|
707 |
|
|
708 |
pdfSize = cropBox; |
|
709 |
} |
|
710 |
|
|
711 |
scaleWidth = float.Parse(currentPage.PAGE_WIDTH) / pdfSize.Width; |
|
712 |
scaleHeight = float.Parse(currentPage.PAGE_HEIGHT) / pdfSize.Height; |
|
713 |
|
|
714 |
pdfLink.CURRENT_PAGE = markupItem.PAGENUMBER; |
|
715 |
_entity.SaveChanges(); |
|
716 |
|
|
717 |
string[] markedData = markupItem.DATA.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
|
718 |
|
|
719 |
PdfContentByte contentByte = pdfStamper.GetOverContent(markupItem.PAGENUMBER); |
|
720 |
strLog.Append($"{markupItem.PAGENUMBER}/"); |
|
721 |
|
|
722 |
foreach (var data in markedData) |
|
723 |
{ |
|
724 |
var item = JsonSerializerHelper.UnCompressString(data); |
|
725 |
var ControlT = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(item); |
|
726 |
|
|
727 |
try |
|
728 |
{ |
|
729 |
switch (ControlT.Name) |
|
730 |
{ |
|
731 |
#region LINE |
|
732 |
case "LineControl": |
|
733 |
{ |
|
734 |
using (S_LineControl control = JsonSerializerHelper.JsonDeserialize<S_LineControl>(item)) |
|
735 |
{ |
|
736 |
DrawLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
737 |
} |
|
738 |
} |
|
739 |
break; |
|
740 |
#endregion |
|
741 |
#region ArrowControlMulti |
|
742 |
case "ArrowControl_Multi": |
|
743 |
{ |
|
744 |
using (S_ArrowControl_Multi control = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
|
745 |
{ |
|
746 |
DrawMultiArrowLine(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
747 |
} |
|
748 |
} |
|
749 |
break; |
|
750 |
#endregion |
|
751 |
#region PolyControl |
|
752 |
case "PolygonControl": |
|
753 |
using (S_PolyControl control = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(item)) |
|
754 |
{ |
|
755 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
756 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
757 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
758 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
759 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
|
760 |
double Opacity = control.Opac; |
|
761 |
DoubleCollection DashSize = control.DashSize; |
|
762 |
|
|
763 |
Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
|
764 |
} |
|
765 |
break; |
|
766 |
#endregion |
|
767 |
#region ArcControl or ArrowArcControl |
|
768 |
case "ArcControl": |
|
769 |
case "ArrowArcControl": |
|
770 |
{ |
|
771 |
using (S_ArcControl control = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(item)) |
|
772 |
{ |
|
773 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
774 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
775 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
776 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
|
777 |
DoubleCollection DashSize = control.DashSize; |
|
778 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
779 |
|
|
780 |
var Opacity = control.Opac; |
|
781 |
string UserID = control.UserID; |
|
782 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(InnerData.First())); |
|
783 |
bool IsTransOn = control.IsTransOn; |
|
784 |
|
|
785 |
if (control.IsTransOn) |
|
786 |
{ |
|
787 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
|
788 |
Controls_PDF.DrawSet_Arrow.SingleAllow(MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity, true); |
|
789 |
} |
|
790 |
else |
|
791 |
{ |
|
792 |
Controls_PDF.DrawSet_Arc.DrawArc(StartPoint, MidPoint, EndPoint, (int)LineSize, contentByte, _SetColor, Opacity); |
|
793 |
} |
|
794 |
|
|
795 |
if (ControlT.Name == "ArrowArcControl") |
|
796 |
{ |
|
797 |
Controls_PDF.DrawSet_Arrow.SingleAllow(StartPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
|
798 |
Controls_PDF.DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity); |
|
799 |
} |
|
800 |
} |
|
801 |
} |
|
802 |
break; |
|
803 |
#endregion |
|
804 |
#region RectangleControl |
|
805 |
case "RectangleControl": |
|
806 |
using (S_RectControl control = JsonSerializerHelper.JsonDeserialize<S_RectControl>(item)) |
|
807 |
{ |
|
808 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
809 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
|
810 |
var PaintStyle = control.PaintState; |
|
811 |
double Angle = control.Angle; |
|
812 |
DoubleCollection DashSize = control.DashSize; |
|
813 |
double Opacity = control.Opac; |
|
814 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
815 |
|
|
816 |
Controls_PDF.DrawSet_Shape.DrawRectangle(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
|
817 |
} |
|
818 |
break; |
|
819 |
#endregion |
|
820 |
#region TriControl |
|
821 |
case "TriControl": |
|
822 |
using (S_TriControl control = JsonSerializerHelper.JsonDeserialize<S_TriControl>(item)) |
|
823 |
{ |
|
824 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
825 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
|
826 |
var PaintStyle = control.Paint; |
|
827 |
double Angle = control.Angle; |
|
828 |
//StrokeColor = _SetColor, //색상은 레드 |
|
829 |
DoubleCollection DashSize = control.DashSize; |
|
830 |
double Opacity = control.Opac; |
|
831 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
832 |
|
|
833 |
Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity); |
|
834 |
} |
|
835 |
break; |
|
836 |
#endregion |
|
837 |
#region CircleControl |
|
838 |
case "CircleControl": |
|
839 |
using (S_CircleControl control = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(item)) |
|
840 |
{ |
|
841 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
842 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
|
843 |
var StartPoint = GetPdfPointSystem(control.StartPoint); |
|
844 |
var EndPoint = GetPdfPointSystem(control.EndPoint); |
|
845 |
var PaintStyle = control.PaintState; |
|
846 |
double Angle = control.Angle; |
|
847 |
DoubleCollection DashSize = control.DashSize; |
|
848 |
double Opacity = control.Opac; |
|
849 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
850 |
Controls_PDF.DrawSet_Shape.DrawCircle(StartPoint, EndPoint, LineSize, contentByte, DashSize, _SetColor, PaintStyle, Opacity, Angle, PointSet); |
|
851 |
|
|
852 |
} |
|
853 |
break; |
|
854 |
#endregion |
|
855 |
#region RectCloudControl |
|
856 |
case "RectCloudControl": |
|
857 |
using (S_RectCloudControl control = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(item)) |
|
858 |
{ |
|
859 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
860 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
|
861 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
862 |
double size = MathSet.DistanceTo(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
|
863 |
|
|
864 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
|
865 |
|
|
866 |
var PaintStyle = control.PaintState; |
|
867 |
double Opacity = control.Opac; |
|
868 |
DoubleCollection DashSize = control.DashSize; |
|
869 |
|
|
870 |
//드로잉 방식이 표현되지 않음 |
|
871 |
var rrrr = returnAngle(GetPdfPointSystem(control.StartPoint), GetPdfPointSystem(control.EndPoint)); |
|
872 |
|
|
873 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
|
874 |
bool reverse = (area < 0); |
|
875 |
if (PaintStyle == PaintSet.None) |
|
876 |
{ |
|
877 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
|
878 |
} |
|
879 |
else |
|
880 |
{ |
|
881 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
|
882 |
} |
|
883 |
} |
|
884 |
break; |
|
885 |
#endregion |
|
886 |
#region CloudControl |
|
887 |
case "CloudControl": |
|
888 |
using (S_CloudControl control = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(item)) |
|
889 |
{ |
|
890 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
891 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
|
892 |
double Toler = control.Toler; |
|
893 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
894 |
double ArcLength = (control.ArcLength == 0 ? 10 : control.ArcLength) / (scaleWidth > scaleHeight ? scaleWidth : scaleHeight); |
|
895 |
var PaintStyle = control.PaintState; |
|
896 |
double Opacity = control.Opac; |
|
897 |
bool isTransOn = control.IsTrans; |
|
898 |
bool isChain = control.IsChain; |
|
899 |
|
|
900 |
DoubleCollection DashSize = control.DashSize; |
|
901 |
|
|
902 |
if (isChain) |
|
903 |
{ |
|
904 |
Controls_PDF.DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity); |
|
905 |
} |
|
906 |
else |
|
907 |
{ |
|
908 |
if (isTransOn) |
|
909 |
{ |
|
910 |
double area = MathSet.AreaOf(GetPdfPointSystem(control.PointSet)); |
|
911 |
bool reverse = (area < 0); |
|
912 |
|
|
913 |
if (PaintStyle == PaintSet.None) |
|
914 |
{ |
|
915 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
|
916 |
} |
|
917 |
else |
|
918 |
{ |
|
919 |
Controls_PDF.DrawSet_Cloud.DrawCloud(PointSet, LineSize, ArcLength, contentByte, control.DashSize, _SetColor, _SetColor, PaintStyle, Opacity); |
|
920 |
} |
|
921 |
} |
|
922 |
else |
|
923 |
{ |
|
924 |
Controls_PDF.DrawSet_Shape.DrawPolygon(PointSet, LineSize, contentByte, control.DashSize, _SetColor, PaintStyle, Opacity); |
|
925 |
} |
|
926 |
} |
|
927 |
} |
|
928 |
break; |
|
929 |
#endregion |
|
930 |
#region TEXT |
|
931 |
case "TextControl": |
|
932 |
using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
|
933 |
{ |
|
934 |
DrawTextBox(control, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
935 |
} |
|
936 |
break; |
|
937 |
#endregion |
|
938 |
#region ArrowTextControl |
|
939 |
case "ArrowTextControl": |
|
940 |
using (S_ArrowTextControl control = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(item)) |
|
941 |
{ |
|
942 |
//using (S_TextControl textcontrol = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item)) |
|
943 |
//{ |
|
944 |
// textcontrol.Angle = control.Angle; |
|
945 |
// textcontrol.BoxH = control.BoxHeight; |
|
946 |
// textcontrol.BoxW = control.BoxWidth; |
|
947 |
// textcontrol.EndPoint = control.EndPoint; |
|
948 |
// textcontrol.FontColor = "#FFFF0000"; |
|
949 |
// textcontrol.Name = "TextControl"; |
|
950 |
// textcontrol.Opac = control.Opac; |
|
951 |
// textcontrol.PointSet = new List<Point>(); |
|
952 |
// textcontrol.SizeSet = string.Join(delimiterChars2.First(), control.SizeSet.First(), control.fontConfig[3]); |
|
953 |
// textcontrol.StartPoint = control.StartPoint; |
|
954 |
// textcontrol.Text = control.ArrowText; |
|
955 |
// textcontrol.TransformPoint = control.TransformPoint; |
|
956 |
// textcontrol.UserID = null; |
|
957 |
// textcontrol.fontConfig = control.fontConfig; |
|
958 |
// textcontrol.isHighLight = control.isHighLight; |
|
959 |
// textcontrol.paintMethod = 1; |
|
960 |
|
|
961 |
// DrawTextBox(textcontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
962 |
//} |
|
963 |
|
|
964 |
//using (S_ArrowControl_Multi linecontrol = JsonSerializerHelper.JsonDeserialize<S_ArrowControl_Multi>(item)) |
|
965 |
//{ |
|
966 |
// linecontrol.Angle = control.Angle; |
|
967 |
// linecontrol.DashSize = new DoubleCollection(new[] {(double)999999 }); |
|
968 |
// linecontrol.EndPoint = control.EndPoint; |
|
969 |
// linecontrol.MidPoint = control.MidPoint; |
|
970 |
// linecontrol.Name = "ArrowControl_Multi"; |
|
971 |
// linecontrol.Opac = control.Opac; |
|
972 |
// linecontrol.PointSet = control.PointSet; |
|
973 |
// linecontrol.SizeSet = control.SizeSet; |
|
974 |
// linecontrol.StartPoint = control.StartPoint; |
|
975 |
// linecontrol.StrokeColor = control.StrokeColor; |
|
976 |
// linecontrol.TransformPoint = control.TransformPoint; |
|
977 |
|
|
978 |
// DrawMultiArrowLine(linecontrol, contentByte, delimiterChars, delimiterChars2, _SetColor); |
|
979 |
//} |
|
980 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
981 |
Point tempStartPoint = GetPdfPointSystem(control.StartPoint); |
|
982 |
Point tempMidPoint = GetPdfPointSystem(control.MidPoint); |
|
983 |
Point tempEndPoint = GetPdfPointSystem(control.EndPoint); |
|
984 |
bool isUnderLine = false; |
|
985 |
string Text = ""; |
|
986 |
double fontsize = 30; |
|
987 |
|
|
988 |
System.Drawing.SizeF sizeF = new System.Drawing.SizeF((float)control.BoxWidth, (float)control.BoxHeight); |
|
989 |
Rect rect = new Rect(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight)); |
|
990 |
List<Point> tempPoint = new List<Point>(); |
|
991 |
|
|
992 |
double Angle = control.Angle; |
|
993 |
|
|
994 |
if (Math.Abs(Angle).ToString() == "90") |
|
995 |
{ |
|
996 |
Angle = 270; |
|
997 |
} |
|
998 |
else if (Math.Abs(Angle).ToString() == "270") |
|
999 |
{ |
|
1000 |
Angle = 90; |
|
1001 |
} |
|
1002 |
|
|
1003 |
var tempRectMidPoint = MathSet.getRectMiddlePoint(rect); |
|
1004 |
tempPoint.Add(new Point(rect.Left, tempRectMidPoint.Y)); |
|
1005 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Top)); |
|
1006 |
tempPoint.Add(new Point(rect.Right, tempRectMidPoint.Y)); |
|
1007 |
tempPoint.Add(new Point(tempRectMidPoint.X, rect.Bottom)); |
|
1008 |
|
|
1009 |
var newStartPoint = tempStartPoint; |
|
1010 |
var newEndPoint = MathSet.getNearPoint(tempPoint, tempMidPoint); |
|
1011 |
var newMidPoint = MathSet.getMiddlePoint(newStartPoint, newEndPoint); |
|
1012 |
|
|
1013 |
//Point testPoint = tempEndPoint; |
|
1014 |
//if (Angle != 0) |
|
1015 |
//{ |
|
1016 |
// testPoint = GetArrowTextControlTestPoint(0, newMidPoint, tempPoint, control.isFixed); |
|
1017 |
// //testPoint = Test(rect, newMidPoint); |
|
1018 |
//} |
|
1019 |
|
|
1020 |
double LineSize = Common.ConverterLineSize.Convert(Convert.ToInt32(data2.First())); |
|
1021 |
SolidColorBrush FontColor = _SetColor; |
|
1022 |
bool isHighlight = control.isHighLight; |
|
1023 |
double Opacity = control.Opac; |
|
1024 |
PaintSet Paint = PaintSet.None; |
|
1025 |
|
|
1026 |
switch (control.ArrowStyle) |
|
1027 |
{ |
|
1028 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Normal: |
|
1029 |
{ |
|
1030 |
Paint = PaintSet.None; |
|
1031 |
} |
|
1032 |
break; |
|
1033 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud: |
|
1034 |
{ |
|
1035 |
Paint = PaintSet.Hatch; |
|
1036 |
} |
|
1037 |
break; |
|
1038 |
case Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect: |
|
1039 |
{ |
|
1040 |
Paint = PaintSet.Fill; |
|
1041 |
} |
|
1042 |
break; |
|
1043 |
default: |
|
1044 |
break; |
|
1045 |
} |
|
1046 |
if (control.isHighLight) Paint |= PaintSet.Highlight; |
|
1047 |
|
|
1048 |
if (Paint == PaintSet.Hatch) |
|
1049 |
{ |
|
1050 |
Text = control.ArrowText; |
|
1051 |
} |
|
1052 |
else |
|
1053 |
{ |
|
1054 |
Text = control.ArrowText; |
|
1055 |
} |
|
1056 |
|
|
1057 |
try |
|
1058 |
{ |
|
1059 |
if (control.fontConfig.Count == 4) |
|
1060 |
{ |
|
1061 |
fontsize = Convert.ToDouble(control.fontConfig[3]); |
|
1062 |
} |
|
1063 |
|
|
1064 |
//강인구 수정(2018.04.17) |
|
1065 |
var TextStyle = Common.StringToFont.ConFontStyle(control.fontConfig[1]); |
|
1066 |
|
|
1067 |
FontStyle fontStyle = FontStyles.Normal; |
|
1068 |
if (FontStyles.Italic == TextStyle) |
|
1069 |
{ |
|
1070 |
fontStyle = FontStyles.Italic; |
|
1071 |
} |
|
1072 |
|
|
1073 |
FontWeight fontWeight = FontWeights.Black; |
|
1074 |
|
|
1075 |
var TextWeight = Common.StringToFont.ConFontWeight(control.fontConfig[2]); |
|
1076 |
if (FontWeights.Bold == TextWeight) |
|
1077 |
{ |
|
1078 |
fontWeight = FontWeights.Bold; |
|
1079 |
} |
|
1080 |
|
|
1081 |
TextDecorationCollection decoration = TextDecorations.Baseline; |
|
1082 |
if (control.fontConfig.Count() == 5) |
|
1083 |
{ |
|
1084 |
decoration = TextDecorations.Underline; |
|
1085 |
} |
|
1086 |
|
|
1087 |
if (control.isTrans) |
|
1088 |
{ |
|
1089 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
|
1090 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
|
1091 |
newStartPoint, tempMidPoint, newEndPoint, control.isFixed, |
|
1092 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
|
1093 |
} |
|
1094 |
else |
|
1095 |
{ |
|
1096 |
if (control.isFixed) |
|
1097 |
{ |
|
1098 |
var testP = new Point(0, 0); |
|
1099 |
if (control.isFixed) |
|
1100 |
{ |
|
1101 |
if (tempPoint[1] == newEndPoint) |
|
1102 |
{ |
|
1103 |
testP = new Point(newEndPoint.X, newEndPoint.Y - 10); |
|
1104 |
} |
|
1105 |
else if (tempPoint[3] == newEndPoint) |
|
1106 |
{ |
|
1107 |
testP = new Point(newEndPoint.X, newEndPoint.Y + 10); |
|
1108 |
} |
|
1109 |
else if (tempPoint[0] == newEndPoint) |
|
1110 |
{ |
|
1111 |
testP = new Point(newEndPoint.X - 10, newEndPoint.Y); |
|
1112 |
} |
|
1113 |
else if (tempPoint[2] == newEndPoint) |
|
1114 |
{ |
|
1115 |
testP = new Point(newEndPoint.X + 10, newEndPoint.Y); |
|
1116 |
} |
|
1117 |
} |
|
1118 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
|
1119 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
|
1120 |
tempStartPoint, testP, tempEndPoint, control.isFixed, |
|
1121 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, |
|
1122 |
FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
|
1123 |
} |
|
1124 |
else |
|
1125 |
{ |
|
1126 |
//인구 수정 Arrow Text Style적용 되도록 변경 |
|
1127 |
Controls_PDF.DrawSet_Text.DrawString_ArrowText(tempEndPoint, new Point(tempEndPoint.X + control.BoxWidth / scaleWidth, tempEndPoint.Y - control.BoxHeight / scaleHeight), |
|
1128 |
newStartPoint, tempMidPoint, tempEndPoint, control.isFixed, |
|
1129 |
LineSize, contentByte, _SetColor, Paint, fontsize, isHighlight, FontHelper.GetFontFamily(control.fontConfig[0]), fontStyle, fontWeight, decoration, Text, sizeF, Opacity, Angle); |
|
1130 |
} |
|
1131 |
} |
|
1132 |
} |
|
1133 |
catch (Exception ex) |
|
1134 |
{ |
|
1135 |
throw ex; |
|
1136 |
} |
|
1137 |
|
|
1138 |
} |
|
1139 |
break; |
|
1140 |
#endregion |
|
1141 |
#region SignControl |
|
1142 |
case "SignControl": |
|
1143 |
using (S_SignControl control = JsonSerializerHelper.JsonDeserialize<S_SignControl>(item)) |
|
1144 |
{ |
|
1145 |
|
|
1146 |
double Angle = control.Angle; |
|
1147 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
1148 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
|
1149 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
1150 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
|
1151 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
1152 |
double Opacity = control.Opac; |
|
1153 |
string UserNumber = control.UserNumber; |
|
1154 |
Controls_PDF.DrawSet_Image.DrawSign(StartPoint, EndPoint, PointSet, contentByte, UserNumber, Angle, Opacity, finaldata.PROJECT_NO); |
|
1155 |
} |
|
1156 |
break; |
|
1157 |
#endregion |
|
1158 |
#region MyRegion |
|
1159 |
case "DateControl": |
|
1160 |
using (S_DateControl control = JsonSerializerHelper.JsonDeserialize<S_DateControl>(item)) |
|
1161 |
{ |
|
1162 |
string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
1163 |
string Text = control.Text; |
|
1164 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
1165 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
1166 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
|
1167 |
SolidColorBrush FontColor = _SetColor; |
|
1168 |
double Angle = control.Angle; |
|
1169 |
double Opacity = control.Opac; |
|
1170 |
Controls_PDF.PDFLib_DrawSet_Text.DrawDate(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Text, Angle, Opacity); |
|
1171 |
} |
|
1172 |
break; |
|
1173 |
#endregion |
|
1174 |
#region SymControlN (APPROVED) |
|
1175 |
case "SymControlN": |
|
1176 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
|
1177 |
{ |
|
1178 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
1179 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
1180 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
|
1181 |
SolidColorBrush FontColor = _SetColor; |
|
1182 |
double Angle = control.Angle; |
|
1183 |
double Opacity = control.Opac; |
|
1184 |
|
|
1185 |
var stamp = _entity.PROPERTIES.Where(x => x.TYPE == "STAMP"); |
|
1186 |
|
|
1187 |
if (stamp.Count() > 0) |
|
1188 |
{ |
|
1189 |
var xamldata = Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(stamp.First().VALUE); |
|
1190 |
|
|
1191 |
Controls_PDF.PDFLib_DrawSet_Symbol.DrawApprovalXamlData(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, xamldata); |
|
1192 |
} |
|
1193 |
|
|
1194 |
string imgpath = CommonLib.Common.GetConfigString("ApprovedImgPath", "URL", ""); |
|
1195 |
|
|
1196 |
} |
|
1197 |
break; |
|
1198 |
case "SymControl": |
|
1199 |
using (S_SymControl control = JsonSerializerHelper.JsonDeserialize<S_SymControl>(item)) |
|
1200 |
{ |
|
1201 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
1202 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
1203 |
List<Point> pointSet = GetPdfPointSystem(control.PointSet); |
|
1204 |
SolidColorBrush FontColor = _SetColor; |
|
1205 |
double Angle = control.Angle; |
|
1206 |
double Opacity = control.Opac; |
|
1207 |
|
|
1208 |
string imgpath = CommonLib.Common.GetConfigString("CheckmarkImgPath", "URL", ""); |
|
1209 |
Controls_PDF.PDFLib_DrawSet_Symbol.DrawCheckMark(StartPoint, EndPoint, pointSet, contentByte, _SetColor, Angle, Opacity, imgpath); |
|
1210 |
} |
|
1211 |
break; |
|
1212 |
#endregion |
|
1213 |
#region Image |
|
1214 |
case "ImgControl": |
|
1215 |
using (S_ImgControl control = JsonSerializerHelper.JsonDeserialize<S_ImgControl>(item)) |
|
1216 |
{ |
|
1217 |
double Angle = control.Angle; |
|
1218 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
1219 |
Point TopRightPoint = GetPdfPointSystem(control.TR); |
|
1220 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
1221 |
Point LeftBottomPoint = GetPdfPointSystem(control.LB); |
|
1222 |
List<Point> PointSet = GetPdfPointSystem(control.PointSet); |
|
1223 |
double Opacity = control.Opac; |
|
1224 |
string FilePath = control.ImagePath; |
|
1225 |
//Uri uri = new Uri(s.ImagePath); |
|
1226 |
|
|
1227 |
Controls_PDF.DrawSet_Image.DrawImage(StartPoint, EndPoint, PointSet, contentByte, FilePath, Angle, Opacity); |
|
1228 |
} |
|
1229 |
break; |
|
1230 |
#endregion |
|
1231 |
default: |
|
1232 |
StatusChange($"{ControlT.Name} Not Support", 0); |
|
1233 |
break; |
|
1234 |
} |
|
1235 |
|
|
1236 |
} |
|
1237 |
catch (Exception ex) |
|
1238 |
{ |
|
1239 |
StatusChange($"markupItem : {markupItem.ID}" + ex.ToString(), 0); |
|
1240 |
} |
|
1241 |
finally |
|
1242 |
{ |
|
1243 |
if(ControlT?.Name != null) |
|
1244 |
{ |
|
1245 |
strLog.Append($"{ControlT.Name},"); |
|
1246 |
} |
|
1247 |
} |
|
1248 |
} |
|
1249 |
|
|
1250 |
} |
|
1251 |
} |
|
1252 |
|
|
1253 |
if (StatusChanged != null) |
|
1254 |
{ |
|
1255 |
StatusChanged(this, new StatusChangedEventArgs { CurrentPage = lastPageNo, Message = strLog.ToString() }); |
|
1256 |
} |
|
1257 |
//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); |
|
1258 |
//pdfStamper.AddFileAttachment("F-000-5378-702_R2_계장 Cable Schedule Sample.xlsx", pfs); |
|
1259 |
|
|
1260 |
pdfStamper.Outlines = root; |
|
1261 |
pdfStamper.Close(); |
|
1262 |
pdfReader.Close(); |
|
1263 |
} |
|
1264 |
} |
|
1265 |
#endregion |
|
1266 |
} |
|
1267 |
|
|
1268 |
if (tempFileInfo.Exists) |
|
1269 |
{ |
|
1270 |
#if !DEBUG |
|
1271 |
tempFileInfo.Delete(); |
|
1272 |
#endif |
|
1273 |
} |
|
1274 |
|
|
1275 |
if (File.Exists(pdfFilePath)) |
|
1276 |
{ |
|
1277 |
string destfilepath = null; |
|
1278 |
try |
|
1279 |
{ |
|
1280 |
FinalPDFPath = new FileInfo(pdfFilePath); |
|
1281 |
|
|
1282 |
/// 정리 필요함. DB로 변경 |
|
1283 |
string pdfmovepath = CommonLib.Common.GetConfigString("PDFMovePath", "URL", ""); |
|
1284 |
|
|
1285 |
if(!string.IsNullOrEmpty(pdfmovepath)) |
|
1286 |
{ |
|
1287 |
_FinalPDFStorgeLocal = pdfmovepath; |
|
1288 |
} |
|
1289 |
|
|
1290 |
destfilepath = Path.Combine(_FinalPDFStorgeLocal, FinalPDFPath.Name.Replace(".tmp", ".pdf")); |
|
1291 |
|
|
1292 |
if (File.Exists(destfilepath)) |
|
1293 |
File.Delete(destfilepath); |
|
1294 |
|
|
1295 |
File.Move(FinalPDFPath.FullName, destfilepath); |
|
1296 |
FinalPDFPath = new FileInfo(destfilepath); |
|
1297 |
File.Delete(pdfFilePath); |
|
1298 |
} |
|
1299 |
catch (Exception ex) |
|
1300 |
{ |
|
1301 |
SetNotice(finaldata.ID, $"File move error - Source File : {FinalPDFPath.FullName} dest File : {destfilepath}" + ex.ToString()); |
|
1302 |
} |
|
1303 |
|
|
1304 |
return true; |
|
1305 |
} |
|
1306 |
} |
|
1307 |
catch (Exception ex) |
|
1308 |
{ |
|
1309 |
SetNotice(finaldata.ID, "SetStempinPDF error: " + ex.ToString()); |
|
1310 |
} |
|
1311 |
return false; |
|
1312 |
} |
|
1313 |
|
|
1314 |
/// <summary> |
|
1315 |
/// kcom의 화살표방향과 틀려 추가함 |
|
1316 |
/// </summary> |
|
1317 |
/// <param name="PageAngle"></param> |
|
1318 |
/// <param name="endP"></param> |
|
1319 |
/// <param name="ps">box Points</param> |
|
1320 |
/// <param name="IsFixed"></param> |
|
1321 |
/// <returns></returns> |
|
1322 |
private Point GetArrowTextControlTestPoint(double PageAngle,Point endP,List<Point> ps,bool IsFixed) |
|
1323 |
{ |
|
1324 |
Point testP = endP; |
|
1325 |
|
|
1326 |
try |
|
1327 |
{ |
|
1328 |
switch (Math.Abs(PageAngle).ToString()) |
|
1329 |
{ |
|
1330 |
case "90": |
|
1331 |
testP = new Point(endP.X + 50, endP.Y); |
|
1332 |
break; |
|
1333 |
case "270": |
|
1334 |
testP = new Point(endP.X - 50, endP.Y); |
|
1335 |
break; |
|
1336 |
} |
|
1337 |
|
|
1338 |
//20180910 LJY 각도에 따라. |
|
1339 |
switch (Math.Abs(PageAngle).ToString()) |
|
1340 |
{ |
|
1341 |
case "90": |
|
1342 |
if (IsFixed) |
|
1343 |
{ |
|
1344 |
if (ps[0] == endP) //상단 |
|
1345 |
{ |
|
1346 |
testP = new Point(endP.X, endP.Y + 50); |
|
1347 |
//System.Diagnostics.Debug.WriteLine("상단"+ testP); |
|
1348 |
} |
|
1349 |
else if (ps[1] == endP) //하단 |
|
1350 |
{ |
|
1351 |
testP = new Point(endP.X, endP.Y - 50); |
|
1352 |
//System.Diagnostics.Debug.WriteLine("하단"+ testP); |
|
1353 |
} |
|
1354 |
else if (ps[2] == endP) //좌단 |
|
1355 |
{ |
|
1356 |
testP = new Point(endP.X - 50, endP.Y); |
|
1357 |
//System.Diagnostics.Debug.WriteLine("좌단"+ testP); |
|
1358 |
} |
|
1359 |
else if (ps[3] == endP) //우단 |
|
1360 |
{ |
|
1361 |
testP = new Point(endP.X + 50, endP.Y); |
|
1362 |
//System.Diagnostics.Debug.WriteLine("우단"+ testP); |
|
1363 |
} |
|
1364 |
} |
|
1365 |
break; |
|
1366 |
case "270": |
|
1367 |
if (IsFixed) |
|
1368 |
{ |
|
1369 |
if (ps[0] == endP) //상단 |
|
1370 |
{ |
|
1371 |
testP = new Point(endP.X, endP.Y - 50); |
|
1372 |
//System.Diagnostics.Debug.WriteLine("상단" + testP); |
|
1373 |
} |
|
1374 |
else if (ps[1] == endP) //하단 |
|
1375 |
{ |
|
1376 |
testP = new Point(endP.X, endP.Y + 50); |
|
1377 |
//System.Diagnostics.Debug.WriteLine("하단" + testP); |
|
1378 |
} |
|
1379 |
else if (ps[2] == endP) //좌단 |
|
1380 |
{ |
|
1381 |
testP = new Point(endP.X + 50, endP.Y); |
|
1382 |
//System.Diagnostics.Debug.WriteLine("좌단" + testP); |
|
1383 |
} |
|
1384 |
else if (ps[3] == endP) //우단 |
|
1385 |
{ |
|
1386 |
testP = new Point(endP.X - 50, endP.Y); |
|
1387 |
//System.Diagnostics.Debug.WriteLine("우단" + testP); |
|
1388 |
} |
|
1389 |
} |
|
1390 |
break; |
|
1391 |
default: |
|
1392 |
if (IsFixed) |
|
1393 |
{ |
|
1394 |
|
|
1395 |
if (ps[0] == endP) //상단 |
|
1396 |
{ |
|
1397 |
testP = new Point(endP.X, endP.Y - 50); |
|
1398 |
//System.Diagnostics.Debug.WriteLine("상단"); |
|
1399 |
} |
|
1400 |
else if (ps[1] == endP) //하단 |
|
1401 |
{ |
|
1402 |
testP = new Point(endP.X, endP.Y + 50); |
|
1403 |
//System.Diagnostics.Debug.WriteLine("하단"); |
|
1404 |
} |
|
1405 |
else if (ps[2] == endP) //좌단 |
|
1406 |
{ |
|
1407 |
testP = new Point(endP.X - 50, endP.Y); |
|
1408 |
//System.Diagnostics.Debug.WriteLine("좌단"); |
|
1409 |
} |
|
1410 |
else if (ps[3] == endP) //우단 |
|
1411 |
{ |
|
1412 |
testP = new Point(endP.X + 50, endP.Y); |
|
1413 |
//System.Diagnostics.Debug.WriteLine("우단"); |
|
1414 |
} |
|
1415 |
} |
|
1416 |
break; |
|
1417 |
} |
|
1418 |
|
|
1419 |
} |
|
1420 |
catch (Exception) |
|
1421 |
{ |
|
1422 |
} |
|
1423 |
|
|
1424 |
return testP; |
|
1425 |
} |
|
1426 |
|
|
1427 |
private Point Test(Rect rect,Point point) |
|
1428 |
{ |
|
1429 |
Point result = new Point(); |
|
1430 |
|
|
1431 |
Point newPoint = new Point(); |
|
1432 |
|
|
1433 |
double oldNear = 0; |
|
1434 |
double newNear = 0; |
|
1435 |
|
|
1436 |
oldNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.TopRight, out result); |
|
1437 |
|
|
1438 |
newNear = MathSet.GetShortestDistance(point, rect.TopLeft, rect.BottomLeft, out newPoint); |
|
1439 |
|
|
1440 |
if (newNear < oldNear) |
|
1441 |
{ |
|
1442 |
oldNear = newNear; |
|
1443 |
result = newPoint; |
|
1444 |
} |
|
1445 |
|
|
1446 |
newNear = MathSet.GetShortestDistance(point, rect.TopRight, rect.BottomRight, out newPoint); |
|
1447 |
|
|
1448 |
if (newNear < oldNear) |
|
1449 |
{ |
|
1450 |
oldNear = newNear; |
|
1451 |
result = newPoint; |
|
1452 |
} |
|
1453 |
|
|
1454 |
|
|
1455 |
newNear = MathSet.GetShortestDistance(point, rect.BottomLeft, rect.BottomRight, out newPoint); |
|
1456 |
|
|
1457 |
if (newNear < oldNear) |
|
1458 |
{ |
|
1459 |
oldNear = newNear; |
|
1460 |
result = newPoint; |
|
1461 |
} |
|
1462 |
|
|
1463 |
return result; |
|
1464 |
} |
|
1465 |
|
|
1466 |
private void DrawMultiArrowLine(S_ArrowControl_Multi control, PdfContentByte contentByte, string[] delimiterChars, string[] delimiterChars2, SolidColorBrush setColor) |
|
1467 |
{ |
|
1468 |
string[] InnerData = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
1469 |
Point StartPoint = GetPdfPointSystem(control.StartPoint); |
|
1470 |
Point MidPoint = GetPdfPointSystem(control.MidPoint); |
|
1471 |
Point EndPoint = GetPdfPointSystem(control.EndPoint); |
|
1472 |
DoubleCollection DashSize = control.DashSize; |
내보내기 Unified diff