Examples of BaseFont


Examples of com.lowagie.text.pdf.BaseFont

      }
    }

    try
    {
      final BaseFont baseFont = BaseFont.createFont
          (fontType, encoding, embedded, false, ttfAfm, pfb);
      return new CompoundResource(key, dc, baseFont, getFactoryType());
    }
    catch (Exception e)
    {
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

        style |= Font.UNDERLINE;
      }

      final BaseFontFontMetrics fontMetrics = metaData.getBaseFontFontMetrics
          (fontName, fontSize, bold, italic, "utf-8", false, false);
      final BaseFont baseFont = fontMetrics.getBaseFont();
      final Font font = new Font(baseFont, (float) fontSize, style, textColor);
      final Chunk c = new Chunk(text, font);
      if (backgroundColor != null)
      {
        c.setBackground(backgroundColor);
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

            + "\nisPdfEmbedded : " + pdfFont.isPdfEmbedded(),
            initialException
            );
      }

      BaseFont baseFont = null;

      try
      {
        baseFont =
          BaseFont.createFont(
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

   */
  public Rectangle getTextSize(String text, Font font) {
    template.saveState();
    // get the font
    DefaultFontMapper mapper = new DefaultFontMapper();
    BaseFont bf = mapper.awtToPdf(font);
    template.setFontAndSize(bf, font.getSize());
    // calculate text width and height
    float textWidth = template.getEffectiveStringWidth(text, false);
    float ascent = bf.getAscentPoint(text, font.getSize());
    float descent = bf.getDescentPoint(text, font.getSize());
    float textHeight = ascent - descent;
    template.restoreState();
    return new Rectangle(0, 0, textWidth, textHeight);
  }
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

   */
  public void drawText(String text, Font font, Rectangle box, Color fontColor) {
    template.saveState();
    // get the font
    DefaultFontMapper mapper = new DefaultFontMapper();
    BaseFont bf = mapper.awtToPdf(font);
    template.setFontAndSize(bf, font.getSize());

    // calculate descent
    float descent = 0;
    if (text != null) {
      descent = bf.getDescentPoint(text, font.getSize());
    }

    // calculate the fitting size
    Rectangle fit = getTextSize(text, font);

View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

 
 
   public static void addTextAtXY( String text, PdfContentByte cb, float x, float y )
        throws IOException, DocumentException
        {
          BaseFont labelFont = BaseFont.createFont( BaseFont.TIMES_ROMAN, "Cp1252", true );
          cb.beginText();
          cb.setColorFill( Color.black);
          cb.setFontAndSize( labelFont, 10 );
          cb.setTextMatrix( x, y );
          cb.showText( text );
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

      logger.error(Tools.getStackTrace(e));
    }
  }

  public void abrirDocumento() {
    BaseFont bf = null;
    try {
      bf = BaseFont.createFont(BaseFont.COURIER, "Cp1252", false);
    } catch (Exception e) {
      logger.error(Tools.getStackTrace(e));
    }
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

            return fontRecord;
          }

          // filename is null, so no ttf file registered for the fontname, maybe this is
          // one of the internal fonts ...
          final BaseFont f = BaseFont.createFont(fontName, stringEncoding, embedded,
              useGlobalCache, null, null);
          if (f != null)
          {
            fontRecord = new BaseFontRecord(fontName, false, embedded, f, bold, italic);
            putToCache(fontRecord);
            return fontRecord;
          }
        }
      }

      // If we got to this point, then the font was not recognized as any known font. We will fall back
      // to Helvetica instead ..
    }
    catch (Exception e)
    {
      if (logger.isDebugEnabled())
      {
        logger.debug("BaseFont.createFont failed. Key = " + fontKey + ": " + e.getMessage(), e);
      }
      else if (logger.isWarnEnabled())
      {
        logger.warn("BaseFont.createFont failed. Key = " + fontKey + ": " + e.getMessage(), e);
      }
    }
    // fallback .. use BaseFont.HELVETICA as default
    try
    {
      // check, whether HELVETICA is already created - yes, then return cached instance instead
      BaseFontRecord fontRecord = getFromCache(BaseFont.HELVETICA, stringEncoding, embedded);
      if (fontRecord != null)
      {
        // map all font references of the invalid font to the default font..
        // this might be not very nice, but at least the report can go on..
        putToCache(new BaseFontRecordKey(fontKey, encoding, embedded), fontRecord);
        return fontRecord;
      }

      // no helvetica created, so do this now ...
      final BaseFont f = BaseFont.createFont(BaseFont.HELVETICA, stringEncoding, embedded,
          useGlobalCache, null, null);
      if (f != null)
      {
        fontRecord = new BaseFontRecord
            (BaseFont.HELVETICA, false, embedded, f, bold, italic);
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

    if (fontRec != null)
    {
      return fontRec;
    }

    BaseFont f;
    try
    {
      try
      {
        f = BaseFont.createFont(filename, encoding, embedded, false, null, null);
View Full Code Here

Examples of com.lowagie.text.pdf.BaseFont

    else
    {
      throw new IllegalArgumentException("Unknown font-identifier type encountered.");
    }

    final BaseFont baseFont = baseFontSupport.createBaseFont
        (fontName, bold, italic, context.getEncoding(), context.isEmbedded());

    return new BaseFontFontMetrics
        (new DefaultFontNativeContext(bold, italic), baseFont, (float) context.getFontSize());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.