프로젝트

일반

사용자정보

개정판 e68712b6

IDe68712b6f616783a01ed848dc228127e5bb7a4ef
상위 30ad1266
하위 008ec303

백흠경이(가) 5년 이상 전에 추가함

issue #937: 싱글 라인 텍스트가 잘리는 현상 수정(싱글 라인일때 처리하는 함수를 별도로 둠)

Change-Id: I06053877061f067acf9807d9d52eab526b8811ab

차이점 보기:

FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/HoneyPDFLib_DrawSet_DrawString.cs
148 148

  
149 149
            contentByte.SetColorStroke(bs);
150 150
            contentByte.SetColorFill(bs);
151
            
152
            ColumnText ct = new ColumnText(contentByte);
153
            PdfGState gs3 = new PdfGState();
154
            gs3.StrokeOpacity = (float)opac;
155
            gs3.FillOpacity = (float)opac;
156 151

  
157 152
            if (Char.IsWhiteSpace(text, 0))
158 153
            {
......
160 155
            }
161 156

  
162 157
            string[] tokens = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
163
            ct.Canvas.Transform(mat);
164
            ct.Canvas.SetGState(gs3);
165
            float fLeadingSize = (calRect.Height / (float)tokens.Length);
166
            float spacing = ((float)calRect.Height - tokens.Length*itextFont.CalculatedSize)/(tokens.Length+2);
167
            /// add paddings
168
            calRect.Right += (float)(lineSize * 0.5);
169
            if (calRect.Top > calRect.Bottom)
170
                calRect.Bottom -= (float)(lineSize * 0.5);
158
            /// single line text
159
            if (tokens.Length == 1)
160
            {
161
                float height = itextFont.BaseFont.GetAscentPoint(text, itextFont.CalculatedSize) - itextFont.BaseFont.GetDescentPoint(text, itextFont.CalculatedSize);
162
                float spacing = (float)((calRect.Height - height) * 0.5);
163
                System.Drawing.PointF[] origin = new System.Drawing.PointF[1]
164
                {
165
                    new System.Drawing.PointF((float)((calRect.Left + calRect.Right) * 0.5), (float)((calRect.Top + calRect.Bottom - height) * 0.5))
166
                };
167
                mat.TransformPoints(origin);
168

  
169
                ColumnText.ShowTextAligned(contentByte, Element.ALIGN_CENTER, new Phrase(new Chunk(text, itextFont)), origin[0].X, origin[0].Y, (float)-Angle);
170
            }
171
            /// multi line text
171 172
            else
172
                calRect.Top -= (float)(lineSize * 0.5);
173
            /// up to here
174
            ct.SetLeading(itextFont.CalculatedSize + (float)((tokens.Length > 1) ? spacing : 0), ct.MultipliedLeading);
175
            ct.SetSimpleColumn(calRect);
176
            ct.SetText(new Phrase(new Chunk(text, itextFont)));
177
            ct.Alignment = Element.ALIGN_MIDDLE | Element.ALIGN_CENTER;
178
            ct.Go();
173
            {
174
                ColumnText ct = new ColumnText(contentByte);
175
                PdfGState gs3 = new PdfGState();
176
                gs3.StrokeOpacity = (float)opac;
177
                gs3.FillOpacity = (float)opac;
178

  
179
                ct.Canvas.Transform(mat);
180
                ct.Canvas.SetGState(gs3);
181
                float fLeadingSize = (calRect.Height / (float)tokens.Length);
182
                float spacing = ((float)calRect.Height - tokens.Length * itextFont.CalculatedSize) / (tokens.Length + 2);
183
                /// add paddings
184
                calRect.Right += (float)(lineSize * 0.5);
185
                if (calRect.Top > calRect.Bottom)
186
                    calRect.Bottom -= (float)(lineSize * 0.5);
187
                else
188
                    calRect.Top -= (float)(lineSize * 0.5);
189
                /// up to here
190
                ct.SetLeading(itextFont.CalculatedSize + (float)((tokens.Length > 1) ? spacing : 0), ct.MultipliedLeading);
191
                ct.SetSimpleColumn(calRect);
192
                ct.Alignment = Element.ALIGN_MIDDLE | Element.ALIGN_CENTER;
193
                ct.SetText(new Phrase(new Chunk(text, itextFont)));
194
                ct.Go();
195
            }
179 196

  
180 197
            contentByte.RestoreState();
181 198
        }
......
206 223
                                   bool isHighlight, FontFamily fontFamilly, FontStyle fontstyle, FontWeight fontweight, TextDecorationCollection isUnderline,
207 224
                                   string text, System.Drawing.SizeF size, double opac, double Angle)
