Package com.lowagie.text

Examples of com.lowagie.text.Paragraph


            doc.setHeader(header);
            doc.setFooter(footer);

            doc.open();

            Paragraph p = new Paragraph();
            p.add(new RtfTableOfContents("UPDATE ME!"));
            doc.add(p);

            p = new Paragraph("", new RtfFont("Staccato222 BT"));
            p.add(new Chunk("Hello! "));
            p.add(new Chunk("How do you do?"));
            doc.add(p);
            p.setAlignment(LwgElement.ALIGN_RIGHT);
            doc.add(p);

            Anchor a = new Anchor("http://www.uni-klu.ac.at");
            a.setReference("http://www.uni-klu.ac.at");
            doc.add(a);

            LwgImage img = LwgImage.getInstance("pngnow.png");
            doc.add(new Chunk(img, 0, 0));
            doc.add(new Annotation("Mark", "This works!"));

            Chunk c = new Chunk("");
            c.setNewPage();
            doc.add(c);

            List subList = new List(true, 40);
            subList.add(new ListItem("Sub list 1"));
            subList.add(new ListItem("Sub list 2"));

            List list = new List(true, 20);
            list.add(new ListItem("Test line 1"));
            list
                    .add(new ListItem(
                            "Test line 2 - This is a really long test line to test that linebreaks are working the way they are supposed to work so a really really long line of drivel is required"));
            list.add(subList);
            list.add(new ListItem("Test line 3 - \t\u20ac\t 60,-"));
            doc.add(list);

            list = new List(false, 20);
            list.add(new ListItem("Bullet"));
            list.add(new ListItem("Another one"));
            doc.add(list);

            doc.newPage();

            Chapter chapter = new Chapter(new Paragraph("This is a Chapter"), 1);
            chapter.add(new Paragraph(
                    "This is some text that belongs to this chapter."));
            chapter.add(new Paragraph("A second paragraph. What a surprise."));

            Section section = chapter.addSection(new Paragraph(
                    "This is a subsection"));
            section.add(new Paragraph("Text in the subsection."));

            doc.add(chapter);

            com.lowagie.text.rtf.field.RtfTOCEntry rtfTOC = new com.lowagie.text.rtf.field.RtfTOCEntry(
                    "Table Test");
            doc.add(rtfTOC);

            Table table = new Table(3);
            table.setPadding(2);
            table.setAlignment(LwgElement.ALIGN_LEFT);
            table.setSpacing(2);

            LwgCell emptyCell = new LwgCell("");

            LwgCell cellLeft = new LwgCell("Left Alignment");
            cellLeft.setHorizontalAlignment(LwgElement.ALIGN_LEFT);
            LwgCell cellCenter = new LwgCell("Center Alignment");
            cellCenter.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            LwgCell cellRight = new LwgCell("Right Alignment");
            cellRight.setHorizontalAlignment(LwgElement.ALIGN_RIGHT);

            table.addCell(cellLeft);
            table.addCell(cellCenter);
            table.addCell(cellRight);

            LwgCell cellSpanHoriz = new LwgCell("This Cell spans two columns");
            cellSpanHoriz.setColspan(2);
            table.addCell(cellSpanHoriz);
            table.addCell(emptyCell);

            LwgCell cellSpanVert = new LwgCell("This Cell spans two rows");
            cellSpanVert.setRowspan(2);
            table.addCell(emptyCell);
            table.addCell(cellSpanVert);
            table.addCell(emptyCell);
            table.addCell(emptyCell);
            table.addCell(emptyCell);

            LwgCell cellSpanHorizVert = new LwgCell(
                    "This Cell spans both two columns and two rows");
            cellSpanHorizVert.setColspan(2);
            cellSpanHorizVert.setRowspan(2);
            table.addCell(emptyCell);
            table.addCell(cellSpanHorizVert);
            table.addCell(emptyCell);

            RtfCell cellDotted = new RtfCell("Dotted border");
            cellDotted.setBorders(new RtfBorderGroup(LwgRectangle.BOX,
                    RtfBorder.BORDER_DOTTED, 1, new Color(0, 0, 0)));
            RtfCell cellEmbossed = new RtfCell("Embossed border");
            cellEmbossed.setBorders(new RtfBorderGroup(LwgRectangle.BOX,
                    RtfBorder.BORDER_EMBOSS, 1, new Color(0, 0, 0)));
            RtfCell cellNoBorder = new RtfCell("No border");
            cellNoBorder.setBorders(new RtfBorderGroup());

            table.addCell(cellDotted);
            table.addCell(cellEmbossed);
            table.addCell(cellNoBorder);

            doc.add(table);

            for (int i = 0; i < 300; i++) {
                doc.add(new Paragraph(
                        "Dummy line to get multi-page document. Line "
                                + (i + 1)));
            }

            doc.close();
