Package com.lowagie.text

Examples of com.lowagie.text.LwgPhrase


                yLine = compositeColumn.yLine;
                linesWritten += compositeColumn.linesWritten;
                descender = compositeColumn.descender;
                if (!Float.isNaN(compositeColumn.firstLineY) && !compositeColumn.firstLineYDone) {
                    if (!simulate)
                        showTextAligned(canvas, LwgElement.ALIGN_LEFT, new LwgPhrase(item.getListSymbol()), compositeColumn.leftX + listIndentation, compositeColumn.firstLineY, 0);
                    compositeColumn.firstLineYDone = true;
                }
                if ((status & NO_MORE_TEXT) != 0) {
                    compositeColumn = null;
                    ++listIdx;
View Full Code Here


      // step 4: we add some content
      Paragraph p = new Paragraph(new Chunk("Click to print")
          .setAction(new PdfAction(PdfAction.PRINTDIALOG)));
      LwgPdfPTable table = new LwgPdfPTable(4);
      table.getDefaultCell().setHorizontalAlignment(LwgElement.ALIGN_CENTER);
      table.add(new LwgPhrase(new Chunk("First Page")
          .setAction(new PdfAction(PdfAction.FIRSTPAGE))));
      table.add(new LwgPhrase(new Chunk("Prev Page")
          .setAction(new PdfAction(PdfAction.PREVPAGE))));
      table.add(new LwgPhrase(new Chunk("Next Page")
          .setAction(new PdfAction(PdfAction.NEXTPAGE))));
      table.add(new LwgPhrase(new Chunk("Last Page")
          .setAction(new PdfAction(PdfAction.LASTPAGE))));
      for (int k = 1; k <= 10; ++k) {
        document.add(new Paragraph("This is page " + k));
        document.add(Chunk.NEWLINE);
        document.add(table);
View Full Code Here

            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));
            for (int i = 0; i < 27; i++) {
                ct.addText(new LwgPhrase(15, uni[i] + "\n", font));
            }
            ct.go();
            cb.rectangle(103, 295, 52, 8 + 28 * 15);
            cb.stroke();
            ct.setSimpleColumn(105, 300, 150, 300 + 28 * 15, 15, LwgElement.ALIGN_RIGHT);
            ct.addText(new LwgPhrase(15, "char\n", font));
            for (int i = 0; i < 27; i++) {
                ct.addText(new LwgPhrase(15, code[i] + "\n", font));
            }
            ct.go();
            ct.setSimpleColumn(160, 300, 500, 300 + 28 * 15, 15, LwgElement.ALIGN_LEFT);
            ct.addText(new LwgPhrase(15, "NAME" + "\n", font));
            for (int i = 0; i < 27; i++) {
                ct.addText(new LwgPhrase(15, name[i] + "\n", font));
            }
            ct.go();
           
        }
        catch(DocumentException de) {
View Full Code Here

      for (int i = 0; i < 5; i++) {
        chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_STROKE, 0.3f, new Color(i * 30, i * 30, i * 30));
        document.add(chunk);
      }
      document.newPage();
      LwgPhrase p = new LwgPhrase(16f);
      for (int i = 0; i < 5; i++) {
        chunk = new Chunk("quick brown fox jumps over the lazy dog ");
        chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_STROKE, 0.3f, new Color(i * 30, i * 30, i * 30));
        p.add(chunk);
      }
      document.add(p);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
View Full Code Here

            writer.setViewerPreferences(PdfWriter.PageModeUseOC);
            // step 3
            document.open();
            // step 4
            PdfContentByte cb = writer.getDirectContent();
            LwgPhrase explanation = new LwgPhrase("Automatic layer grouping and nesting", new LwgFont(LwgFont.HELVETICA, 20, LwgFont.BOLD, Color.red));
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, explanation, 50, 650, 0);
            PdfLayer l12 = new PdfLayer("Layer nesting", writer);
            PdfLayer l1 = new PdfLayer("Layer 1", writer);
            PdfLayer l2 = new PdfLayer("Layer 2", writer);
            PdfLayer title = PdfLayer.createTitle("Layer grouping", writer);
            PdfLayer l3 = new PdfLayer("Layer 3", writer);
            PdfLayer l4 = new PdfLayer("Layer 4", writer);
            l12.addChild(l1);
            l12.addChild(l2);
            title.addChild(l3);
            title.addChild(l4);
            LwgPhrase p1 = new LwgPhrase("Text in layer 1");
            LwgPhrase p2 = new LwgPhrase("Text in layer 2");
            LwgPhrase p3 = new LwgPhrase("Text in layer 3");
            LwgPhrase p4 = new LwgPhrase("Text in layer 4");
            cb.beginLayer(l1);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p1, 50, 600, 0);
            cb.endLayer();
            cb.beginLayer(l2);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p2, 50, 550, 0);
View Full Code Here

      writer.setViewerPreferences(PdfWriter.PageModeUseOC);
      // step 3
      document.open();
      // step 4
      PdfContentByte cb = writer.getDirectContent();
      LwgPhrase explanation = new LwgPhrase("Ordered layers", new LwgFont(
          LwgFont.HELVETICA, 20, LwgFont.BOLD, Color.red));
      ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, explanation, 50,
          650, 0);
      PdfLayer l1 = new PdfLayer("Layer 1", writer);
      PdfLayer l2 = new PdfLayer("Layer 2", writer);
      PdfLayer l3 = new PdfLayer("Layer 3", writer);
      PdfLayerMembership m1 = new PdfLayerMembership(writer);
      m1.addMember(l2);
      m1.addMember(l3);
      LwgPhrase p1 = new LwgPhrase("Text in layer 1");
      LwgPhrase p2 = new LwgPhrase("Text in layer 2 or layer 3");
      LwgPhrase p3 = new LwgPhrase("Text in layer 3");
      cb.beginLayer(l1);
      ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p1, 50, 600, 0);
      cb.endLayer();
      cb.beginLayer(m1);
      ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p2, 50, 550, 0);
