개정판 84e1aacc
revised issue #937: calculate font size to fit given text boundary
Change-Id: I1e30922680e6989386023b23931b2956307a9f54
FinalService/KCOM_FinalService/ConsoleApp1/Program.cs | ||
---|---|---|
44 | 44 |
|
45 | 45 |
using (KCOMEntities _entity = new KCOMEntities(KCOMDataModel.Common.ConnectStringBuilder.KCOMConnectionString().ToString())) |
46 | 46 |
{ |
47 |
|
|
48 |
//FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "ngKwBgMotw8d56dea3839120d").FirstOrDefault(); |
|
49 |
FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "Bm6qsYD9Hu8d6e7c702626345").FirstOrDefault(); |
|
47 |
FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "f8Gv6hVdw8d6e881c26a4199").FirstOrDefault(); |
|
48 |
///FINAL_PDF item = _entity.FINAL_PDF.Where(d => d.ID == "Bm6qsYD9Hu8d6e7c702626345").FirstOrDefault(); |
|
50 | 49 |
//_entity.FINAL_PDF.AddObject(new FINAL_PDF |
51 | 50 |
//{ |
52 | 51 |
// ID = Guid.NewGuid().ToString(), |
FinalService/KCOM_FinalService/MarkupToPDF/Controls/Common/PaintSet.cs | ||
---|---|---|
11 | 11 |
None = 0, |
12 | 12 |
Fill = 1, |
13 | 13 |
Hatch = 2, |
14 |
Highlight = 4 |
|
14 |
Highlight = 4, |
|
15 |
Outline = 8 |
|
15 | 16 |
}; |
16 | 17 |
public enum LineStyleSet |
17 | 18 |
{ |
FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/HoneyPDFLib_DrawSet_DrawString.cs | ||
---|---|---|
12 | 12 |
{ |
13 | 13 |
public partial class HoneyPDFLib_DrawSet_Text |
14 | 14 |
{ |
15 |
const double MARGIN = 1.5; /// it's magic number |
|
16 |
|
|
15 | 17 |
private static iTextSharp.text.Font CreateFont(FontStyle fontstyle, FontWeight fontweight, TextDecorationCollection isUnderline, Rectangle rect, string text) |
16 | 18 |
{ |
17 | 19 |
string ARIALUNI_TFF = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Arial Unicode MS.TTF"); |
... | ... | |
26 | 28 |
double size = rect.Height * ratio; |
27 | 29 |
dFontSize = size < dFontSize ? size : dFontSize; |
28 | 30 |
} |
29 |
///dFontSize = dFontSize > rect.Height ? rect.Height : dFontSize; |
|
30 |
/* |
|
31 |
width = bf.GetWidthPoint(sLongestStr, (float)dFontSize); |
|
32 |
float ascent = bf.GetAscentPoint(sLongestStr, (float)dFontSize); |
|
33 |
float descent = bf.GetDescentPoint(sLongestStr, (float)dFontSize); |
|
34 |
*/ |
|
35 | 31 |
|
36 | 32 |
iTextSharp.text.Font itextFont = new iTextSharp.text.Font(bf, (float)(dFontSize)); |
37 | 33 |
itextFont.SetStyle(0); |
... | ... | |
94 | 90 |
HoneyPDFLib_DrawSet_Text.PaintFill(contentByte, PaintStyle, bs); |
95 | 91 |
} |
96 | 92 |
|
97 |
string ARIALUNI_TFF = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Arial Unicode MS.TTF"); |
|
98 |
|
|
99 | 93 |
var calRect = MathSet.GetPointsToRectX(points); |
100 | 94 |
calRect.Left += (float)lineSize; |
101 | 95 |
calRect.Top -= (float)lineSize; |
... | ... | |
128 | 122 |
/// expand size of rectangle to prevent text disappear |
129 | 123 |
calRect.Right += itextFont.CalculatedSize; |
130 | 124 |
string[] tokens = text.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries); |
131 |
float top = calRect.Bottom + tokens.Length * itextFont.CalculatedSize + (float)2;
|
|
125 |
float top = calRect.Bottom + (tokens.Length - 1) * (itextFont.CalculatedSize + 1) + itextFont.CalculatedSize + (float)HoneyPDFLib_DrawSet_Text.MARGIN;
|
|
132 | 126 |
calRect.Top = top < calRect.Top ? calRect.Top : top; |
133 | 127 |
/// up to here |
134 | 128 |
ct.SetSimpleColumn(calRect); |
... | ... | |
199 | 193 |
ct.Canvas.Transform(mat); |
200 | 194 |
ct.Canvas.SetGState(gs3); |
201 | 195 |
ct.SetText(new Phrase(new Chunk(text, itextFont))); |
202 |
ct.Alignment = Element.ALIGN_CENTER | Element.ALIGN_TOP; |
|
196 |
ct.Alignment = Element.ALIGN_JUSTIFIED;/// Element.ALIGN_CENTER | Element.ALIGN_TOP;
|
|
203 | 197 |
ct.SetLeading(itextFont.CalculatedSize + 1, ct.MultipliedLeading); |
204 | 198 |
/// expand size of rectangle to prevent text disappear |
205 | 199 |
calRect.Right += itextFont.CalculatedSize; |
206 | 200 |
string[] tokens = text.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries); |
207 |
float top = calRect.Bottom + tokens.Length * itextFont.CalculatedSize + (float)2;
|
|
201 |
float top = calRect.Bottom + (tokens.Length - 1) * (itextFont.CalculatedSize + 1) + itextFont.CalculatedSize + (float)HoneyPDFLib_DrawSet_Text.MARGIN;;
|
|
208 | 202 |
calRect.Top = top < calRect.Top ? calRect.Top : top; |
209 | 203 |
/// up to here |
210 | 204 |
ct.SetSimpleColumn(calRect); |
FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/HoneyPDFLib_DrawSet_Shape.cs | ||
---|---|---|
141 | 141 |
contentByte.Transform(mat2); |
142 | 142 |
contentByte.Ellipse((float)sp1.X, (float)sp1.Y, (float)ep1.X, (float)ep1.Y); |
143 | 143 |
|
144 |
HoneyPDFLib_DrawSet_Shape.PaintFill(contentByte, PaintStyle, bs, opac); |
|
144 |
HoneyPDFLib_DrawSet_Shape.PaintFill(contentByte, PaintStyle | PaintSet.Outline, bs, opac);
|
|
145 | 145 |
contentByte.RestoreState(); |
146 | 146 |
} |
147 | 147 |
|
... | ... | |
185 | 185 |
PatternColor colors = new PatternColor(line); |
186 | 186 |
contentByte.SetPatternFill(line); |
187 | 187 |
contentByte.SetColorFill(colors); |
188 |
contentByte.Fill(); |
|
188 |
if ((PaintStyle & PaintSet.Outline) == PaintSet.Outline) |
|
189 |
{ |
|
190 |
contentByte.SetColorStroke(bs); |
|
191 |
contentByte.ClosePathFillStroke(); |
|
192 |
} |
|
193 |
else |
|
194 |
contentByte.Fill(); |
|
189 | 195 |
} |
190 | 196 |
|
191 |
if(PaintStyle == PaintSet.None) |
|
197 |
if (PaintStyle == PaintSet.None)
|
|
192 | 198 |
{ |
193 | 199 |
contentByte.SetColorStroke(bs); |
194 | 200 |
contentByte.ClosePathStroke(); |
FinalService/KCOM_FinalService/MarkupToPDF/MarkupToPDF.cs | ||
---|---|---|
680 | 680 |
|
681 | 681 |
double ArcLength = control.ArcLength == 0 ? 10 : control.ArcLength; |
682 | 682 |
|
683 |
//ArcLength = (size * 0.13); |
|
684 |
|
|
685 |
//강인구 수정(클라우드 사이즈) |
|
686 |
//if (ArcLength <= 10) |
|
687 |
//{ |
|
688 |
// ArcLength = 10; |
|
689 |
//} |
|
690 |
//if (ArcLength <= 3) |
|
691 |
//{ |
|
692 |
// ArcLength = 10; |
|
693 |
//} |
|
694 |
//else if (ArcLength <= 10) |
|
695 |
//{ |
|
696 |
// ArcLength = 20; |
|
697 |
//} |
|
698 |
//else if (ArcLength <= 30) |
|
699 |
//{ |
|
700 |
// ArcLength = 30; |
|
701 |
//} |
|
702 |
|
|
703 | 683 |
var PaintStyle = control.PaintState; |
704 | 684 |
double Opacity = control.Opac; |
705 | 685 |
DoubleCollection DashSize = control.DashSize; |
내보내기 Unified diff