Package com.lowagie.text

Examples of com.lowagie.text.Chunk


    if(this.buffer.length() == 0) return;
   
    if(propertyName.startsWith(RtfProperty.CHARACTER)) {
      // this is a character change,
      // add a new chunk to the current paragraph using current character settings.
      Chunk chunk = new Chunk();
      chunk.append(this.buffer.toString());
      this.buffer = new StringBuffer(255);
      HashMap charProperties = this.rtfParser.getState().properties.getProperties(RtfProperty.CHARACTER);
      String defFont = (String)charProperties.get(RtfProperty.CHARACTER_FONT);
      if(defFont == null) defFont = "0";
      RtfDestinationFontTable fontTable = (RtfDestinationFontTable)this.rtfParser.getDestination("fonttbl");
      LwgFont currFont = fontTable.getFont(defFont);
      int fs = LwgFont.NORMAL;
      if(charProperties.containsKey(RtfProperty.CHARACTER_BOLD)) fs |= LwgFont.BOLD;
      if(charProperties.containsKey(RtfProperty.CHARACTER_ITALIC)) fs |= LwgFont.ITALIC;
      if(charProperties.containsKey(RtfProperty.CHARACTER_UNDERLINE)) fs |= LwgFont.UNDERLINE;
      LwgFont useFont = FontFactory.getFont(currFont.getFamilyname(), 12, fs, new Color(0,0,0));
     
     
      chunk.setFont(useFont);
      if(iTextParagraph == null) this.iTextParagraph = new Paragraph();
      this.iTextParagraph.add(chunk);

    } else {
      if(propertyName.startsWith(RtfProperty.PARAGRAPH)) {
View Full Code Here


      // step 3: we open the document
      document.open();
      // step 4:     
      Paragraph p = new Paragraph("Text Rendering:");
      document.add(p);
      Chunk chunk = new Chunk("rendering test");
      chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL, 100f, new Color(0xFF, 0x00, 0x00));
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0.3f, new Color(0xFF, 0x00, 0x00));
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE, 100f, new Color(0x00, 0xFF, 0x00));
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_STROKE, 0.3f, new Color(0x00, 0x00, 0xFF));
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      Chunk bold = new Chunk("This looks like Font.BOLD");
      bold.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0.5f, new Color(0x00, 0x00, 0x00));
      document.add(bold);
     
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
View Full Code Here

     */
    public void onChapter(PdfWriter writer, LwgDocument document,
        float paragraphPosition, Paragraph title) {
      StringBuffer buf = new StringBuffer();
      for (Iterator i = title.getChunks().iterator(); i.hasNext();) {
        Chunk chunk = (Chunk) i.next();
        buf.append(chunk.getContent());
      }
      act = buf.toString();
    }
View Full Code Here

      // step 3: we open the document
      document.open();
      // step 4:
      Paragraph p = new Paragraph("Generic page event");
      document.add(p);
      Chunk box = new Chunk("box");
      box.setGenericTag("box");
      Chunk ellipse = new Chunk("ellipse");
      ellipse.setGenericTag("ellipse");
      p = new Paragraph("In this example, we will add chunks that are tagged as an ");
      p.add(ellipse);
      p.add(" and chunks that are tagged as a ");
      p.add(box);
      p.add(". Can you see the difference between ");
      Chunk c1 = new Chunk("this");
      c1.setGenericTag("box");
      Chunk c2 = new Chunk("that");
      c2.setGenericTag("ellipse");
      p.add(c1);
      p.add(" and ");
      p.add(c2);
      p.add("? One is a ");
      p.add(box);
