Package com.lowagie.text

Examples of com.lowagie.text.LwgDocument


  public static void main(String[] args) {

    System.out.println("Symbol Substitution");

    // step 1: creation of a document-object
    LwgDocument document = new LwgDocument();
    try {
      // step 2:
      // we create a writer that listens to the document
      PdfWriter.getInstance(document,
          new FileOutputStream("SymbolSubstitution.pdf"));

      // step 3: we open the document
      document.open();
      // step 4:
            document.add(LwgPhrase.getInstance("What is the " + (char) 945 + "-coefficient of the "
                    + (char) 946 + "-factor in the " + (char) 947 + "-equation?\n"));
                    for (int i = 913; i < 970; i++) {
                        document.add(LwgPhrase.getInstance(" " + i + ": " + (char) i));
                    }
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
  }
View Full Code Here


    public static void main(String[] args) {
       
        System.out.println("Irregular Columns");
       
        // step 1: creation of a document-object
        LwgDocument document = new LwgDocument();
       
        try {
           
            // step 2: creation of the writer
            PdfWriter writer = PdfWriter.getInstance(document, new GfrFileOutputStream("com.lowagie.examples.objects.columns.ColumnIrregular.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4:
            // we grab the contentbyte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            PdfTemplate t = cb.createTemplate(600, 800);
            LwgImage caesar = LwgImage.getInstance("caesar_coin.jpg");
            cb.addImage(caesar, 100, 0, 0, 100, 260, 595);
            t.setGrayFill(0.75f);
            t.moveTo(310, 112);
            t.lineTo(280, 60);
            t.lineTo(340, 60);
            t.closePath();
            t.moveTo(310, 790);
            t.lineTo(310, 710);
            t.moveTo(310, 580);
            t.lineTo(310, 122);
            t.stroke();
            cb.addTemplate(t, 0, 0);
           
            ColumnText ct = new ColumnText(cb);
            ct.addText(new LwgPhrase("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.\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("[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.]\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("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.\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("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.\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("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.", FontFactory.getFont(FontFactory.HELVETICA, 12)));
           
            float[] left1  = {70,790, 70,60};
            float[] right1 = {300,790, 300,700, 240,700, 240,590, 300,590, 300,106, 270,60};
            float[] left2  = {320,790, 320,700, 380,700, 380,590, 320,590, 320,106, 350,60};
            float[] right2 = {550,790, 550,60};
           
            int status = 0;
            int column = 0;
            while ((status & ColumnText.NO_MORE_TEXT) == 0) {
                if (column == 0) {
                    ct.setColumns(left1, right1);
                    column = 1;
                }
                else {
                    ct.setColumns(left2, right2);
                    column = 0;
                }
                status = ct.go();
                ct.setYLine(790);
                ct.setAlignment(LwgElement.ALIGN_JUSTIFIED);
                status = ct.go();
                if ((column == 0) && ((status & ColumnText.NO_MORE_COLUMN) != 0)) {
                    document.newPage();
                    cb.addTemplate(t, 0, 0);
                    cb.addImage(caesar, 100, 0, 0, 100, 260, 595);
                }
            }
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
            System.err.println(ioe.getMessage());
        }
       
        // step 5: we close the document
        document.close();
    }
View Full Code Here

  public static void main(String[] args) {

    System.out.println("Viewerpreferences");

    // step 1: creation of a document-object
    LwgDocument document = new LwgDocument(LwgPageSize.A6);
    try {

      // step 2:
      PdfWriter writer1 = PdfWriter.getInstance(document,
          new FileOutputStream("TwoColumnLeft.pdf"));
      PdfWriter writer2 = PdfWriter.getInstance(document,
          new FileOutputStream("HideMenuToolbar.pdf"));
      PdfWriter writer3 = PdfWriter.getInstance(document,
          new FileOutputStream("FullScreen.pdf"));
      PdfWriter writer4 = PdfWriter.getInstance(document,
          new FileOutputStream("WithTitle.pdf"));
      PdfWriter writer5 = PdfWriter.getInstance(document,
          new FileOutputStream("NoScaling.pdf"));
      // step 3:
      writer1.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);
      writer2.setViewerPreferences(PdfWriter.HideMenubar
          | PdfWriter.HideMenubar);
      writer3.setViewerPreferences(PdfWriter.PageLayoutTwoColumnRight
          | PdfWriter.PageModeFullScreen
          | PdfWriter.NonFullScreenPageModeUseThumbs);
      writer4.setViewerPreferences(PdfWriter.DisplayDocTitle);
      writer5.setViewerPreferences(PdfWriter.PrintScalingNone);
      document.addTitle("Julius Caesar");
      document.open();
      // step 4: we grab the ContentByte and do some stuff with it
      document
          .add(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.",
              new LwgFont(LwgFont.HELVETICA, 12)));
      document
          .add(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.]",
              new LwgFont(LwgFont.HELVETICA, 12)));
      document
          .add(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.",
              new LwgFont(LwgFont.HELVETICA, 12)));
      document
          .add(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.",
              new LwgFont(LwgFont.HELVETICA, 12)));
      document
          .add(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.",
              new LwgFont(LwgFont.HELVETICA, 12)));
    } catch (Exception de) {
      de.printStackTrace();
    }

    // step 5: we close the document
    document.close();
  }
