Package com.lowagie.text

Examples of com.lowagie.text.LwgFont


  /** Creates a new instance of FactoryProperties */
  public FactoryProperties() {
  }

  public Chunk createChunk(String text, ChainedProperties props) {
    LwgFont font = getFont(props);
    float size = font.getSize();
    size /= 2;
    Chunk ck = new Chunk(text, font);
    if (props.hasProperty("sub"))
      ck.setTextRise(-size);
    else if (props.hasProperty("sup"))
View Full Code Here


            }
            catch(Exception exception) {
                return new Chunk(e, font);
            }
        }
        LwgFont symbol = new LwgFont(LwgFont.SYMBOL, font.getSize(), font.getStyle(), font.getColor());
        return new Chunk(String.valueOf(s), symbol);
    }
View Full Code Here

* @return  true if the font differs
*/
   
    public boolean isOtherFont(LwgFont font) {
        try {
            LwgFont cFont = (LwgFont) currentfont.peek();
            if (cFont.compareTo(font) == 0) return false;
            return true;
        }
        catch(EmptyStackException ese) {
            if (standardfont.compareTo(font) == 0) return false;
            return true;
View Full Code Here

            TextElementArray current;
            try {
                current = (TextElementArray) stack.pop();
            } catch (EmptyStackException ese) {
              if (bf == null) {
                current = new Paragraph("", new LwgFont());
              }
              else {
                current = new Paragraph("", new LwgFont(this.bf));
              }
            }
            current.add(currentChunk);
            stack.push(current);
            currentChunk = null;
        }

        // chunks
        if (ElementTags.CHUNK.equals(name)) {
            currentChunk = ElementFactory.getChunk(attributes);
            if (bf != null) {
              currentChunk.setFont(new LwgFont(this.bf));
            }
            return;
        }

        // symbols
        if (ElementTags.ENTITY.equals(name)) {
            LwgFont f = new LwgFont();
            if (currentChunk != null) {
                handleEndingTags(ElementTags.CHUNK);
                f = currentChunk.getFont();
            }
            currentChunk = EntitiesToSymbol.get(attributes.getProperty(ElementTags.ID),
                    f);
            return;
        }

        // phrases
        if (ElementTags.PHRASE.equals(name)) {
            stack.push(ElementFactory.getPhrase(attributes));
            return;
        }

        // anchors
        if (ElementTags.ANCHOR.equals(name)) {
            stack.push(ElementFactory.getAnchor(attributes));
            return;
        }

        // paragraphs and titles
        if (ElementTags.PARAGRAPH.equals(name) || ElementTags.TITLE.equals(name)) {
            stack.push(ElementFactory.getParagraph(attributes));
            return;
        }

        // lists
        if (ElementTags.LIST.equals(name)) {
            stack.push(ElementFactory.getList(attributes));
            return;
        }
       
        // listitems
        if (ElementTags.LISTITEM.equals(name)) {
            stack.push(ElementFactory.getListItem(attributes));
            return;
        }

        // cells
        if (ElementTags.CELL.equals(name)) {
            stack.push(ElementFactory.getCell(attributes));
            return;
        }

        // tables
        if (ElementTags.TABLE.equals(name)) {
            Table table = ElementFactory.getTable(attributes);
            float widths[] = table.getProportionalWidths();
            for (int i = 0; i < widths.length; i++) {
                if (widths[i] == 0) {
                    widths[i] = 100.0f / widths.length;
                }
            }
            try {
                table.setWidths(widths);
            } catch (BadElementException bee) {
                // this shouldn't happen
                throw new ExceptionConverter(bee);
            }
            stack.push(table);
            return;
        }

        // sections
        if (ElementTags.SECTION.equals(name)) {
            LwgElement previous = (LwgElement) stack.pop();
            Section section;
            try {
                section = ElementFactory.getSection((Section) previous, attributes);
            } catch (ClassCastException cce) {
                throw new ExceptionConverter(cce);
            }
            stack.push(previous);
            stack.push(section);
            return;
        }

        // chapters
        if (ElementTags.CHAPTER.equals(name)) {
            stack.push(ElementFactory.getChapter(attributes));
            return;
        }

        // images
        if (ElementTags.IMAGE.equals(name)) {
            try {
                LwgImage img = ElementFactory.getImage(attributes);
                try {
                  addImage(img);
                    return;
                } catch (EmptyStackException ese) {
                    // if there is no element on the stack, the LwgImage is added
                    // to the document
                    try {
                        document.add(img);
                    } catch (DocumentException de) {
                        throw new ExceptionConverter(de);
                    }
                    return;
                }
            } catch (Exception e) {
                throw new ExceptionConverter(e);
            }
        }

        // annotations
        if (ElementTags.ANNOTATION.equals(name)) {
            Annotation annotation = ElementFactory.getAnnotation(attributes);
            TextElementArray current;
            try {
                try {
                    current = (TextElementArray) stack.pop();
                    try {
                        current.add(annotation);
                    } catch (Exception e) {
                        document.add(annotation);
                    }
                    stack.push(current);
                } catch (EmptyStackException ese) {
                    document.add(annotation);
                }
                return;
            } catch (DocumentException de) {
                throw new ExceptionConverter(de);
            }
        }

        // newlines
        if (isNewline(name)) {
            TextElementArray current;
            try {
                current = (TextElementArray) stack.pop();
                current.add(Chunk.NEWLINE);
                stack.push(current);
            } catch (EmptyStackException ese) {
                if (currentChunk == null) {
                    try {
                        document.add(Chunk.NEWLINE);
                    } catch (DocumentException de) {
                        throw new ExceptionConverter(de);
                    }
                } else {
                    currentChunk.append("\n");
                }
            }
            return;
        }

        // newpage
        if (isNewpage(name)) {
            TextElementArray current;
            try {
                current = (TextElementArray) stack.pop();
                Chunk newPage = new Chunk("");
                newPage.setNewPage();
                if (bf != null) {
                  newPage.setFont(new LwgFont(this.bf));
                }
                current.add(newPage);
                stack.push(current);
            } catch (EmptyStackException ese) {
                document.newPage();
View Full Code Here

        if (currentChunk == null) {
          if (bf == null) {
            currentChunk = new Chunk(buf.toString());
          }
          else {
            currentChunk = new Chunk(buf.toString(), new LwgFont(this.bf));
          }
        } else {
            currentChunk.append(buf.toString());
        }
    }
View Full Code Here

   */
  public void execute() {
    try {
            String line = null;
            LwgDocument document;
            LwgFont f;
            LwgRectangle pagesize = (LwgRectangle)getValue("pagesize");
            if ("LANDSCAPE".equals(getValue("orientation"))) {
                f = FontFactory.getFont(FontFactory.COURIER, 10);
                document = new LwgDocument(pagesize.rotate(), 36, 9, 36, 36);
            }
View Full Code Here

              '\u03B3'
           });

   static public LwgFont getfontGreek(int intSize) throws Exception
   {
      return new LwgFont(BaseFont.createFont("Symbol", "Symbol", true), intSize);
   }
View Full Code Here

  /**
   * Constructs a new RtfAddableElement. The Chunk content is
   * set to an empty string and the font to the default Font().
   */
  public RtfAddableElement() {
    super("", new LwgFont());
  }
View Full Code Here

            // step 3: we open the document
            document.open();
           
            // step 4: we add content to the document
            BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\comic.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            LwgFont font = new LwgFont(bfComic, 12);
            String text1 = "This is the quite popular True Type font 'Comic'.";
            String text2 = "Some greek characters: \u0393\u0394\u03b6";
            String text3 = "Some cyrillic characters: \u0418\u044f";
            document.add(new Paragraph(text1, font));
            document.add(new Paragraph(text2, font));
View Full Code Here

     * subclasses instead.
     *
     * @param doc The RtfDocument this RtfField belongs to.
     */
    protected RtfField(RtfDocument doc) {
        this(doc, new LwgFont());
    }
View Full Code Here

TOP

Related Classes of com.lowagie.text.LwgFont

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.