View Full Code Here

        try {
          // initialization of the header table
            headerImage = LwgImage.getInstance("logo.gif");
            table = new LwgPdfPTable(2);
            LwgPhrase p = new LwgPhrase();
            Chunk ck = new Chunk("lowagie.com\n", new LwgFont(LwgFont.TIMES_ROMAN, 16, LwgFont.BOLDITALIC, Color.blue));
            p.add(ck);
            ck = new Chunk("Ghent\nBelgium", new LwgFont(LwgFont.HELVETICA, 12, LwgFont.NORMAL, Color.darkGray));
            p.add(ck);
            table.getDefaultCell().setBackgroundColor(Color.yellow);
            table.getDefaultCell().setBorderWidth(0);
            table.add(p);
            table.getDefaultCell().setHorizontalAlignment(LwgElement.ALIGN_RIGHT);
            table.add(new LwgPhrase(new Chunk(headerImage, 0, 0)));
            // initialization of the Graphic State
            gstate = new PdfGState();
            gstate.setFillOpacity(0.3f);
            gstate.setStrokeOpacity(0.3f);
            // initialization of the template
View Full Code Here

            PdfWriter.getInstance(document, new FileOutputStream("differentfonts.pdf"));
            // step 3
            document.open();
            // step 4
            Paragraph p = new Paragraph();
            p.add(new Chunk("This text is in Times Roman. This is ZapfDingbats: ", new LwgFont(LwgFont.TIMES_ROMAN, 12)));
            p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new LwgFont(LwgFont.ZAPFDINGBATS, 12)));
            p.add(new Chunk(". This is font Symbol: ", new LwgFont(LwgFont.TIMES_ROMAN, 12)));
            p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new LwgFont(LwgFont.SYMBOL, 12)));
            document.add(new Paragraph(p));
            // step 5
            document.close();
        }
        catch(Exception de) {
View Full Code Here

            Paragraph paragraph = new Paragraph("Please visit my ");
            Anchor anchor1 = new Anchor("website (external reference)", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.UNDERLINE, new Color(0, 0, 255)));
            anchor1.setReference("http://www.lowagie.com/iText/");
            anchor1.setName("top");
            paragraph.add(anchor1);
            paragraph.add(new Chunk(".\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
            document.add(paragraph);
            Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.NORMAL, new Color(0, 0, 255)));
            anchor2.setReference("#top");
            document.add(anchor2);
    } catch (DocumentException de) {
View Full Code Here

            new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello");
           
            remote.add(new Paragraph("Some remote document"));
            remote.newPage();
            Paragraph p = new Paragraph("This paragraph contains a ");
            p.add(new Chunk("local destination").setLocalDestination("test"));
            remote.add(p);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

      // the default leading = 1.5 * size of the font
      LwgPhrase phrase3 = new LwgPhrase(
          "(3) this is a phrase with a red, normal font Courier, size 20. As you can see the leading is automatically changed.\n",
          FontFactory.getFont(FontFactory.COURIER, 20, LwgFont.NORMAL,
              new Color(255, 0, 0)));
      LwgPhrase phrase4 = new LwgPhrase(new Chunk("(4) this is a phrase\n"));
      LwgPhrase phrase5 = new LwgPhrase(
          18,
          new Chunk(
              "(5) this is a phrase in Helvetica, bold, red and size 16 with a given leading of 18 points.\n",
              FontFactory.getFont(FontFactory.HELVETICA, 16,
                  LwgFont.BOLD, new Color(255, 0, 0))));
      // A Phrase can contains several chunks with different fonts
      LwgPhrase phrase6 = new LwgPhrase("(6)");
      Chunk chunk = new Chunk(" This is a font: ");
      phrase6.add(chunk);
      phrase6.add(new Chunk("Helvetica", FontFactory.getFont(
          FontFactory.HELVETICA, 12)));
      phrase6.add(chunk);
      phrase6.add(new Chunk("Times New Roman", FontFactory.getFont(
          FontFactory.TIMES_ROMAN, 12)));
      phrase6.add(chunk);
      phrase6.add(new Chunk("Courier", FontFactory.getFont(
          FontFactory.COURIER, 12)));
      phrase6.add(chunk);
      phrase6.add(new Chunk("Symbol", FontFactory.getFont(
          FontFactory.SYMBOL, 12)));
      phrase6.add(chunk);
      phrase6.add(new Chunk("ZapfDingBats", FontFactory.getFont(
          FontFactory.ZAPFDINGBATS, 12)));
      LwgPhrase phrase7 = new LwgPhrase(
          "(7) if you don't add a newline yourself, all phrases are glued to eachother!");

      document.add(phrase1);
View Full Code Here

           
            // we create some content
           
            // a paragraph with a link to an external url
            Paragraph p1 = new Paragraph("You can turn a Chunk into an ", FontFactory.getFont(FontFactory.HELVETICA, 12));
            p1.add(new Chunk("anchor", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.UNDERLINE, new Color(0, 0, 255))).setAnchor(new URL("http://www.lowagie.com/iText/")));
            p1.add(", for instance to the iText site.");
           
            // some paragraph
            Paragraph p2 = new Paragraph("blah, blah, blah");
           
            // two paragraphs with a local destination
            Paragraph p3a = new Paragraph("This paragraph contains a ");
            p3a.add(new Chunk("local destination in document A", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.NORMAL, new Color(0, 255, 0))).setLocalDestination("test"));
            Paragraph p3b = new Paragraph("This paragraph contains a ");
            p3b.add(new Chunk("local destination in document B", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.NORMAL, new Color(0, 255, 0))).setLocalDestination("test"));
           
            // two paragraphs with a remote goto
            Paragraph p4a = new Paragraph(new Chunk("Click this paragraph to go to a certain destination on document B").setRemoteGoto("DocumentB.pdf", "test"));
            Paragraph p4b = new Paragraph(new Chunk("Click this paragraph to go to a certain destination on document A").setRemoteGoto("DocumentA.pdf", "test"));
           
            // a special remote goto
            Paragraph p5a = new Paragraph("you can also jump to a ");
            p5a.add(new Chunk("specific page on another document", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.ITALIC)).setRemoteGoto("DocumentB.pdf", 3));
           
            // we add all the content
            document.add(p1);
            document.add(p2);
            document.add(p2);
View Full Code Here

TOP

Related Classes of com.lowagie.text.Chunk

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.