208 225
        {
209
            BaseColor bs = new BaseColor(color.Color.R, color.Color.G, color.Color.B, color.Color.A);
210
            contentByte.SaveState();
211

  
212 226
            Rect rect = new Rect(sp, ep);
213 227
            List<Point> points = new List<Point>
214 228
            {
215 229
                rect.TopLeft, rect.BottomLeft,
216 230
                rect.BottomRight, rect.TopRight
217 231
            };
218
            rect.Inflate(lineSize * 0.5, lineSize * 0.5);   /// 점을 중심으로 라인 두께가 그려짐으로 사각형 안쪽으로 텍스트가 쓰여지게 사각형을 키움
219

  
220
            contentByte.SetLineWidth((float)lineSize);
221 232

  
222 233
            System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
223 234
            mat.RotateAt((float)Angle * -1, new System.Drawing.PointF((float)sp.X, (float)sp.Y));
......
234 245
            var transformed = border.Select(param => new Point(param.X, param.Y)).ToList();
235 246
            /// up to here
236 247

  
237
            if ((PaintStyle & PaintSet.Hatch) == PaintSet.Hatch)
238
            {
239
                /// default arc length
240
                double ArcLength = 10 / (MarkupToPDF.scaleWidth > MarkupToPDF.scaleHeight ? MarkupToPDF.scaleWidth : MarkupToPDF.scaleHeight);
241

  
242
                DrawSet_Cloud.DrawCloud(transformed, lineSize, ArcLength, contentByte, new DoubleCollection(99999), color, new SolidColorBrush(Color.FromRgb(255, 255, 255)), (PaintStyle & ~PaintSet.Hatch) | PaintSet.Fill, 0.7);
243

  
244
                contentByte.RestoreState();
245
                contentByte.SaveState();
246
            }
247
            else
248
            {
249
                contentByte.NewPath();
250
                contentByte.MoveTo(transformed[0].X, transformed[0].Y);
251
                for (int i = 1; i <= transformed.Count; ++i) contentByte.LineTo(transformed[i% transformed.Count].X, transformed[i% transformed.Count].Y);
252
                HoneyPDFLib_DrawSet_Text.PaintFill(contentByte, PaintStyle, bs);
253
            }
254

  
255
            var calRect = MathSet.GetPointsToRectX(points);
256
            if (lineSize * 2 > calRect.Height) lineSize *= 0.3;    /// 텍스트가 뒤집어 지는것 방지
257
            /// calculate text area except border
258
            if (calRect.Top > calRect.Bottom)
259
            {
260
                calRect.Left += (float)(lineSize*0.5);
261
                calRect.Top -= (float)(lineSize*0.5);
262
                calRect.Right -= (float)(lineSize*0.5);
263
                calRect.Bottom += (float)(lineSize*0.5);
264
            }
265
            else ///Top이 작을 경우(예: 문서를 회전하여 Comment 작업한 경우)
266
            {
267
                calRect.Left += (float)(lineSize*0.5);
268
                calRect.Top += (float)(lineSize*0.5);
269
                calRect.Right -= (float)(lineSize*0.5);
270
                calRect.Bottom -= (float)(lineSize*0.5);
271
            }
272

  
273
            iTextSharp.text.Font itextFont = HoneyPDFLib_DrawSet_Text.CreateFont(fontstyle, fontweight, isUnderline, calRect, text);
274
            
275
            contentByte.SetColorStroke(bs);
276
            contentByte.SetColorFill(bs);
277

  
278
            ColumnText ct = new ColumnText(contentByte);
279
            PdfGState gs3 = new PdfGState();
280
            gs3.StrokeOpacity = (float)opac;
281
            gs3.FillOpacity = (float)opac;
282

  
283
            if (Char.IsWhiteSpace(text, 0))
284
            {
285
                text = text.Remove(0, 1);
286
            }
287

  
288
            string[] tokens = text.Split(new[]{Environment.NewLine}, StringSplitOptions.None);
289
            ct.Canvas.Transform(mat);
290
            ct.Canvas.SetGState(gs3);
291
            float spacing = ((float)calRect.Height - tokens.Length * itextFont.CalculatedSize) / (tokens.Length+2);
292
            /// add paddings
293
            calRect.Right += (float)(lineSize * 0.5);
294
            if (calRect.Top > calRect.Bottom)
295
                calRect.Bottom -= (float)(lineSize * 0.5);
296
            else
297
                calRect.Top -= (float)(lineSize * 0.5);
298
            /// up to here
299
            ct.SetLeading(itextFont.CalculatedSize + (float)(tokens.Length > 1 ? spacing : 0), ct.MultipliedLeading);
300
            ct.SetSimpleColumn(calRect);
301
            ct.SetText(new Phrase(new Chunk(text, itextFont)));
302
            ct.Alignment = Element.ALIGN_MIDDLE | Element.ALIGN_CENTER;
303
            ct.Go();
304

  
305
            contentByte.RestoreState();
306

  
248
            HoneyPDFLib_DrawSet_Text.DrawString(sp, ep, lineSize, contentByte, color, PaintStyle, FontSize, fontFamilly, fontstyle, fontweight, isUnderline, text, size, opac, Angle);
307 249
            DrawLeaderLine(ptHead, ptMid, transformed, lineSize, contentByte, color, opac);
308 250
        }
309 251

  
FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/HoneyPDFLib_DrawSet_Line.cs
164 164

  
165 165
            /// WPF defines a device-independent pixel as 1 / 96 per inch
166 166
            /// iTextSharp : "the default for the size of the unit in default user space (1/72 inch)
167
            lineSize = lineSize*72/96*0.5;
168 167
            contentByte.SetLineWidth((float)lineSize);
169 168
            for (int i = 0; i < list.Count; i++)
170 169
            {
FinalService/KCOM_FinalService/MarkupToPDF/MarkupToPDF.cs
574 574

  
575 575
                                                        if (EndPoint == MidPoint)
576 576
                                                        {
577
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, (int)LineSize, contentByte, _SetColor, Opacity);
577
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(MidPoint, StartPoint, LineSize, contentByte, _SetColor, Opacity);
578 578
                                                        }
579 579
                                                        else
580 580
                                                        {
581
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, (int)LineSize, contentByte, _SetColor, Opacity);
581
                                                            Controls_PDF.HoneyPDFLib_DrawSet_Arrow.SingleAllow(EndPoint, MidPoint, LineSize, contentByte, _SetColor, Opacity);
582 582
                                                        }
583 583

  
584 584
                                                        Controls_PDF.HoneyPDFLib_DrawSet_Line.DrawLine(PointSet, LineSize, contentByte, DashSize, _SetColor, Opacity);

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)