/**
 * Adds an <CODE>Object</CODE> to the <CODE>List</CODE>.
 *
 * @param    o    the object to add.
 * @return true if adding the object succeeded
 */
 public override bool Add(Object o)
 {
     if (o is ListItem) {
         ListItem item = (ListItem) o;
         Chunk chunk = new Chunk(preSymbol, symbol.Font);
         chunk.Append(((char)zn).ToString());
         chunk.Append(postSymbol);
         item.ListSymbol = chunk;
         item.SetIndentationLeft(symbolIndent, autoindent);
         item.IndentationRight = 0;
         list.Add(item);
         return true;
     } else if (o is List) {
         List nested = (List) o;
         nested.IndentationLeft = nested.IndentationLeft + symbolIndent;
         first--;
         list.Add(nested);
         return true;
     } else if (o is String) {
         return this.Add(new ListItem((string) o));
     }
     return false;
 }
Beispiel #2
0
 /// <summary>
 /// Constructs an Anchor with a certain Chunk
 /// and a certain leading.
 /// </summary>
 /// <param name="leading">the leading</param>
 /// <param name="chunk">a Chunk</param>
 public Anchor(float leading, Chunk chunk)
     : base(leading, chunk)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Constructs an Anchor with a certain Chunk.
 /// </summary>
 /// <param name="chunk">a Chunk</param>
 public Anchor(Chunk chunk)
     : base(chunk)
 {
 }
Beispiel #4
0
 /**
  * Adds a <CODE>Chunk</CODE> to the current text array.
  * @param chunk the text
  */
 public void AddText(Chunk chunk)
 {
     chunks.Add(new PdfChunk(chunk, null));
 }
Beispiel #5
0
 /**
 * Adds extra space.
 * This method should probably be rewritten.
 */
 protected internal void AddSpacing(float extraspace, float oldleading, Font f)
 {
     if (extraspace == 0) return;
     if (pageEmpty) return;
     if (currentHeight + line.Height + leading > IndentTop - IndentBottom) return;
     leading = extraspace;
     CarriageReturn();
     if (f.IsUnderlined() || f.IsStrikethru()) {
         f = new Font(f);
         int style = f.Style;
         style &= ~Font.UNDERLINE;
         style &= ~Font.STRIKETHRU;
         f.SetStyle(style);
     }
     Chunk space = new Chunk(" ", f);
     space.Process(this);
     CarriageReturn();
     leading = oldleading;
 }
Beispiel #6
0
 /// <summary>
 /// Constructs a Paragraph with a certain Chunk.
 /// </summary>
 /// <param name="chunk">a Chunk</param>
 public Paragraph(Chunk chunk)
     : base(chunk)
 {
 }
Beispiel #7
0
 /**
 * Adds an <CODE>Object</CODE> to the <CODE>List</CODE>.
 *
 * @param    o   the object to add.
 * @return true if adding the object succeeded
 */
 public override bool Add(Object o)
 {
     if (o is ListItem) {
         ListItem item = (ListItem) o;
         Chunk chunk = new Chunk(preSymbol, symbol.Font);
         chunk.Append(GreekAlphabetFactory.GetString(first + list.Count, lowercase));
         chunk.Append(postSymbol);
         item.ListSymbol = chunk;
         item.SetIndentationLeft(symbolIndent, autoindent);
         item.IndentationRight = 0;
         list.Add(item);
         return true;
     } else if (o is List) {
         List nested = (List) o;
         nested.IndentationLeft = nested.IndentationLeft + symbolIndent;
         first--;
         list.Add(nested);
         return true;
     } else if (o is string) {
         return this.Add(new ListItem((string)o));
     }
     return false;
 }
Beispiel #8
0
 /// <summary>
 /// Constructs an Anchor with a certain Chunk
 /// and a certain leading.
 /// </summary>
 /// <param name="leading">the leading</param>
 /// <param name="chunk">a Chunk</param>
 public Anchor(float leading, Chunk chunk) : base(leading, chunk)
 {
 }