View Full Code Here


            fonts[11] = FontFactory.getFont(FontFactory.TIMES_ROMAN, LwgFont.DEFAULTSIZE, LwgFont.BOLDITALIC);
            fonts[12] = FontFactory.getFont(FontFactory.SYMBOL, LwgFont.DEFAULTSIZE, LwgFont.NORMAL);
            fonts[13] = FontFactory.getFont(FontFactory.ZAPFDINGBATS, LwgFont.DEFAULTSIZE, LwgFont.NORMAL);
      // add the content
      for (int i = 0; i < 14; i++) {
          document.add(new Paragraph("quick brown fox jumps over the lazy dog", fonts[i]));
      }
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

      PdfWriter.getInstance(document, new FileOutputStream("Paragraphs.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
      Paragraph p1 = new Paragraph(new Chunk(
          "This is my first paragraph. ",
          FontFactory.getFont(FontFactory.HELVETICA, 10)));
      p1.add("The leading of this paragraph is calculated automagically. ");
      p1.add("The default leading is 1.5 times the fontsize. ");
      p1.add(new Chunk("You can add chunks "));
      p1.add(new LwgPhrase("or you can add phrases. "));
      p1.add(new LwgPhrase(
        "Unless you change the leading with the method setLeading, the leading doesn't change if you add text with another leading. This can lead to some problems.",
        FontFactory.getFont(FontFactory.HELVETICA, 18)));
      document.add(p1);
      Paragraph p2 = new Paragraph(new LwgPhrase(
          "This is my second paragraph. ", FontFactory.getFont(
              FontFactory.HELVETICA, 12)));
      p2.add("As you can see, it started on a new line.");
      document.add(p2);
      Paragraph p3 = new Paragraph("This is my third paragraph.",
          FontFactory.getFont(FontFactory.HELVETICA, 12));
      document.add(p3);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            document.add(new Paragraph("A picture of my dog: otsoe.jpg"));
            LwgImage jpg = LwgImage.getInstance(new URL("/examples/com/lowagie/examples/html/otsoe.jpg"));
            document.add(jpg);
            document.add(new Paragraph("getacro.gif"));
            LwgImage gif= LwgImage.getInstance(new URL("/examples/com/lowagie/examples/html/getacro.gif"));
            document.add(gif);
            document.add(new Paragraph("pngnow.png"));
            LwgImage png = LwgImage.getInstance(new URL("/examples/com/lowagie/examples/html/pngnow.png"));
            document.add(png);
            document.add(new Paragraph("iText.bmp"));
            LwgImage bmp = LwgImage.getInstance(new URL("/examples/com/lowagie/examples/html/iText.bmp"));
            document.add(bmp);
            document.add(new Paragraph("iText.wmf"));
            LwgImage wmf = LwgImage.getInstance(new URL("/examples/com/lowagie/examples/html/iText.wmf"));
            document.add(wmf);
            document.add(new Paragraph("iText.tif"));
            LwgImage tiff = LwgImage.getInstance(new URL("/examples/com/lowagie/examples/html/iText.tif"));
            document.add(tiff);
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
View Full Code Here

           
            // Step 3: Open the document.
            document.open();
           
            // Step 4: Add content to the document.
            document.add(new Paragraph("Hello World!"));
           
            // Step 5: Close the document. It will be written to the target output stream.
            document.close();
        } catch (FileNotFoundException fnfe) {
            // It might not be possible to create the target file.
View Full Code Here

            document.open();
           
            // Simply set the stylesheet you wish to use as the Font
            // of the Paragraph
            document.add(new Paragraph("This is a heading",
                    RtfParagraphStyle.STYLE_HEADING_1));
           
            document.add(new Paragraph("Just some text that is formatted " +
                    "in the default style.", RtfParagraphStyle.STYLE_NORMAL));

            document.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
View Full Code Here

            writer.setViewerPreferences(PdfWriter.PageModeUseThumbs);
            document.open();
            // step 4:
            // we add some content
            for (int k = 1; k <= 10; ++k) {
                document.add(new Paragraph("This document has the logical page numbers: i,ii,iii,iv,1,2,3,A-8,A-9,A-10\nReal page " + k));
                document.newPage();
            }
            PdfPageLabels pageLabels = new PdfPageLabels();
            pageLabels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS);
            pageLabels.addPageLabel(5, PdfPageLabels.DECIMAL_ARABIC_NUMERALS);
View Full Code Here

      // step 3: we open the document
      document.open();
      // step 4:
      Paragraph[] p = new Paragraph[5];
            p[0] = new Paragraph("GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.  Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt.  Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.");
            p[1] = new Paragraph("[Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones. Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. Aquitania a Garumna flumine ad Pyrenaeos montes et eam partem Oceani quae est ad Hispaniam pertinet; spectat inter occasum solis et septentriones.]");
            p[2] = new Paragraph("Apud Helvetios longe nobilissimus fuit et ditissimus Orgetorix.  Is M. Messala, [et P.] M.  Pisone consulibus regni cupiditate inductus coniurationem nobilitatis fecit et civitati persuasit ut de finibus suis cum omnibus copiis exirent:  perfacile esse, cum virtute omnibus praestarent, totius Galliae imperio potiri.  Id hoc facilius iis persuasit, quod undique loci natura Helvetii continentur:  una ex parte flumine Rheno latissimo atque altissimo, qui agrum Helvetium a Germanis dividit; altera ex parte monte Iura altissimo, qui est inter Sequanos et Helvetios; tertia lacu Lemanno et flumine Rhodano, qui provinciam nostram ab Helvetiis dividit.  His rebus fiebat ut et minus late vagarentur et minus facile finitimis bellum inferre possent; qua ex parte homines bellandi cupidi magno dolore adficiebantur.  Pro multitudine autem hominum et pro gloria belli atque fortitudinis angustos se fines habere arbitrabantur, qui in longitudinem milia passuum CCXL, in latitudinem CLXXX patebant.");
            p[3] = new Paragraph("His rebus adducti et auctoritate Orgetorigis permoti constituerunt ea quae ad proficiscendum pertinerent comparare, iumentorum et carrorum quam maximum numerum coemere, sementes quam maximas facere, ut in itinere copia frumenti suppeteret, cum proximis civitatibus pacem et amicitiam confirmare.  Ad eas res conficiendas biennium sibi satis esse duxerunt; in tertium annum profectionem lege confirmant.  Ad eas res conficiendas Orgetorix deligitur.  Is sibi legationem ad civitates suscipit.  In eo itinere persuadet Castico, Catamantaloedis filio, Sequano, cuius pater regnum in Sequanis multos annos obtinuerat et a senatu populi Romani amicus appellatus erat, ut regnum in civitate sua occuparet, quod pater ante habuerit; itemque Dumnorigi Haeduo, fratri Diviciaci, qui eo tempore principatum in civitate obtinebat ac maxime plebi acceptus erat, ut idem conaretur persuadet eique filiam suam in matrimonium dat.  Perfacile factu esse illis probat conata perficere, propterea quod ipse suae civitatis imperium obtenturus esset:  non esse dubium quin totius Galliae plurimum Helvetii possent; se suis copiis suoque exercitu illis regna conciliaturum confirmat.  Hac oratione adducti inter se fidem et ius iurandum dant et regno occupato per tres potentissimos ac firmissimos populos totius Galliae sese potiri posse sperant.");
            p[4] = new Paragraph("Ea res est Helvetiis per indicium enuntiata.  Moribus suis Orgetoricem ex vinculis causam dicere coegerunt; damnatum poenam sequi oportebat, ut igni cremaretur.  Die constituta causae dictionis Orgetorix ad iudicium omnem suam familiam, ad hominum milia decem, undique coegit, et omnes clientes obaeratosque suos, quorum magnum numerum habebat, eodem conduxit; per eos ne causam diceret se eripuit.  Cum civitas ob eam rem incitata armis ius suum exequi conaretur multitudinemque hominum ex agris magistratus cogerent, Orgetorix mortuus est; neque abest suspicio, ut Helvetii arbitrantur, quin ipse sibi mortem consciverit.");
            for (int i = 0; i < 5; i++) {
              p[i].setAlignment(LwgElement.ALIGN_JUSTIFIED);
              document.add(p[i]);
            }
            document.newPage();
View Full Code Here

            // Add RtfTab tab stops at the desired positions
            tabGroup.add(new RtfTab(400, RtfTab.TAB_RIGHT_ALIGN));
            tabGroup.add(new RtfTab(500, RtfTab.TAB_DECIMAL_ALIGN));
           
            // Create a Paragraph object
            Paragraph par = new Paragraph();
            // Add the tab group to the paragraph
            par.add(tabGroup);
            // Specify the tab positions using "\t"
            par.add("Description\tDate\tAmount");
            document.add(par);
           
            DecimalFormat nf = new DecimalFormat("#.00");
            double sum = 0;
            for(int i = 0; i < 10; i++) {
                double value = Math.random() * 100;
                sum = sum + value;

                par = new Paragraph();
                // The RtfTabGroup can be reused for further paragraphs
                par.add(tabGroup);
                par.add("Item " + (i + 1) + "\t" + (12 + i) + ".03.2007\t" + nf.format(value));
                document.add(par);
            }

            par = new Paragraph("", new LwgFont(LwgFont.TIMES_ROMAN, 12, LwgFont.BOLD));
            par.add(tabGroup);
            // If a tab in the RtfTabGroup is not needed, just add an empty tab stop in the text
            par.add("Total\t\t" + nf.format(sum));
            document.add(par);
           
            document.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
View Full Code Here

        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2.getInstance(document, new FileOutputStream("ExtendedHeaderFooter.rtf"));

            // Create the Paragraphs that will be used in the header.
            Paragraph date = new Paragraph("01.01.2010");
            date.setAlignment(Paragraph.ALIGN_RIGHT);
            Paragraph address = new Paragraph("TheFirm\nTheRoad 24, TheCity\n" +
                    "+00 99 11 22 33 44");

            // Create the RtfHeaderFooter with an array containing the Paragraphs to add
            RtfHeaderFooter header = new RtfHeaderFooter(new LwgElement[]{date, address});
           
            // Set the header
            document.setHeader(header);

            // Create the table that will be used as the footer
            Table footer = new Table(2);
            footer.setBorder(0);
            footer.getDefaultCell().setBorder(0);
            footer.setWidth(100);
            footer.addCell(new LwgCell("(c) Mark Hall"));
            Paragraph pageNumber = new Paragraph("Page ");
           
            // The RtfPageNumber is an RTF specific element that adds a page number field
            pageNumber.add(new RtfPageNumber());
            pageNumber.setAlignment(Paragraph.ALIGN_RIGHT);
            footer.addCell(new LwgCell(pageNumber));
           
            // Create the RtfHeaderFooter and set it as the footer to use
            document.setFooter(new RtfHeaderFooter(footer));
           
            document.open();
           
            document.add(new Paragraph("This document has headers and footers created" +
                    " using the RtfHeaderFooter class."));

            document.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
View Full Code Here

TOP

Related Classes of com.lowagie.text.Paragraph

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.