iTextSharp.text.Phrase.Add C# (CSharp) Метод

Add() публичный Метод

Adds a Chunk, an Anchor or another Phrase to this Phrase.
public Add ( int index, Object o ) : void
index int index at which the specified element is to be inserted
o Object an object of type Chunk, Anchor, or Phrase
Результат void
        public virtual void Add(int index, Object o) {
            if (o == null) return;
            try {
                IElement element = (IElement) o;
                if (element.Type == Element.CHUNK) {
                    Chunk chunk = (Chunk)element;
                    if (!font.IsStandardFont()) {
                        chunk.Font = font.Difference(chunk.Font);
                    }
                    if (hyphenation != null && chunk.GetHyphenation() == null && !chunk.IsEmpty()) {
                        chunk.SetHyphenation(hyphenation);
                    }
                    base.Insert(index, chunk);
                }
                else if (element.Type == Element.PHRASE ||
                    element.Type == Element.ANCHOR ||
                    element.Type == Element.ANNOTATION ||
                    element.Type == Element.TABLE || // line added by David Freels
                    element.Type == Element.YMARK || 
                    element.Type == Element.MARKED) {
                    base.Insert(index, element);
                }
                else {
                    throw new Exception(element.Type.ToString());
                }
            }
            catch (Exception cce) {
                throw new Exception("Insertion of illegal Element: " + cce.Message);
            }
        }
    

Same methods

Phrase::Add ( Object o ) : bool

Usage Example

Пример #1
0
    private void Creo_Cabecera(iTextSharp.text.pdf.PdfWriter writer, iTextSharp.text.Document document)
    {
        PdfPTable t = new PdfPTable(2);

        Single[] arrAnchosC = { 20F, 80F };
        t.SetWidthPercentage(arrAnchosC, iTextSharpText.PageSize.A4);
        t.WidthPercentage = 100;

        iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + "App_Themes\\imagenes\\logo_impresion.png");
        PdfPCell c = new PdfPCell(png);

        c.HorizontalAlignment = iTextSharpText.Element.ALIGN_LEFT;
        c.BorderWidth         = 0;

        iTextSharpText.Phrase texto = new iTextSharpText.Phrase();
        texto.Font = iTextSharpText.FontFactory.GetFont("Arial", 14, iTextSharpText.Element.ALIGN_CENTER);
        texto.Add(new iTextSharpText.Phrase("Reporte de Solicitudes de Prestamos a Liquidar\n\n"));

        texto.Font = iTextSharpText.FontFactory.GetFont("Arial", 8, iTextSharpText.Element.ALIGN_CENTER);
        texto.Add(new iTextSharpText.Phrase("Fecha Reporte: " + lst[0].Fecha_Informe.ToString("dd/MM/yyyy") + "   N° Reporte: " + lst[0].nroInforme));

        PdfPCell c1 = new PdfPCell(texto);

        c1.HorizontalAlignment = iTextSharpText.Element.ALIGN_CENTER;
        c1.BorderWidth         = 0;

        t.AddCell(c);
        t.AddCell(c1);

        iTextSharpText.Paragraph Cabecera = new iTextSharpText.Paragraph();
        Cabecera.Add(t);

        document.Add(Cabecera);
        document.Add(iTextSharpText.Chunk.NEWLINE);
    }
All Usage Examples Of iTextSharp.text.Phrase::Add