Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.ColumnText


  public void addHtmlToPdfContentByte(String html, float[] pos) {
   
    PdfContentByte cb = docWriter.getDirectContent();
    StyleSheet styles = createDefaultStyleSheet();

    ColumnText ct = new ColumnText(cb);
    ct.setSimpleColumn(pos[0], pos[1], pos[2], pos[3]);
    ct.setYLine(pos[3]);
    try {
      ArrayList htmlObjs = HTMLWorker.parseToList(new StringReader(html),
          styles);
      for (int k = 0; k < htmlObjs.size(); ++k) {
        ct.addElement((Element) htmlObjs.get(k));
      }
      ct.go();
    } catch (Exception e) {
      throw new RuntimeException("Could not parse HTML", e);
    }
  }
View Full Code Here


            LwgFont f2 = new LwgFont(bf, 24, LwgFont.NORMAL, Color.BLUE);
            float llx = 100;
            float lly = 100;
            float urx = 500;
            float ury = 800;
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(llx, lly, urx, ury, 24, LwgElement.ALIGN_LEFT);
            ct.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
            ct.setLeading(0, 1);
            ct.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
            ct.setAlignment(LwgElement.ALIGN_CENTER);
            ct.addText(new Chunk(ar1, new LwgFont(bf, 16)));
            ct.addText(new Chunk(ar2, new LwgFont(bf, 16, LwgFont.NORMAL, Color.red)));
            ct.go();
            ct.setAlignment(LwgElement.ALIGN_JUSTIFIED);
            ct.addText(new Chunk(ar3, new LwgFont(bf, 12)));
            ct.go();
            ct.setAlignment(LwgElement.ALIGN_CENTER);
            ct.addText(new Chunk(ar4, new LwgFont(bf, 14)));
            ct.go();
           
            ct.setSpaceCharRatio(PdfWriter.SPACE_CHAR_RATIO_DEFAULT);
            ct.setAlignment(LwgElement.ALIGN_CENTER);
            ct.addText(new Chunk("\n\n\n", new LwgFont(bf, 16)));
            ct.addText(new Chunk(he1, new LwgFont(bf, 16)));
            ct.addText(new Chunk(he2, new LwgFont(bf, 16, LwgFont.NORMAL, Color.red)));
            ct.go();
            ct.setAlignment(LwgElement.ALIGN_JUSTIFIED);
            ct.addText(new Chunk(he3, new LwgFont(bf, 12)));
            ct.go();
            ct.setAlignment(LwgElement.ALIGN_CENTER);
            ct.addText(new Chunk(he4, new LwgFont(bf, 14)));
            ct.go();
           
            document.newPage();
            String atext = "\u062a\u0635\u0628\u062d ";
            LwgPdfPTable table = new LwgPdfPTable(5);
            table.setWidthPercentage(100);
View Full Code Here

            Font f2 = new Font(bf, 24, Font.NORMAL, Color.BLUE);
            float llx = 100;
            float lly = 100;
            float urx = 500;
            float ury = 800;
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(llx, lly, urx, ury, 24, Element.ALIGN_LEFT);
            ct.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
            ct.setLeading(0, 1);
            ct.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
            ct.setAlignment(Element.ALIGN_CENTER);
            ct.addText(new Chunk(ar1, new Font(bf, 16)));
            ct.addText(new Chunk(ar2, new Font(bf, 16, Font.NORMAL, Color.red)));
            ct.go();
            ct.setAlignment(Element.ALIGN_JUSTIFIED);
            ct.addText(new Chunk(ar3, new Font(bf, 12)));
            ct.go();
            ct.setAlignment(Element.ALIGN_CENTER);
            ct.addText(new Chunk(ar4, new Font(bf, 14)));
            ct.go();
           
            ct.setSpaceCharRatio(PdfWriter.SPACE_CHAR_RATIO_DEFAULT);
            ct.setAlignment(Element.ALIGN_CENTER);
            ct.addText(new Chunk("\n\n\n", new Font(bf, 16)));
            ct.addText(new Chunk(he1, new Font(bf, 16)));
            ct.addText(new Chunk(he2, new Font(bf, 16, Font.NORMAL, Color.red)));
            ct.go();
            ct.setAlignment(Element.ALIGN_JUSTIFIED);
            ct.addText(new Chunk(he3, new Font(bf, 12)));
            ct.go();
            ct.setAlignment(Element.ALIGN_CENTER);
            ct.addText(new Chunk(he4, new Font(bf, 14)));
            ct.go();
           
            document.newPage();
            String atext = "\u062a\u0635\u0628\u062d ";
            PdfPTable table = new PdfPTable(5);
            table.setWidthPercentage(100);
