Package com.lowagie.text

Examples of com.lowagie.text.Chunk


           
            // we make some content
           
            // a paragraph with a local goto
            Paragraph p1 = new Paragraph("We will do something special with this paragraph. If you click on ", FontFactory.getFont(FontFactory.HELVETICA, 12));
            p1.add(new Chunk("this word", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.NORMAL, new Color(0, 0, 255))).setLocalGoto("test"));
            p1.add(" you will automatically jump to another location in this document.");
           
            // some paragraph
            Paragraph p2 = new Paragraph("blah, blah, blah");
           
            // a paragraph with a local destination
            Paragraph p3 = new Paragraph("This paragraph contains a ");
            p3.add(new Chunk("local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, LwgFont.NORMAL, new Color(0, 255, 0))).setLocalDestination("test"));
           
            // we add the content
            document.add(p1);
            document.add(p2);
            document.add(p2);
View Full Code Here


      // step 4:
      LwgFont red = FontFactory.getFont(FontFactory.HELVETICA, LwgFont.DEFAULTSIZE, LwgFont.BOLD, new Color(0xFF, 0x00, 0x00));
      LwgFont blue = FontFactory.getFont(FontFactory.HELVETICA, LwgFont.DEFAULTSIZE, LwgFont.ITALIC, new Color(0x00, 0x00, 0xFF));
      Paragraph p;
      p = new Paragraph("Roses are ");
      p.add(new Chunk("red", red));
      document.add(p);
      p = new Paragraph("Violets are ");
      p.add(new Chunk("blue", blue));
      document.add(p);
      BaseFont bf = FontFactory.getFont(FontFactory.COURIER).getCalculatedBaseFont(false);
      PdfContentByte cb = writer.getDirectContent();
      cb.beginText();
      cb.setColorFill(new Color(0x00, 0xFF, 0x00));
View Full Code Here

      // step 3: we open the document
      document.open();
      // step 4:     
      Paragraph p = new Paragraph("Skew test:");
      document.add(p);
      Chunk chunk = new Chunk("TESTING skew");
      chunk.setSkew(45f, 0f);
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setSkew(0f, 45f);
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setSkew(-45f, 0f);
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setSkew(0f, -45f);
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      chunk.setSkew(15f, 30f);
      document.add(chunk);
      document.add(Chunk.NEWLINE);
      Chunk italic = new Chunk("This looks like Font.ITALIC");
      italic.setSkew(0f, 12f);
      document.add(italic);
     
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
View Full Code Here

      PdfWriter.getInstance(document,
          new FileOutputStream("NamedActions.pdf"));
      // step 3: we open the document
      document.open();
      // 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

          new FileOutputStream("Background.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
      Chunk high = new Chunk("highlighted");
      high.setBackground(new Color(0xFF, 0xFF, 0x00));
      Paragraph p = new Paragraph("The following chunk is ");
      p.add(high);
      document.add(p);
      Chunk c;
      c = new Chunk("background");
      c.setBackground(new Color(0xC0, 0xC0, 0xC0));
      document.add(c);
      c = new Chunk("background");
      c.setTextRise(8);
      c.setBackground(new Color(0xFF, 0xDE, 0xAD));
      document.add(c);
      c = new Chunk("background", FontFactory.getFont(FontFactory.HELVETICA, 8));
      c.setBackground(new Color(0x70, 0x70, 0x70));
      document.add(c);
      c = new Chunk("background");
      c.setBackground(new Color(0x00, 0x80, 0x80));
      document.add(c);
      document.add(Chunk.NEWLINE);
      p = new Paragraph("An more complex ");
      c = new Chunk("background chunk");
      c.setBackground(new Color(0xFF, 0x00, 0x00), 5f, 30f, -10f, 0f);
      p.add(c);
      p.add(" example");
      document.add(p);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
View Full Code Here

            template.setWidth(width);
            template.setHeight(size + 2);
            template.sanityCheck();
            LwgImage img = LwgImage.getInstance(template);
            img.setRotationDegrees(90);
            Chunk ck = new Chunk(img, 0, 0);
            LwgPdfPTable table = new LwgPdfPTable(3);
            table.setWidthPercentage(100);
            table.getDefaultCell().setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_MIDDLE);
            LwgPdfPCell cell = new LwgPdfPCell(img);
View Full Code Here

      try {
        PdfWriter writer = PdfWriter.getInstance(document, baos);
        document.open();
        if (requ.getParameter("preview") == null)
          writer.addJavaScript("this.print(false);", false);
        document.add(new Chunk("Silent Auto Print"));
        document.close();
      } catch (DocumentException e) {
        e.printStackTrace();
      }
      resp.setContentType("application/pdf");
View Full Code Here

          new FileOutputStream("EndOfLine.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
      Chunk chunk = new Chunk("quick brown fox jumps over the lazy dog ");
      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());
View Full Code Here

          new FileOutputStream("SplitChar.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
      Chunk chunk;
      Paragraph p;
            String text = "Some.text.to.show.the.splitting.action.of.the.interface.";
            LwgFont font = FontFactory.getFont(FontFactory.HELVETICA, 24);
           
            document.add(new Paragraph("Normal split."));
            chunk = new Chunk(text, font);
            p = new Paragraph(24, chunk);
            document.add(p);
           
            document.add(new Paragraph("The dot '.' is the split character."));
            chunk = new Chunk(text, font);
            chunk.setSplitCharacter(new SplitChar());
            p = new Paragraph(24, chunk);
            document.add(p);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
View Full Code Here

          + "we were all going direct to Heaven, we were all going direct "
          + "the other way\u2014in short, the period was so far like the present "
          + "period, that some of its noisiest authorities insisted on its "
          + "being received, for good or for evil, in the superlative degree "
          + "of comparison only.";
      Chunk ck = new Chunk(text);
      HyphenationAuto auto = new HyphenationAuto("en", "GB", 2, 2);
      ck.setHyphenation(auto);
      Paragraph p = new Paragraph(ck);
      p.setAlignment(Paragraph.ALIGN_JUSTIFIED);
      document.add(p);
      document.newPage();
      ck = new Chunk(text);
      auto = new HyphenationAuto("en", "US", 2, 2);
      ck.setHyphenation(auto);
      p = new Paragraph(ck);
      p.setAlignment(Paragraph.ALIGN_JUSTIFIED);
      document.add(p);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
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.