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

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

Adds a Chunk, Anchor or another Phrase to this Phrase.
public Add ( Object o ) : bool
o Object an object of type Chunk, Anchor or Phrase
Результат bool
        public virtual new bool Add(Object o) {
            if (o == null) return false;
            if (o is string) {
                base.Add(new Chunk((string) o, font));
                return true;
            }
            if (o is IRtfElementInterface) {
        	    base.Add(o);
                return true;
            }
            try {
                IElement element = (IElement) o;
                switch (element.Type) {
                    case Element.CHUNK:
                        return AddChunk((Chunk) o);
                    case Element.PHRASE:
                    case Element.PARAGRAPH:
                        Phrase phrase = (Phrase) o;
                        bool success = true;
                        foreach (IElement e in phrase) {
                            if (e is Chunk) {
                                success &= AddChunk((Chunk)e);
                            }
                            else {
                                success &= this.Add(e);
                            }
                        }
                        return success;
                    case Element.MARKED:
                    case Element.ANCHOR:
                    case Element.ANNOTATION:
                    case Element.TABLE: // case added by David Freels
                    case Element.PTABLE: // case added by Karen Vardanyan
                        // This will only work for PDF!!! Not for RTF/HTML
                    case Element.LIST:
                    case Element.YMARK:
                        base.Add(o);
                        return true;
                    default:
                        throw new Exception(element.Type.ToString());
                }
            }
            catch (Exception cce) {
                throw new Exception("Insertion of illegal Element: " + cce.Message);
            }
        }
    

Same methods

Phrase::Add ( int index, Object o ) : void

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