Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.BaseFont


            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("templateImages.pdf"));
            // step 3: we open the document
            document.open();
            // step 4:
            PdfTemplate template = writer.getDirectContent().createTemplate(20, 20);
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
            String text = "Vertical";
            float size = 16;
            float width = bf.getWidthPoint(text, size);
            template.beginText();
            template.setRGBColorFillF(1, 1, 1);
            template.setFontAndSize(bf, size);
            template.setTextMatrix(0, 2);
            template.showText(text);
View Full Code Here


            // step 4:
           
            // we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            LwgFont font = new LwgFont(bf, 11, LwgFont.NORMAL);
           
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(60, 300, 100, 300 + 28 * 15, 15, LwgElement.ALIGN_CENTER);
            ct.addText(new LwgPhrase(15, "UNI\n", font));
View Full Code Here

            template.circle(250f, 100f, 80f);
            template.stroke();
           
            // we add some text
            template.beginText();
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            template.setFontAndSize(bf, 12);
            template.setTextMatrix(100, 100);
            template.showText("Text at the position 100,100 (relative to the template!)");
            template.endText();
            template.sanityCheck();
View Full Code Here

            cb.lineTo(360, 504);
            cb.lineTo(72, 144);
            cb.lineTo(144, 288);
            cb.stroke();
           
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.beginText();
            cb.setFontAndSize(bf, 12);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(3\", 10\")", 216 + 25, 720 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 5\")", 360 + 25, 360 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 7\")", 360 + 25, 504 + 5, 0);
View Full Code Here

            cb.stroke();
           
            // we tell the ContentByte we're ready to draw text
            cb.beginText();
           
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.setFontAndSize(bf, 12);
            String text = "Sample text for alignment";
            // we show some text starting on some absolute position with a given alignment
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, text + " Center", 250, 700, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, text + " Right", 250, 650, 0);
View Full Code Here

            cb.lineTo(360, 504);
            cb.lineTo(72, 144);
            cb.lineTo(144, 288);
            cb.stroke();
           
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.beginText();
            cb.setFontAndSize(bf, 12);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(3\", 10\")", 216 + 25, 720 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 5\")", 360 + 25, 360 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\", 7\")", 360 + 25, 504 + 5, 0);
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate template = cb.createTemplate(500, 200);
            template.setLineWidth(2f);
            template.rectangle(2.5f, 2.5f, 495f, 195f);
            template.stroke();
View Full Code Here

    return getSpecialLine(template, inchunks, offsetX, offsetY, SMALL_FONT_SIZE, SUPSCRIPT_FONT_SIZE);
  }

  public static Paragraph getSpecialLine(PdfTemplate template, Chunk[] inchunks, float offsetX, float offsetY, float fontsize, float supscriptFontsize) throws Exception {

    BaseFont font = BaseFont.createFont("Helvetica", "winansi", false);


    float leading = 7;
    int linesNo = getRealChunksSize(inchunks);

    float yPosition = (linesNo - 1) * DEFAULT_FONT_HEIGHT;

    float width = 0;
    float height = linesNo * DEFAULT_FONT_HEIGHT;

    template.setFontAndSize(font, fontsize);
    template.beginText();
    template.moveText(0, yPosition);

    float tempWidth = 0;
    for (int i = 0; i < inchunks.length; i++) {
      Chunk inchunk = inchunks[i];

      if (!inchunk.equals(Chunk.NEWLINE) && !inchunk.content().equals("")) {

        String content = inchunk.content();

        String supAttribute = inchunk.getMarkupAttribute(Chunk.SUBSUPSCRIPT);
        if (supAttribute != null) {

          template.setFontAndSize(font, supscriptFontsize);
          template.moveText(tempWidth, 2f);
          template.showText(supAttribute);

          // Rep�e valores
          float attrWidth = font.getWidthPoint(supAttribute, supscriptFontsize);
          tempWidth += attrWidth;
          if (tempWidth > width) width = tempWidth;

          template.moveText(attrWidth, -2f);
          template.setFontAndSize(font, fontsize);
        } else {
          //System.out.println("CONTENT = *" + content + "*");
          template.showText(content);

          tempWidth += font.getWidthPoint(content, fontsize);
          if (tempWidth > width) width = tempWidth;
        }

      }

View Full Code Here

            /** The headertable. */
            PdfPTable table = new PdfPTable(2);
            /** A template that will hold the total number of pages. */
            PdfTemplate tpl = writer.getDirectContent().createTemplate(100, 100);
            /** The font that will be used. */
            BaseFont helv = null;
            try
            {
                helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
            }
            catch (DocumentException e)
            {
            }
            catch (IOException e)
            {
            }
            PdfContentByte cb = writer.getDirectContent();
            cb.saveState();
            // write the headertable
            table.setTotalWidth(document.right() - document.left());
            table.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 50, cb);
            // compose the footer
            String text = "Page " + writer.getPageNumber();
            float textSize = helv.getWidthPoint(text, 12);
            float textBase = document.bottom() - 20;
            cb.beginText();
            cb.setFontAndSize(helv, 12);
            float adjust = helv.getWidthPoint("0", 12);
            cb.setTextMatrix(document.right() - textSize - adjust, textBase);
            cb.showText(text);
            cb.endText();
            cb.addTemplate(tpl, document.right() - adjust, textBase);
            cb.saveState();
View Full Code Here

        throw new InstantiationException(
            "You need to add a text for the watermark");
      }
      int fontsize = Integer.parseInt( (String) getValue("fontsize"));
      float opacity = Float.parseFloat( (String) getValue("opacity"));
      BaseFont bf = BaseFont.createFont("Helvetica", BaseFont.WINANSI,
                                        false);
      PdfReader reader = new PdfReader( ( (File) getValue("srcfile"))
                                       .getAbsolutePath());
      int pagecount = reader.getNumberOfPages();
      PdfGState gs1 = new PdfGState();
      gs1.setFillOpacity(opacity);
      String text = (String) getValue("watermark");
      PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(
          (File) getValue("destfile")));
      float txtwidth = bf.getWidthPoint(text, fontsize);
      for (int i = 1; i <= pagecount; i++) {
        PdfContentByte seitex = stamp.getOverContent(i);
        Rectangle recc = reader.getCropBox(i);
        float winkel = (float) Math.atan(recc.height() / recc.width());
        float m1 = (float) Math.cos(winkel);
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.BaseFont

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.