Package com.lowagie.text

Examples of com.lowagie.text.Font


      }
    if(this.rtfParser.isConvert()) {
      // This could probably be written as a better font matching function
     
      String fName = this.fontName;  // work variable for trimming name if needed.
      Font f1 = createfont(fName);
      if(f1.getBaseFont() == null && this.falt.length()>0)
        f1 = createfont(this.falt);
     
      if(f1.getBaseFont() == null) {
        // Did not find a font, let's try a substring of the first name.
        if(FontFactory.COURIER.indexOf(fName) > -1 ) {
          f1 = FontFactory.getFont(FontFactory.COURIER);
        } else if(FontFactory.HELVETICA.indexOf(fName) > -1 ) {
          f1 = FontFactory.getFont(FontFactory.HELVETICA);
View Full Code Here


   * @return The created <code>Font</code> object
   *
   * @since 2.0.8
   */
  private Font createfont(String fontName) {
    Font f1 = null;
    int pos=-1;
    do {
      f1 = FontFactory.getFont(fontName);
     
      if(f1.getBaseFont() != null) break// found a font, exit the do/while
     
      pos = fontName.lastIndexOf(' ')// find the last space
      if(pos>0) {
        fontName = fontName.substring(0, pos )// truncate it to the last space
      }
View Full Code Here

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

  public Chunk createChunk(String text, ChainedProperties props) {
    Font 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

    throws IOException, DocumentException {
  // normal text font size
  final int normalTextFontSize = 12;

  // definig some fonts
  Font fntRomanTitle = new Font(Font.TIMES_ROMAN, 32);
  Font fntRomanDescription = new Font(Font.TIMES_ROMAN, normalTextFontSize);
  Font fntRomanArea = new Font(Font.TIMES_ROMAN, 20, Font.BOLD);
  Font fntRomanAreaDescription = new Font(Font.TIMES_ROMAN, normalTextFontSize);
  Font fntRomanOption = new Font(Font.TIMES_ROMAN, 16, Font.UNDERLINE);
  Font fntRomanOptionTitle = new Font(Font.TIMES_ROMAN, normalTextFontSize,Font.NORMAL);
  Font fntRomanOptionDescription = new Font(Font.TIMES_ROMAN, normalTextFontSize,Font.NORMAL);
  Font fntRomanTableAllFields = new Font(Font.TIMES_ROMAN, normalTextFontSize);

  Font fntRomanTODO = new Font(Font.TIMES_ROMAN, 24);
  Font fntRomanActor = new Font(Font.TIMES_ROMAN, 14);
  Font fntRomanRelated = new Font(Font.TIMES_ROMAN, 14);

  /*
  // trying to add a watermark ---> image overwrite table and cells borders: I have to remove it.
  Image image = Image.getInstance(getClass().getResource("/it/uniroma1/dptu/stan/print/diptu30.jpg"));
  //image.setAlignment(Image.ALIGN_CENTER);
View Full Code Here

                    float x = (rect.getWidth() - w) / 2;
                    float y = (rect.getHeight() - h) / 2;
                    t.addImage(image, w, 0, 0, h, x, y);
                }
            }
            Font font;
            if (layer2Font == null)
                font = new Font();
            else
                font = new Font(layer2Font);
            float size = font.getSize();

            Rectangle dataRect = null;
            Rectangle signatureRect = null;

            if (render == SignatureRenderNameAndDescription ||
                (render == SignatureRenderGraphicAndDescription && this.signatureGraphic != null)) {
                // origin is the bottom-left
                signatureRect = new Rectangle(
                    MARGIN,
                    MARGIN,
                    rect.getWidth() / 2 - MARGIN,
                    rect.getHeight() - MARGIN);
                dataRect = new Rectangle(
                    rect.getWidth() / 2 +  MARGIN / 2,
                    MARGIN,
                    rect.getWidth() - MARGIN / 2,
                    rect.getHeight() - MARGIN);

                if (rect.getHeight() > rect.getWidth()) {
                    signatureRect = new Rectangle(
                        MARGIN,
                        rect.getHeight() / 2,
                        rect.getWidth() - MARGIN,
                        rect.getHeight());
                    dataRect = new Rectangle(
                        MARGIN,
                        MARGIN,
                        rect.getWidth() - MARGIN,
                        rect.getHeight() / 2 - MARGIN);
                }
            }
            else {
                dataRect = new Rectangle(
                    MARGIN,
                    MARGIN,
                    rect.getWidth() - MARGIN,
                    rect.getHeight() * (1 - TOP_SECTION) - MARGIN);
            }

            if (render == SignatureRenderNameAndDescription) {
                String signedBy = PdfPKCS7.getSubjectFields((X509Certificate)certChain[0]).getField("CN");
                Rectangle sr2 = new Rectangle(signatureRect.getWidth() - MARGIN, signatureRect.getHeight() - MARGIN );
                float signedSize = fitText(font, signedBy, sr2, -1, runDirection);

                ColumnText ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(new Phrase(signedBy, font), signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), signedSize, Element.ALIGN_LEFT);

                ct2.go();
            }
            else if (render == SignatureRenderGraphicAndDescription) {
                ColumnText ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, Element.ALIGN_RIGHT);

                Image im = Image.getInstance(signatureGraphic);
                im.scaleToFit(signatureRect.getWidth(), signatureRect.getHeight());

                Paragraph p = new Paragraph();
                // must calculate the point to draw from to make image appear in middle of column
                float x = 0;
                // experimentation found this magic number to counteract Adobe's signature graphic, which
                // offsets the y co-ordinate by 15 units
                float y = -im.getScaledHeight() + 15;

                x = x + (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = y - (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x + (signatureRect.getWidth() - im.getScaledWidth()) / 2, y, false));
                ct2.addElement(p);
                ct2.go();
            }
           
            if (size <= 0) {
                Rectangle sr = new Rectangle(dataRect.getWidth(), dataRect.getHeight());
                size = fitText(font, text, sr, 12, runDirection);
            }
            ColumnText ct = new ColumnText(t);
            ct.setRunDirection(runDirection);
            ct.setSimpleColumn(new Phrase(text, font), dataRect.getLeft(), dataRect.getBottom(), dataRect.getRight(), dataRect.getTop(), size, Element.ALIGN_LEFT);
            ct.go();
        }
        if (app[3] == null && !acro6Layers) {
            PdfTemplate t = app[3] = new PdfTemplate(writer);
            t.setBoundingBox(new Rectangle(100, 100));
            writer.addDirectTemplateSimple(t, new PdfName("n3"));
            t.setLiteral("% DSBlank\n");
        }
        if (app[4] == null && !acro6Layers) {
            PdfTemplate t = app[4] = new PdfTemplate(writer);
            t.setBoundingBox(new Rectangle(0, rect.getHeight() * (1 - TOP_SECTION), rect.getRight(), rect.getTop()));
            writer.addDirectTemplateSimple(t, new PdfName("n4"));
            Font font;
            if (layer2Font == null)
                font = new Font();
            else
                font = new Font(layer2Font);
            float size = font.getSize();
            String text = "Signature Not Verified";
            if (layer4Text != null)
                text = layer4Text;
            Rectangle sr = new Rectangle(rect.getWidth() - 2 * MARGIN, rect.getHeight() * TOP_SECTION - 2 * MARGIN);
            size = fitText(font, text, sr, 15, runDirection);
View Full Code Here

     * before the user updates the table of contents
     *
     * @param defaultText The default text to display
     */
    public RtfTableOfContents(String defaultText) {
        super(null, new Font());
        this.defaultText = defaultText;
    }
View Full Code Here

     * Constructs a RtfTOCEntry with a certain entry text.
     *
     * @param entry The entry text to display
     */
    public RtfTOCEntry(String entry) {
        super(null, new Font());
        if(entry != null) {
            this.entry = entry;
        }
    }
View Full Code Here

                    if(rtfElement instanceof RtfList) {
                        ((RtfList) rtfElement).setParentList(this);
                    } else if(rtfElement instanceof RtfListItem) {
                        ((RtfListItem) rtfElement).setParent(ll);
                    }
                    ll.setFontNumber( new RtfFont(document, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, new Color(0, 0, 0))) );
                    if (list.getSymbol() != null && list.getSymbol().getFont() != null && !list.getSymbol().getContent().startsWith("-") && list.getSymbol().getContent().length() > 0) {
                        // only set this to bullet symbol is not default
                        ll.setBulletFont( list.getSymbol().getFont());
                        ll.setBulletCharacter(list.getSymbol().getContent().substring(0, 1));
                    } else
                   if (list.getSymbol() != null && list.getSymbol().getFont() != null) {
                       ll.setBulletFont(list.getSymbol().getFont());
                  
                   } else {
                      ll.setBulletFont(new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
                    }
                    items.add(rtfElement);
                }

            } catch(DocumentException de) {
View Full Code Here

     *
     * @param styleName The name of this RtfParagraphStyle.
     * @param basedOnName The name of the RtfParagraphStyle this RtfParagraphStyle is based on.
     */
    public RtfParagraphStyle(String styleName, String basedOnName) {
        super(null, new Font());
        this.styleName = styleName;
        this.basedOnName = basedOnName;
    }
View Full Code Here

   
  public RtfListLevel(RtfDocument doc)
  {
    super(doc);
    templateID = document.getRandomInt();
        setFontNumber( new RtfFont(document, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, new Color(0, 0, 0))));
        setBulletFont(new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
  }
View Full Code Here

TOP

Related Classes of com.lowagie.text.Font

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.