Beispiel #9
0
 // methods to set the membervariables
 /// <summary>
 /// Adds an Object to the List.
 /// </summary>
 /// <param name="o">the object to add</param>
 /// <returns>true is successful</returns>
 public virtual bool Add(Object o)
 {
     if (o is ListItem) {
         ListItem item = (ListItem) o;
         if (numbered || lettered) {
             Chunk chunk = new Chunk(preSymbol, symbol.Font);
             int index = first + list.Count;
             if (lettered)
                 chunk.Append(RomanAlphabetFactory.GetString(index, lowercase));
             else
                 chunk.Append(index.ToString());
             chunk.Append(postSymbol);
             item.ListSymbol = chunk;
         }
         else {
             item.ListSymbol = symbol;
         }
         item.SetIndentationLeft(symbolIndent, autoindent);
         item.IndentationRight = 0;
         list.Add(item);
         return true;
     }
     else if (o is List) {
         List nested = (List) o;
         nested.IndentationLeft = nested.IndentationLeft + symbolIndent;
         first--;
         list.Add(nested);
         return true;
     }
     else if (o is string) {
         return this.Add(new ListItem((string) o));
     }
     return false;
 }
Beispiel #10
0
 /// <summary>
 /// Constructs a Paragraph with a certain Chunk
 /// and a certain leading.
 /// </summary>
 /// <param name="leading">the leading</param>
 /// <param name="chunk">a Chunk</param>
 public Paragraph(float leading, Chunk chunk) : base(leading, chunk)
 {
 }
Beispiel #11
0
 /// <summary>
 /// Constructs an Anchor with a certain Chunk.
 /// </summary>
 /// <param name="chunk">a Chunk</param>
 public Anchor(Chunk chunk) : base(chunk)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Constructs a Paragraph with a certain Chunk.
 /// </summary>
 /// <param name="chunk">a Chunk</param>
 public Paragraph(Chunk chunk) : base(chunk)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Constructs a Phrase with a certain Chunk.
 /// </summary>
 /// <param name="chunk">a Chunk</param>
 public Phrase(Chunk chunk)
 {
     base.Add(chunk);
     font        = chunk.Font;
     hyphenation = chunk.GetHyphenation();
 }
Beispiel #14
0
        /**
        * Adds an image to this Cell.
        *
        * @param i           the image to add
        * @param left        the left border
        * @param right       the right border
        * @param extraHeight extra height to add above image
        * @param alignment   horizontal alignment (constant from Element class)
        * @return the height of the image
        */
        private float AddImage(Image i, float left, float right, float extraHeight, int alignment)
        {
            Image image = Image.GetInstance(i);
            if (image.ScaledWidth > right - left) {
                image.ScaleToFit(right - left, float.MaxValue);
            }
            FlushCurrentLine();
            if (line == null) {
                line = new PdfLine(left, right, alignment, leading);
            }
            PdfLine imageLine = line;

            // left and right in chunk is relative to the start of the line
            right = right - left;
            left = 0f;

            if ((image.Alignment & Image.RIGHT_ALIGN) == Image.RIGHT_ALIGN) { // fix Uwe Zimmerman
                left = right - image.ScaledWidth;
            } else if ((image.Alignment & Image.MIDDLE_ALIGN) == Image.MIDDLE_ALIGN) {
                left = left + ((right - left - image.ScaledWidth) / 2f);
            }
            Chunk imageChunk = new Chunk(image, left, 0);
            imageLine.Add(new PdfChunk(imageChunk, null));
            AddLine(imageLine);
            return imageLine.Height;
        }
        /* (non-Javadoc)
        * @see com.lowagie.text.rtf.parser.properties.RtfPropertyListener#beforeChange(java.lang.String)
        */
        public void BeforePropertyChange(String propertyName)
        {
            // do we have any text to do anything with?
            // if not, then just return without action.
            if (this.buffer.Length == 0) return;

            if (propertyName.StartsWith(RtfProperty.CHARACTER)) {
                // this is a character change,
                // add a new chunck to the current paragraph using current character settings.
                Chunk chunk = new Chunk();
                chunk.Append(this.buffer.ToString());
                this.buffer = new StringBuilder(255);
                Hashtable charProperties = this.rtfParser.GetState().properties.GetProperties(RtfProperty.CHARACTER);
                String defFont = (String)charProperties[RtfProperty.CHARACTER_FONT];
                if (defFont == null) defFont = "0";
                RtfDestinationFontTable fontTable = (RtfDestinationFontTable)this.rtfParser.GetDestination("fonttbl");
                Font currFont = fontTable.GetFont(defFont);
                int fs = Font.NORMAL;
                if (charProperties.ContainsKey(RtfProperty.CHARACTER_BOLD)) fs |= Font.BOLD;
                if (charProperties.ContainsKey(RtfProperty.CHARACTER_ITALIC)) fs |= Font.ITALIC;
                if (charProperties.ContainsKey(RtfProperty.CHARACTER_UNDERLINE)) fs |= Font.UNDERLINE;
                Font useFont = FontFactory.GetFont(currFont.Familyname, 12, fs, new Color(0,0,0));

                chunk.Font = useFont;
                if (iTextParagraph == null) this.iTextParagraph = new Paragraph();
                this.iTextParagraph.Add(chunk);

            } else {
                if (propertyName.StartsWith(RtfProperty.PARAGRAPH)) {
                    // this is a paragraph change. what do we do?
                } else {
                    if (propertyName.StartsWith(RtfProperty.SECTION)) {

                    } else {
                        if (propertyName.StartsWith(RtfProperty.DOCUMENT)) {

                        }
                    }
                }
            }
        }
