예제 #1
0
 private static void CreateImage(object document, ImageText.ImageTextControl imgControl, bool isLinked, ref Paragraph header, bool border, bool isLast)
 {
     iText.Layout.Element.Image img = new iText.Layout.Element.Image(ImageDataFactory.Create((imgControl.Controls[0] as PictureBox).Image, System.Drawing.Color.White)).SetTextAlignment(TextAlignment.LEFT);
     if (isLinked)
     {
         img.SetAction(PdfAction.CreateURI((imgControl.Controls[0] as PictureBox).Name));
     }
     if (border)
     {
         img.SetBorder(new SolidBorder(ColorConstants.GRAY, 4)); img.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);
     }
     if (document.GetType() == typeof(Document))
     {
         (document as Document).Add(header);
         (document as Document).Add(img);
     }
     else
     {
         if (document.GetType() == typeof(Cell))
         {
             (document as Cell).Add(header);
             (document as Cell).Add(img);
         }
         else
         {
             if (document.GetType() == typeof(ListItem))
             {
                 (document as ListItem).Add(header);
                 (document as ListItem).Add(img);
             }
         }
     }
     header = new Paragraph();
     header.SetTextAlignment(TextAlignment.CENTER);
     for (int i = 1; i < imgControl.Controls.Count; i++)
     {
         Style style = new Style();
         if (imgControl.Controls[i].GetType() == typeof(Label))
         {
             Label label = imgControl.Controls[i] as Label;
             style.SetFont(PdfFontFactory.CreateFont("C:\\Windows\\Fonts\\times.ttf", "Cp1251", true));
             style.SetFontSize(label.Font.Size);
             if (label.Font.Bold)
             {
                 style.SetBold();
             }
             if (label.Font.Italic)
             {
                 style.SetItalic();
             }
             if (label.Font.Underline)
             {
                 style.SetUnderline();
             }
             if (label.Font.Strikeout)
             {
                 style.SetLineThrough();
             }
             header.Add(new Text(label.Text).AddStyle(style));
         }
         else
         {
             if (imgControl.Controls[i].GetType() == typeof(Link.LinkControl))
             {
                 CreateLink(document, imgControl.Controls[i] as Link.LinkControl, header, border);
             }
         }
     }
     if (document.GetType() == typeof(Document))
     {
         (document as Document).Add(header);
     }
     else
     {
         if (document.GetType() == typeof(Cell))
         {
             (document as Cell).Add(header);
         }
         else
         {
             if (document.GetType() == typeof(ListItem))
             {
                 (document as ListItem).Add(header);
             }
         }
     }
     header = new Paragraph();
     if (border && !isLast)
     {
         header.SetBorderLeft(new SolidBorder(ColorConstants.GRAY, 4));
         header.SetPadding(30);
     }
 }