Ejemplo n.º 1
0
        private Paragraph CreateParagraph(string caption, float padding, ContentFont font)
        {
            var p = new Paragraph(caption);

            SetFont(font, p);
            p.SetHorizontalAlignment(HorizontalAlignment.CENTER);
            p.SetVerticalAlignment(VerticalAlignment.MIDDLE);
            p.SetPadding(padding);
            return(p);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 字体设置
 /// </summary>
 /// <typeparam name="TContent">内容类型</typeparam>
 /// <param name="font">字体定义</param>
 /// <param name="obj">对象</param>
 protected static void SetFont <TContent>(ContentFont font, ElementPropertyContainer <TContent> obj) where TContent : IPropertyContainer
 {
     if (font != null)
     {
         if (font.Style == null)
         {
             obj.SetFont(PdfFontFactory.CreateRegisteredFont(font.Name, PdfEncodings.IDENTITY_H, font.Embedded, true));
         }
         else
         {
             obj.SetFont(PdfFontFactory.CreateRegisteredFont(font.Name, PdfEncodings.IDENTITY_H, font.Embedded, font.Style.Value, true));
         }
         if (font.Size != null)
         {
             obj.SetFontSize(font.Size.Value);
         }
         if (font.Color != null)
         {
             obj.SetFontColor(font.Color);
         }
     }
 }