Beispiel #16
0
 /// <summary>
 /// Sets the listsymbol.
 /// </summary>
 /// <remarks>
 /// This is a shortcut for SetListSymbol(Chunk symbol).
 /// </remarks>
 /// <param name="symbol">a string</param>
 public void SetListSymbol(string symbol)
 {
     this.symbol = new Chunk(symbol);
 }
        /* (non-Javadoc)
        * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
        */
        public override bool HandleCloseGroup()
        {
            this.OnCloseGroup();    // event handler

            if (this.rtfParser.IsImport()) {
                if (this.buffer.Length>0) {
                    WriteBuffer();
                }
                WriteText("}");
            }
            if (this.rtfParser.IsConvert()) {
                if (this.buffer.Length > 0 && this.iTextParagraph == null) {
                    this.iTextParagraph = new Paragraph();
                }
                if (this.buffer.Length > 0 ) {
                    Chunk chunk = new Chunk();
                    chunk.Append(this.buffer.ToString());
                    this.iTextParagraph.Add(chunk);
                }
                if (this.iTextParagraph != null) {
                    AddParagraphToDocument();
                }
            }
            return true;
        }
Beispiel #18
0
 /**
 * Process the text so that it will render with a combination of fonts
 * if needed.
 * @param text the text
 * @return a <CODE>Phrase</CODE> with one or more chunks
 */
 public Phrase Process(String text)
 {
     int fsize = fonts.Count;
     if (fsize == 0)
         throw new ArgumentException("No font is defined.");
     char[] cc = text.ToCharArray();
     int len = cc.Length;
     StringBuilder sb = new StringBuilder();
     Font font = null;
     int lastidx = -1;
     Phrase ret = new Phrase();
     for (int k = 0; k < len; ++k) {
         char c = cc[k];
         if (c == '\n' || c == '\r') {
             sb.Append(c);
             continue;
         }
         if (Utilities.IsSurrogatePair(cc, k)) {
             int u = Utilities.ConvertToUtf32(cc, k);
             for (int f = 0; f < fsize; ++f) {
                 font = (Font)fonts[f];
                 if (font.BaseFont.CharExists(u)) {
                     if (lastidx != f) {
                         if (sb.Length > 0 && lastidx != -1) {
                             Chunk ck = new Chunk(sb.ToString(), (Font)fonts[lastidx]);
                             ret.Add(ck);
                             sb.Length = 0;
                         }
                         lastidx = f;
                     }
                     sb.Append(c);
                     sb.Append(cc[++k]);
                     break;
                 }
             }
         }
         else {
             for (int f = 0; f < fsize; ++f) {
                 font = (Font)fonts[f];
                 if (font.BaseFont.CharExists(c)) {
                     if (lastidx != f) {
                         if (sb.Length > 0 && lastidx != -1) {
                             Chunk ck = new Chunk(sb.ToString(), (Font)fonts[lastidx]);
                             ret.Add(ck);
                             sb.Length = 0;
                         }
                         lastidx = f;
                     }
                     sb.Append(c);
                     break;
                 }
             }
         }
     }
     if (sb.Length > 0) {
         Chunk ck = new Chunk(sb.ToString(), (Font)fonts[lastidx == -1 ? 0 : lastidx]);
         ret.Add(ck);
     }
     return ret;
 }