View Full Code Here

   * Creates a Phrase object based on a list of properties.
   * @param attributes
   * @return a Phrase
   */
  public static LwgPhrase getPhrase(Properties attributes) {
    LwgPhrase phrase = new LwgPhrase();
    phrase.setFont(FontFactory.getFont(attributes));
    String value;
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
      phrase.setLeading(Float.parseFloat(value + "f"));
    }
    value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT);
    if (value != null) {
      phrase.setLeading(Markup.parseLength(value,
          Markup.DEFAULT_FONT_SIZE));
    }
    value = attributes.getProperty(ElementTags.ITEXT);
    if (value != null) {
      Chunk chunk = new Chunk(value);
      if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) {
        chunk.setGenericTag(value);
      }
      phrase.add(chunk);
    }
    return phrase;
  }
View Full Code Here

            fonts[12] = FontFactory.getFont(FontFactory.SYMBOL, 12, LwgFont.NORMAL);
            fonts[13] = FontFactory.getFont(FontFactory.ZAPFDINGBATS, 12, LwgFont.NORMAL);
            for (int i = 0; i < 14; i++) {
                Chunk chunk = new Chunk("This is font ", fonts[i]);
                Paragraph p = new Paragraph(chunk);
                p.add(new LwgPhrase(new Chunk(f[i], fonts[i]).setGenericTag(f[i])));
                document.add(p);
                if (i % 4 == 3) {
                    document.newPage();
                }
            }
View Full Code Here

                LwgRectangle sr2 = new LwgRectangle(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 LwgPhrase(signedBy, font), signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), signedSize, LwgElement.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, LwgElement.ALIGN_RIGHT);

                LwgImage im = LwgImage.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) {
                LwgRectangle sr = new LwgRectangle(dataRect.getWidth(), dataRect.getHeight());
                size = fitText(font, text, sr, 12, runDirection);
            }
            ColumnText ct = new ColumnText(t);
            ct.setRunDirection(runDirection);
            ct.setSimpleColumn(new LwgPhrase(text, font), dataRect.getLeft(), dataRect.getBottom(), dataRect.getRight(), dataRect.getTop(), size, LwgElement.ALIGN_LEFT);
            ct.go();
        }
        if (app[3] == null && !acro6Layers) {
            PdfTemplate t = app[3] = new PdfTemplate(writer);
            t.setBoundingBox(new LwgRectangle(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 LwgRectangle(0, rect.getHeight() * (1 - TOP_SECTION), rect.getRight(), rect.getTop()));
            writer.addDirectTemplateSimple(t, new PdfName("n4"));
            LwgFont font;
            if (layer2Font == null)
                font = new LwgFont();
            else
                font = new LwgFont(layer2Font);
            float size = font.getSize();
            String text = "Signature Not Verified";
            if (layer4Text != null)
                text = layer4Text;
            LwgRectangle sr = new LwgRectangle(rect.getWidth() - 2 * MARGIN, rect.getHeight() * TOP_SECTION - 2 * MARGIN);
            size = fitText(font, text, sr, 15, runDirection);
            ColumnText ct = new ColumnText(t);
            ct.setRunDirection(runDirection);
            ct.setSimpleColumn(new LwgPhrase(text, font), MARGIN, 0, rect.getWidth() - MARGIN, rect.getHeight() - MARGIN, size, LwgElement.ALIGN_LEFT);
            ct.go();
        }
        int rotation = writer.reader.getPageRotation(page);
        LwgRectangle rotated = new LwgRectangle(rect);
        int n = rotation;
View Full Code Here

                }
                int minLines = Math.max(cr, lf) + 1;
                maxFontSize = Math.abs(rect.getHeight()) / minLines - 0.001f;
            }
            font.setSize(maxFontSize);
            LwgPhrase ph = new LwgPhrase(text, font);
            ct = new ColumnText(null);
            ct.setSimpleColumn(ph, rect.getLeft(), rect.getBottom(), rect.getRight(), rect.getTop(), maxFontSize, LwgElement.ALIGN_LEFT);
            ct.setRunDirection(runDirection);
            status = ct.go(true);
            if ((status & ColumnText.NO_MORE_TEXT) != 0)
                return maxFontSize;
            float precision = 0.1f;
            float min = 0;
            float max = maxFontSize;
            float size = maxFontSize;
            for (int k = 0; k < 50; ++k) { //just in case it doesn't converge
                size = (min + max) / 2;
                ct = new ColumnText(null);
                font.setSize(size);
                ct.setSimpleColumn(new LwgPhrase(text, font), rect.getLeft(), rect.getBottom(), rect.getRight(), rect.getTop(), size, LwgElement.ALIGN_LEFT);
                ct.setRunDirection(runDirection);
                status = ct.go(true);
                if ((status & ColumnText.NO_MORE_TEXT) != 0) {
                    if (max - min < size * precision)
                        return size;
View Full Code Here

TOP

Related Classes of com.lowagie.text.LwgPhrase

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.