View Full Code Here

            }
           
            // we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(unicodes, 60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
            ct.go();
            cb.rectangle(103, 295, 52, 8 + 28 * 15);
            cb.stroke();
            ct.setSimpleColumn(characters, 105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT);
            ct.go();
            ct.setSimpleColumn(names, 160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT);
            ct.go();
           
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
View Full Code Here

            t.moveTo(310, 580);
            t.lineTo(310, 122);
            t.stroke();
            cb.addTemplate(t, 0, 0);
           
            ColumnText ct = new ColumnText(cb);
            ct.addText(new Phrase("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 Phrase("[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 Phrase("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 Phrase("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 Phrase("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(Element.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);
                }
View Full Code Here

            // get the stream content
            PdfContentByte cb = writer.getDirectContent();
            // headers
            Phrase fullTitle = new Phrase("Full Title", font24B);
            float currentY = document.top();
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(fullTitle, document.left(), 0, document.right(), document.top(), 24, Element.ALIGN_JUSTIFIED);
            ct.go();
            currentY = ct.getYLine();
            currentY -= 4;
            cb.setLineWidth(1);
            cb.moveTo(document.left(), currentY);
            cb.lineTo(document.right(), currentY);
            cb.stroke();
            currentY -= 4;
            ct.setYLine(currentY);
            ct.addText(new Chunk("Author: Name of the author comes here", font10B));
            ct.setLeading(10);
            ct.go();
            currentY = ct.getYLine();
            currentY -= 15;
            float topColumn = currentY;
            for (int k = 1; k < numColumns; ++k) {
                float x = allColumns[k] - gutter / 2;
                cb.moveTo(x, topColumn);
                cb.lineTo(x, document.bottom());
            }
            cb.stroke();
            Image img = Image.getInstance("cover.png");
            cb.addImage(img, img.getScaledWidth(), 0, 0, img.getScaledHeight(), document.left(), currentY - img.getScaledHeight());
            currentY -= img.getScaledHeight() + 10;
            ct.setYLine(currentY);
            ct.addText(new Chunk("Key Data:", font14B));
            ct.go();
            currentY = ct.getYLine();
            currentY -= 4;
            PdfPTable ptable = new PdfPTable(2);
            ptable.getDefaultCell().setPaddingLeft(4);
            ptable.getDefaultCell().setPaddingTop(0);
            ptable.getDefaultCell().setPaddingBottom(4);
            ptable.addCell(new Phrase("Imprint Name:", font9));
            ptable.addCell(new Phrase("Prentice Hall", font9));
            ptable.addCell(new Phrase("Series Name:", font9));
            ptable.addCell(new Phrase("", font9));
            ptable.addCell(new Phrase("ISBN:", font9));
            ptable.addCell(new Phrase("Hall", font9));
            ptable.addCell(new Phrase("UPC Code:", font9));
            ptable.addCell(new Phrase("0789718103", font9));
            ptable.addCell(new Phrase("EAN #", font9));
            ptable.addCell(new Phrase("0786718103", font9));
            ptable.addCell(new Phrase("Price:", font9));
            ptable.addCell(new Phrase("49.99", font9));
            ptable.addCell(new Phrase("Page Count:", font9));
            ptable.addCell(new Phrase("500", font9));
            ptable.addCell(new Phrase("Discount:", font9));
            ptable.addCell(new Phrase("10%", font9));
            ptable.addCell(new Phrase("Trim Size:", font9));
            ptable.addCell(new Phrase("420x340", font9));
            ptable.addCell(new Phrase("Cover:", font9));
            ptable.addCell(new Phrase("Hard", font9));
            ptable.addCell(new Phrase("Interior Color:", font9));
            ptable.addCell(new Phrase("none", font9));
            ptable.addCell(new Phrase("Media with book:", font9));
            ptable.addCell(new Phrase("CD", font9));
            ptable.addCell(new Phrase("Author(s):", font9));
            ptable.addCell(new Phrase("Ben Forta", font9));
            ptable.addCell(new Phrase("Editor:", font9));
            ptable.addCell(new Phrase("Ben Forta", font9));
            ptable.addCell(new Phrase("Pub Date:", font9));
            ptable.addCell(new Phrase("06/05/1998", font9));
            ptable.setTotalWidth(columnWidth);

            currentY = ptable.writeSelectedRows(0, -1, document.left(), currentY, cb) - 20;
            for (int k = 0; k < headings.length; ++k) {
                ct.addText(new Chunk(headings[k] + "\n", font14B));
                ct.addText(new Chunk(texts[k] + "\n\n", font11));
            }

            int currentColumn = 0;
            ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
                allColumns[currentColumn] + columnWidth, currentY, 15, Element.ALIGN_JUSTIFIED);
            ct.setLeading(2, 1);
            for (;;) {
                int rc = ct.go();
                if ((rc & ColumnText.NO_MORE_TEXT) != 0)
                    break;
                // we run out of column. Let's go to another one
                ++currentColumn;
                if (currentColumn >= allColumns.length)
                    break;
                ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
                    allColumns[currentColumn] + columnWidth, topColumn, 15, Element.ALIGN_JUSTIFIED);
                ct.setLeading(2, 1);
            }
            // step 5: we close the document
            document.close();
        }
        catch (Exception de) {
View Full Code Here

            tp.setGroup(group);
            cb.addTemplate(tp, 200 + 2 * gap, 500 - 200 - gap);
            cb.restoreState();

            cb.resetRGBColorFill();
            ColumnText ct = new ColumnText(cb);
            Phrase ph = new Phrase("Ungrouped objects\nObject opacity = 1.0");
            ct.setSimpleColumn(ph, gap, 0, gap + 200, 500, 18, Element.ALIGN_CENTER);
            ct.go();
           
            ph = new Phrase("Ungrouped objects\nObject opacity = 0.5");
            ct.setSimpleColumn(ph, 200 + 2 * gap, 0, 200 + 2 * gap + 200, 500, 18, Element.ALIGN_CENTER);
            ct.go();
           
            ph = new Phrase("Transparency group\nObject opacity = 1.0\nGroup opacity = 0.5\nBlend mode = Normal");
            ct.setSimpleColumn(ph, gap, 0, gap + 200, 500 - 200 - gap, 18, Element.ALIGN_CENTER);
            ct.go();
           
            ph = new Phrase("Transparency group\nObject opacity = 0.5\nGroup opacity = 1.0\nBlend mode = SoftLight");
            ct.setSimpleColumn(ph, 200 + 2 * gap, 0, 200 + 2 * gap + 200, 500 - 200 - gap, 18, Element.ALIGN_CENTER);
            ct.go();
           
            cb.sanityCheck();
        }
        catch (Exception de) {
            de.printStackTrace();
View Full Code Here

            PdfContentByte cb = writer.getDirectContent();
           
            BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            Font font = new Font(bf, 11, Font.NORMAL);
           
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
            ct.addText(new Phrase(15, "UNI\n", font));
            for (int i = 0; i < 27; i++) {
                ct.addText(new Phrase(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, Element.ALIGN_RIGHT);
            ct.addText(new Phrase(15, "char\n", font));
            for (int i = 0; i < 27; i++) {
                ct.addText(new Phrase(15, code[i] + "\n", font));
            }
            ct.go();
            ct.setSimpleColumn(160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT);
            ct.addText(new Phrase(15, "NAME" + "\n", font));
            for (int i = 0; i < 27; i++) {
                ct.addText(new Phrase(15, name[i] + "\n", font));
            }
            ct.go();
           
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
View Full Code Here

            // get the stream content
            PdfContentByte cb = writer.getDirectContent();
            // headers
//            Phrase fullTitle = new Phrase("Full Title", font24B);
            float currentY = document.top();
            ColumnText ct = new ColumnText(cb);
//            ct.setSimpleColumn(fullTitle, document.left(), 0, document.right(), document.top(), 24, Element.ALIGN_JUSTIFIED);
//            ct.go();
//           
//           
//            currentY = ct.getYLine();
//            currentY -= 4;
//            cb.setLineWidth(1);
//            cb.moveTo(document.left(), currentY);
//            cb.lineTo(document.right(), currentY);
//            cb.stroke();
//           
//           
//            currentY -= 4;
//            ct.setYLine(currentY);
//            ct.addText(new Chunk("Author: Name of the author comes here", font10B));
//            ct.setLeading(10);
//            ct.go();
//            currentY = ct.getYLine();
//            currentY -= 15;
            float topColumn = currentY;
//            for (int k = 1; k < numColumns; ++k) {
//                float x = allColumns[k] - gutter / 2;
//                cb.moveTo(x, topColumn);
//                cb.lineTo(x, document.bottom());
//            }
//            cb.stroke();
//           
           
           
           
            Image img = Image.getInstance("c:\\lh.jpg");
            cb.addImage(img, img.getScaledWidth(), 0, 0, img.getScaledHeight(), document.left(), currentY - img.getScaledHeight());
            currentY -= img.getScaledHeight() + 10;
            ct.setYLine(currentY);
            ct.addText(new Chunk("Key Data:", font14B));
            ct.go();
            currentY = ct.getYLine();
            currentY -= 4;
           
           
            PdfPTable ptable = new PdfPTable(2);
            ptable.getDefaultCell().setPaddingLeft(4);
            ptable.getDefaultCell().setPaddingTop(0);
            ptable.getDefaultCell().setPaddingBottom(4);
            ptable.addCell(new Phrase("Imprint Name:", font9));
            ptable.addCell(new Phrase("Prentice Hall", font9));
            ptable.addCell(new Phrase("Series Name:", font9));
            ptable.addCell(new Phrase("", font9));
            ptable.addCell(new Phrase("ISBN:", font9));
            ptable.addCell(new Phrase("Hall", font9));
            ptable.addCell(new Phrase("UPC Code:", font9));
            ptable.addCell(new Phrase("0789718103", font9));
            ptable.addCell(new Phrase("EAN #", font9));
            ptable.addCell(new Phrase("0786718103", font9));
            ptable.addCell(new Phrase("Price:", font9));
            ptable.addCell(new Phrase("49.99", font9));
            ptable.addCell(new Phrase("Page Count:", font9));
            ptable.addCell(new Phrase("500", font9));
            ptable.addCell(new Phrase("Discount:", font9));
            ptable.addCell(new Phrase("10%", font9));
            ptable.addCell(new Phrase("Trim Size:", font9));
            ptable.addCell(new Phrase("420x340", font9));
            ptable.addCell(new Phrase("Cover:", font9));
            ptable.addCell(new Phrase("Hard", font9));
            ptable.addCell(new Phrase("Interior Color:", font9));
            ptable.addCell(new Phrase("none", font9));
            ptable.addCell(new Phrase("Media with book:", font9));
            ptable.addCell(new Phrase("CD", font9));
            ptable.addCell(new Phrase("Author(s):", font9));
            ptable.addCell(new Phrase("Ben Forta", font9));
            ptable.addCell(new Phrase("Editor:", font9));
            ptable.addCell(new Phrase("Ben Forta", font9));
            ptable.addCell(new Phrase("Pub Date:", font9));
            ptable.addCell(new Phrase("06/05/1998", font9));
            ptable.setTotalWidth(columnWidth);

            currentY = ptable.writeSelectedRows(0, -1, document.left(), currentY, cb) - 20;
            for (int k = 0; k < headings.length; ++k) {
                ct.addText(new Chunk(headings[k] + "\n", font14B));
                ct.addText(new Chunk(texts[k] + "\n\n", font11));
            }

           
           
            int currentColumn = 0;
            ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
                allColumns[currentColumn] + columnWidth, currentY, 15, Element.ALIGN_JUSTIFIED);
            ct.setLeading(2, 1);
            for (;;) {
                int rc = ct.go();
                if ((rc & ColumnText.NO_MORE_TEXT) != 0)
                    break;
                // we run out of column. Let's go to another one
                ++currentColumn;
                if (currentColumn >= allColumns.length)
                    break;
                ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
                    allColumns[currentColumn] + columnWidth, topColumn, 15, Element.ALIGN_JUSTIFIED);
                ct.setLeading(2, 1);
            }
            // step 5: we close the document
            document.close();
        }
        catch (Exception de) {
View Full Code Here

            // get the stream content
            PdfContentByte cb = writer.getDirectContent();
            // headers
//            Phrase fullTitle = new Phrase("Full Title", font24B);
            float currentY = document.top();
            ColumnText ct = new ColumnText(cb);
//            ct.setSimpleColumn(fullTitle, document.left(), 0, document.right(), document.top(), 24, Element.ALIGN_JUSTIFIED);
//            ct.go();
//           
//           
//            currentY = ct.getYLine();
//            currentY -= 4;
//            cb.setLineWidth(1);
//            cb.moveTo(document.left(), currentY);
//            cb.lineTo(document.right(), currentY);
//            cb.stroke();
//           
//           
//            currentY -= 4;
//            ct.setYLine(currentY);
//            ct.addText(new Chunk("Author: Name of the author comes here", font10B));
//            ct.setLeading(10);
//            ct.go();
//            currentY = ct.getYLine();
//            currentY -= 15;

//            for (int k = 1; k < numColumns; ++k) {
//                float x = allColumns[k] - gutter / 2;
//                cb.moveTo(x, topColumn);
//                cb.lineTo(x, document.bottom());
//            }
//            cb.stroke();
//           
           
           
           
            Image img = Image.getInstance("c:\\lh.jpg");
            cb.addImage(img, img.getScaledWidth(), 0, 0, img.getScaledHeight(), document.left(), currentY - img.getScaledHeight());
            currentY -= img.getScaledHeight() + 10;
            ct.setYLine(currentY);
//            Chunk cc = new Chunk("DDD\n", font24B);
//            ct.addText(cc);
          Paragraph title1 = new Paragraph("Chapter 1", FontFactory.getFont(
            FontFactory.HELVETICA, 18, Font.BOLDITALIC,
            new Color(0, 0, 255)));
          title1.setAlignment(Paragraph.ALIGN_CENTER);
        ct.addElement(title1);
           
           
            ct.go();
            currentY = ct.getYLine();
            currentY -= 4;
   
           
           
//            PdfPTable ptable = new PdfPTable(2);
//            ptable.getDefaultCell().setPaddingLeft(4);
//            ptable.getDefaultCell().setPaddingTop(0);
//            ptable.getDefaultCell().setPaddingBottom(4);
//            ptable.addCell(new Phrase("Imprint Name:", font9));
//            ptable.addCell(new Phrase("Prentice Hall", font9));
//            ptable.addCell(new Phrase("Series Name:", font9));
//            ptable.addCell(new Phrase("", font9));
//            ptable.addCell(new Phrase("ISBN:", font9));
//            ptable.addCell(new Phrase("Hall", font9));
//            ptable.addCell(new Phrase("UPC Code:", font9));
//            ptable.addCell(new Phrase("0789718103", font9));
//            ptable.addCell(new Phrase("EAN #", font9));
//            ptable.addCell(new Phrase("0786718103", font9));
//            ptable.addCell(new Phrase("Price:", font9));
//            ptable.addCell(new Phrase("49.99", font9));
//            ptable.addCell(new Phrase("Page Count:", font9));
//            ptable.addCell(new Phrase("500", font9));
//            ptable.addCell(new Phrase("Discount:", font9));
//            ptable.addCell(new Phrase("10%", font9));
//            ptable.addCell(new Phrase("Trim Size:", font9));
//            ptable.addCell(new Phrase("420x340", font9));
//            ptable.addCell(new Phrase("Cover:", font9));
//            ptable.addCell(new Phrase("Hard", font9));
//            ptable.addCell(new Phrase("Interior Color:", font9));
//            ptable.addCell(new Phrase("none", font9));
//            ptable.addCell(new Phrase("Media with book:", font9));
//            ptable.addCell(new Phrase("CD", font9));
//            ptable.addCell(new Phrase("Author(s):", font9));
//            ptable.addCell(new Phrase("Ben Forta", font9));
//            ptable.addCell(new Phrase("Editor:", font9));
//            ptable.addCell(new Phrase("Ben Forta", font9));
//            ptable.addCell(new Phrase("Pub Date:", font9));
//            ptable.addCell(new Phrase("06/05/1998", font9));
//            ptable.setTotalWidth(columnWidth);

//            currentY = ptable.writeSelectedRows(0, -1, document.left(), currentY, cb) - 20;
            for (int k = 0; k < headings.length; ++k) {
                ct.addText(new Chunk(headings[k] + "\n", font14B));
                ct.addText(new Chunk(texts[k] + "\n\n", font11));
            }

           
           
            int currentColumn = 0;
            ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
                allColumns[currentColumn] + columnWidth, currentY, 15, Element.ALIGN_JUSTIFIED);
            ct.setLeading(2, 1);
            for (;;) {
                int rc = ct.go();
                if ((rc & ColumnText.NO_MORE_TEXT) != 0)
                    break;
                // we run out of column. Let's go to another one
                ++currentColumn;
                if (currentColumn >= allColumns.length)
                    break;
                ct.setSimpleColumn(allColumns[currentColumn], document.bottom(),
                    allColumns[currentColumn] + columnWidth, currentY, 15, Element.ALIGN_JUSTIFIED);
                ct.setLeading(2, 1);
            }
            // step 5: we close the document
            document.close();
        }
        catch (Exception de) {
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.ColumnText

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.