Beispiel #19
0
 /**
 *
 * @param bulletCharacter
 * @since 2.1.4
 */
 public void SetBulletChunk(Chunk bulletCharacter)
 {
     this.bulletChunk = bulletCharacter;
 }
Beispiel #20
0
 /**
  * Adds a <CODE>Chunk</CODE> to the current text array.
  * Will not have any effect if addElement() was called before.
  * @param chunk the text
  * @since	2.1.5
  */
 public void AddText(Chunk chunk)
 {
     columnText.AddText(chunk);
 }
Beispiel #21
0
 /**
 * A <CODE>Chunk</CODE> copy constructor.
 * @param ck the <CODE>Chunk</CODE> to be copied
 */
 public Chunk(Chunk ck)
 {
     if (ck.content != null) {
         content = new StringBuilder(ck.content.ToString());
     }
     if (ck.font != null) {
         font = new Font(ck.font);
     }
 }
Beispiel #22
0
        /**
        * Constructs a RtfChunk based on the content of a Chunk
        *
        * @param doc The RtfDocument that this Chunk belongs to
        * @param chunk The Chunk that this RtfChunk is based on
        */
        public RtfChunk(RtfDocument doc, Chunk chunk)
            : base(doc)
        {
            if (chunk == null) {
                return;
            }

            if (chunk.Attributes != null && chunk.Attributes[Chunk.SUBSUPSCRIPT] != null) {
                this.superSubScript = (float)chunk.Attributes[Chunk.SUBSUPSCRIPT];
            }
            if (chunk.Attributes != null && chunk.Attributes[Chunk.BACKGROUND] != null) {
                this.background = new RtfColor(this.document, (Color) ((Object[]) chunk.Attributes[Chunk.BACKGROUND])[0]);
            }
            font = new ST.RtfFont(doc, chunk.Font);
            content = chunk.Content;
        }
Beispiel #23
0
 /// <summary>
 /// Constructs a Paragraph with a certain Chunk
 /// and a certain leading.
 /// </summary>
 /// <param name="leading">the leading</param>
 /// <param name="chunk">a Chunk</param>
 public Paragraph(float leading, Chunk chunk)
     : base(leading, chunk)
 {
 }
 /**
 * Adds an <CODE>Object</CODE> to the <CODE>List</CODE>.
 *
 * @param    o    the object to add.
 * @return true if adding the object succeeded
 */
 public override bool Add(Object o)
 {
     if (o is ListItem) {
         ListItem item = (ListItem) o;
         Chunk chunk = new Chunk(preSymbol, symbol.Font);
         switch (type ) {
             case 0:
                 chunk.Append(((char)(first + list.Count + 171)).ToString());
                 break;
             case 1:
                 chunk.Append(((char)(first + list.Count + 181)).ToString());
                 break;
             case 2:
                 chunk.Append(((char)(first + list.Count + 191)).ToString());
                 break;
             default:
                 chunk.Append(((char)(first + list.Count + 201)).ToString());
                 break;
         }
         chunk.Append(postSymbol);
         item.ListSymbol = chunk;
         item.SetIndentationLeft(symbolIndent, autoindent);
         item.IndentationRight = 0;
         list.Add(item);
         return true;
     } else if (o is List) {
         List nested = (List) o;
         nested.IndentationLeft = nested.IndentationLeft + symbolIndent;
         first--;
         list.Add(nested);
         return true;
     } else if (o is String) {
         return this.Add(new ListItem((string) o));
     }
     return false;
 }