View Full Code Here

     * @param args Unused
     */
    public static void main(String[] args) {
        System.out.println("Demonstrates creating new, user-defined paragraph stylesheets");
        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2 writer = RtfWriter2.getInstance(document, new FileOutputStream("ExtendingStylesheets.rtf"));

            // Create the new RtfParagraphStyle. The second parameter is the name of
            // the RtfParagraphStyle that this style will inherit default properties from.
            RtfParagraphStyle incorrectStyle = new RtfParagraphStyle("Incorrect", "Normal");
            // Change the desired properties
            incorrectStyle.setColor(Color.RED);
            incorrectStyle.setStyle(LwgFont.STRIKETHRU);
            // Register the new paragraph stylesheet with the RtfWriter2.
            writer.getDocumentSettings().registerParagraphStyle(incorrectStyle);
           
            // Create a new RtfParagraphStyle that does not inherit from any other style.
            RtfParagraphStyle correctStyle = new RtfParagraphStyle("Correct", "Arial",
                    12, LwgFont.NORMAL, Color.GREEN);
            // Register the new paragraph stylesheet with the RtfWriter2.
            writer.getDocumentSettings().registerParagraphStyle(correctStyle);

            // Change the default font name. This will propagate to the paragraph stylesheet
            // that inherits, but not the other one.
            RtfParagraphStyle.STYLE_NORMAL.setFontName("Times New Roman");
           
            document.open();
           
            // Simply set the stylesheet you wish to use as the Font
            // of the Paragraph
            document.add(new Paragraph("This is a heading level 1",
                    RtfParagraphStyle.STYLE_HEADING_1));
            document.add(new Paragraph("This is a heading level 2",
                    RtfParagraphStyle.STYLE_HEADING_2));
            document.add(new Paragraph("Just some text that is formatted " +
                    "in the default style.", RtfParagraphStyle.STYLE_NORMAL));
            document.add(new Paragraph("This paragraph should be removed.",
                    incorrectStyle));
            document.add(new Paragraph("It should be replaced with this.",
                    correctStyle));

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

     * @param args no arguments needed
     */
    public static void main(String[] args) {
        try {
          // step 1
          LwgDocument document = new LwgDocument();
          // step 2
            PdfWriter.getInstance(document, new FileOutputStream("fontselection.pdf"));
            // step 3
            document.open();
            // step 4
            String text = "This text is the first verse of \u275dThe Iliad\u275e. It's not polytonic as it should be "
            + "with \u2798 and \u279a entoation variants but that's all we have for now.\n\n"
            + "\u2766\u00a0\u00a0\u039c\u03b7\u03bd\u03b9\u03bd \u03b1\u03b5\u03b9\u03b4\u03b5, \u03b8\u03b5\u03b1, \u03a0\u03b7\u03bb\u03b7\u03b9\u03b1\u03b4\u03b5\u03c9 \u0391\u03c7\u03b9\u03bb\u03b7\u03bf\u03c2";
            FontSelector sel = new FontSelector();
            sel.addFont(new LwgFont(LwgFont.TIMES_ROMAN, 12));
            sel.addFont(new LwgFont(LwgFont.ZAPFDINGBATS, 12));
            sel.addFont(new LwgFont(LwgFont.SYMBOL, 12));
            LwgPhrase ph = sel.process(text);
            document.add(new Paragraph(ph));
            // step 5
            document.close();
        }
        catch(Exception de) {
            de.printStackTrace();
        }
    }
View Full Code Here

     * @param args Unused
     */
    public static void main(String[] args) {
        System.out.println("Demonstrates creating Paragraphs with tab stops");
        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2.getInstance(document, new FileOutputStream("BasicTabs.rtf"));

            document.open();
           
            // Define the Paragraph to add tab stops to
            Paragraph par = new Paragraph();
           
            // Add the tab stops to the paragraph
            par.add(new RtfTab(70, RtfTab.TAB_LEFT_ALIGN));
            par.add(new RtfTab(400, RtfTab.TAB_RIGHT_ALIGN));
           
            // Add the text to the paragraph, placing the tab stops with \t
            par.add("\tFirst the text on the left-hand side\tThis text is right aligned.");
           
            document.add(par);

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

     * @param args Unused
     */
    public static void main(String[] args) {
        System.out.println("Demonstrates creating different headers and footers per Chapter");
        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2.getInstance(document, new FileOutputStream("ChapterHeaderFooter.rtf"));

            // Create the header identifying the current chapter. The first
            // chapter has to be set before the document is opened.
            Paragraph header = new Paragraph("Chapter 1");
            header.setAlignment(LwgElement.ALIGN_CENTER);
            document.setHeader(new RtfHeaderFooter(header));
           
            // If the footer (or header) is to be the same for all Chapters
            // then it has to be set before the document is opened and is
            // then automatically set for all Chapters.
            document.setFooter(new HeaderFooter(new LwgPhrase("This is page "), new LwgPhrase(".")));
           
            document.open();
           
            Chapter chapter1 = new Chapter("Chapter 1", 1);
            chapter1.add(new Paragraph("This document has different headers and footers " +
                    " for each chapter."));
            document.add(chapter1);

            // After adding the first chapter set the header for the second chapter.
            header = new Paragraph("Chapter 2");
            header.setAlignment(LwgElement.ALIGN_CENTER);
            document.setHeader(new RtfHeaderFooter(header));

            Chapter chapter2 = new Chapter("Chapter 2", 2);
            chapter2.add(new Paragraph("This is the content of chapter 2."));
            document.add(chapter2);
           
            // After adding the second chapter set the header for the third chapter.
            header = new Paragraph("Chapter 3");
            header.setAlignment(LwgElement.ALIGN_CENTER);
            document.setHeader(new RtfHeaderFooter(header));

            Chapter chapter3 = new Chapter("Chapter 3", 3);
            chapter3.add(new Paragraph("Chapter 3 is very boring."));
            document.add(chapter3);

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

     * @param args Unused
     */
    public static void main(String[] args) {
        System.out.println("Demonstrates using the RTF table of contents.");
        try {
            LwgDocument document = new LwgDocument();
            RtfWriter2 rtfWriter2 = RtfWriter2.getInstance(document, new FileOutputStream("TableOfContents.rtf"));

            // Create paragraph stylesheets for each heading level. They must be named
            // "toc N" for each heading level you are using
            RtfParagraphStyle tocLevel1Style = new RtfParagraphStyle("toc 1",
                    "Times New Roman", 11, LwgFont.NORMAL, Color.BLACK);
            RtfParagraphStyle tocLevel2Style = new RtfParagraphStyle("toc 2",
                    "Times New Roman", 10, LwgFont.NORMAL, Color.BLACK);
            tocLevel2Style.setIndentLeft(10);
           
            // Register the paragraph stylesheets with the RtfWriter2
            rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel1Style);
            rtfWriter2.getDocumentSettings().registerParagraphStyle(tocLevel2Style);
           
            document.open();

            // Create a Paragraph and add the table of contents to it
            Paragraph par = new Paragraph();
            par.add(new RtfTableOfContents("Right-click here and select \"Update\" " +
                    "to see the table of contents."));
            document.add(par);
           
            for(int i = 1; i <= 5; i++) {
                // Create a level 1 heading
                document.add(new Paragraph("Heading " + i, RtfParagraphStyle.STYLE_HEADING_1));
                for(int j = 1; j <= 3; j++) {
                    // Create a level 2 heading
                    document.add(new Paragraph("Heading " + i + "." + j, RtfParagraphStyle.STYLE_HEADING_2));
                    for(int k = 1; k <= 20; k++) {
                        document.add(new Paragraph("Line " + k + " in section " + i + "." + k));
                    }
                }
            }
           
            document.close();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace();
        } catch (DocumentException de) {
            de.printStackTrace();
        }
View Full Code Here

  public static void main(String[] args) {

    System.out.println("Bookmarks");

    // step 1: creation of a document-object
    LwgDocument document = new LwgDocument(LwgPageSize.A6);
    try {

      // step 2:
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Bookmarks.pdf"));
      // step 3:
            writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
      document.open();
            // step 4: we grab the ContentByte and do some stuff with it
            writer.setPageEvent(new Bookmarks());
           
            document.add(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.", new LwgFont(LwgFont.HELVETICA, 12)));
            document.add(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.]", new LwgFont(LwgFont.HELVETICA, 12)));
            document.add(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.", new LwgFont(LwgFont.HELVETICA, 12)));
            document.add(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.", new LwgFont(LwgFont.HELVETICA, 12)));
            document.add(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.", new LwgFont(LwgFont.HELVETICA, 12)));
    } catch (Exception de) {
      de.printStackTrace();
    }

    // step 5: we close the document
    document.close();
  }
View Full Code Here

   */
  public static void main(String[] args) {

    System.out.println("indentation - alignment");
    // step1
    LwgDocument document = new LwgDocument(LwgPageSize.A4.rotate(), 10, 10, 10, 10);
    try {
      // step2
      PdfWriter.getInstance(document,
          new GfrFileOutputStream("com.lowagie.examples.objects.tables.CellAlignment.pdf"));
      // step3
      document.open();
      // step4
      LwgPdfPTable table = new LwgPdfPTable(2);
      LwgPdfPCell cell;
      Paragraph p = new Paragraph("Quick brown fox jumps over the lazy dog. Quick brown fox jumps over the lazy dog.");
      table.add("default alignment");
      cell = new LwgPdfPCell(p);
      table.add(cell);
      table.add("centered alignment");
      cell = new LwgPdfPCell(p);
      cell.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
      table.add(cell);
      table.add("right alignment");
      cell = new LwgPdfPCell(p);
      cell.setHorizontalAlignment(LwgElement.ALIGN_RIGHT);
      table.add(cell);
      table.add("justified alignment");
      cell = new LwgPdfPCell(p);
      cell.setHorizontalAlignment(LwgElement.ALIGN_JUSTIFIED);
      table.add(cell);
      table.add("blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n");
      table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_BASELINE);
      table.add("baseline");
      table.add("blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n");
      table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_BOTTOM);
      table.add("bottom");
      table.add("blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n");
      table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_MIDDLE);
      table.add("middle");
      table.add("blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n");
      table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_TOP);
      table.add("top");
      document.add(table);
    } catch (Exception de) {
      de.printStackTrace();
    }
    // step5
    document.close();
  }
View Full Code Here

TOP

Related Classes of com.lowagie.text.LwgDocument

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.