Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.ColumnText


   */
  public void draw()
  {
    TabSegment segment = segments.get(segmentIndex);
   
    ColumnText colText = new ColumnText(pdfContentByte);
    colText.setSimpleColumn(
      pdfExporter.getPhrase(segment.as, segment.text, text),
      x + leftPadding + drawPosX,
      pdfExporter.exporterContext.getExportedReport().getPageHeight()
        - y
        - topPadding
        - verticalAlignOffset
        //- text.getLeadingOffset()
        + lineHeight
        - drawPosY,
      x + leftPadding + drawPosX  + segment.layout.getAdvance(),
      pdfExporter.exporterContext.getExportedReport().getPageHeight()
        - y
        - topPadding
        - verticalAlignOffset
        //- text.getLeadingOffset()
        -400//+ lineHeight//FIXMETAB
        - drawPosY,
      0,//text.getLineSpacingFactor(),// * text.getFont().getSize(),
      horizontalAlignment
      );

    //colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());
    colText.setLeading(lineHeight);
    colText.setRunDirection(
      text.getRunDirectionValue() == RunDirectionEnum.LTR
      ? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_RTL
      );

    try
    {
      colText.go();
    }
    catch (DocumentException e)
    {
      throw new JRRuntimeException(e);
    }
View Full Code Here


   
    chunk.setLocalDestination(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1));

    tagHelper.startPageAnchor();
   
    ColumnText colText = new ColumnText(pdfContentByte);
    colText.setSimpleColumn(
      new Phrase(chunk),
      0,
      jasperPrint.getPageHeight(),
      1,
      1,
      0,
      Element.ALIGN_LEFT
      );

    colText.go();

    tagHelper.endPageAnchor();
  }
View Full Code Here

        setAnchor(chunk, printImage, printImage);
        setHyperlinkInfo(chunk, printImage);

        tagHelper.startImage(printImage);
       
        ColumnText colText = new ColumnText(pdfContentByte);
        int upperY = jasperPrint.getPageHeight() - printImage.getY() - topPadding - getOffsetY() - yoffset;
        int lowerX = printImage.getX() + leftPadding + getOffsetX() + xoffset;
        colText.setSimpleColumn(
          new Phrase(chunk),
          lowerX,
          upperY - scaledHeight,
          lowerX + scaledWidth,
          upperY,
          scaledHeight,
          Element.ALIGN_LEFT
          );

        colText.go();

        tagHelper.endImage();
      }
    }
View Full Code Here

    }

    public ColumnText reconfigure(PdfContentByte cb, Phrase p)
    {
      float filledWidth = ColumnText.getWidth(p, runDirection, 0) + 0.5f;
      ColumnText ct = new ColumnText(cb);
      ct.setRunDirection(runDirection);
      if (alignment == Element.ALIGN_LEFT)
      {
        ct.setSimpleColumn(llx, lly, llx + filledWidth, ury, leading, alignment);
      }
      else if (alignment == Element.ALIGN_RIGHT)
      {
        ct.setSimpleColumn(urx - filledWidth, lly, urx, ury, leading, alignment);
      }
      else if (alignment == Element.ALIGN_CENTER)
      {
        float delta = ((urx - llx) - filledWidth) / 2;
        ct.setSimpleColumn(urx + delta, lly, urx - delta, ury, leading, alignment);
      }
      else {
        ct.setSimpleColumn(llx, lly, urx, ury, leading, alignment);
      }
      return ct;
    }
View Full Code Here

      final Phrase p = createPhrase(node);
      final ColumnConfig cc = createColumnText(node);

      final PdfGraphics2D pg2 = (PdfGraphics2D) getGraphics();
      final PdfContentByte cb = pg2.getRawContentByte();
      ColumnText ct = cc.reconfigure(cb, p);
      ct.setText(p);
      if (ct.go(false) == ColumnText.NO_MORE_COLUMN)
      {
        throw new InvalidReportStateException
            ("iText signaled an error when printing text. Failing to prevent silent data-loss: Width=" +
            ct.getFilledWidth());
      }
    }
    catch (DocumentException e)
    {
      throw new InvalidReportStateException(e);
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);
            LwgPhrase ph = new LwgPhrase("Ungrouped objects\nObject opacity = 1.0");
            ct.setSimpleColumn(ph, gap, 0, gap + 200, 500, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            ph = new LwgPhrase("Ungrouped objects\nObject opacity = 0.5");
            ct.setSimpleColumn(ph, 200 + 2 * gap, 0, 200 + 2 * gap + 200, 500, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            ph = new LwgPhrase("Transparency group\nObject opacity = 1.0\nGroup opacity = 0.5\nBlend mode = Normal");
            ct.setSimpleColumn(ph, gap, 0, gap + 200, 500 - 200 - gap, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            ph = new LwgPhrase("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, LwgElement.ALIGN_CENTER);
            ct.go();
           
            cb.sanityCheck();
        }
        catch (Exception de) {
            de.printStackTrace();
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, LwgElement.ALIGN_CENTER);
            ct.go();
            cb.rectangle(103, 295, 52, 8 + 28 * 15);
            cb.stroke();
            ct.setSimpleColumn(characters, 105, 300, 150, 300 + 28 * 15, 15, LwgElement.ALIGN_RIGHT);
            ct.go();
            ct.setSimpleColumn(names, 160, 300, 500, 300 + 28 * 15, 15, LwgElement.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 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);
                }
View Full Code Here

            // get the stream content
            PdfContentByte cb = writer.getDirectContent();
            // headers
            LwgPhrase fullTitle = new LwgPhrase("Full Title", font24B);
            float currentY = document.top();
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(fullTitle, document.left(), 0, document.right(), document.top(), 24, LwgElement.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();
            LwgImage img = LwgImage.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;
            LwgPdfPTable ptable = new LwgPdfPTable(2);
            ptable.getDefaultCell().setPaddingLeft(4);
            ptable.getDefaultCell().setPaddingTop(0);
            ptable.getDefaultCell().setPaddingBottom(4);
            ptable.add(new LwgPhrase("Imprint Name:", font9));
            ptable.add(new LwgPhrase("Prentice Hall", font9));
            ptable.add(new LwgPhrase("Series Name:", font9));
            ptable.add(new LwgPhrase("", font9));
            ptable.add(new LwgPhrase("ISBN:", font9));
            ptable.add(new LwgPhrase("Hall", font9));
            ptable.add(new LwgPhrase("UPC Code:", font9));
            ptable.add(new LwgPhrase("0789718103", font9));
            ptable.add(new LwgPhrase("EAN #", font9));
            ptable.add(new LwgPhrase("0786718103", font9));
            ptable.add(new LwgPhrase("Price:", font9));
            ptable.add(new LwgPhrase("49.99", font9));
            ptable.add(new LwgPhrase("Page Count:", font9));
            ptable.add(new LwgPhrase("500", font9));
            ptable.add(new LwgPhrase("Discount:", font9));
            ptable.add(new LwgPhrase("10%", font9));
            ptable.add(new LwgPhrase("Trim Size:", font9));
            ptable.add(new LwgPhrase("420x340", font9));
            ptable.add(new LwgPhrase("Cover:", font9));
            ptable.add(new LwgPhrase("Hard", font9));
            ptable.add(new LwgPhrase("Interior Color:", font9));
            ptable.add(new LwgPhrase("none", font9));
            ptable.add(new LwgPhrase("Media with book:", font9));
            ptable.add(new LwgPhrase("CD", font9));
            ptable.add(new LwgPhrase("Author(s):", font9));
            ptable.add(new LwgPhrase("Ben Forta", font9));
            ptable.add(new LwgPhrase("Editor:", font9));
            ptable.add(new LwgPhrase("Ben Forta", font9));
            ptable.add(new LwgPhrase("Pub Date:", font9));
            ptable.add(new LwgPhrase("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, LwgElement.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, LwgElement.ALIGN_JUSTIFIED);
                ct.setLeading(2, 1);
            }
            // step 5: we close the document
            document.close();
        }
        catch (Exception de) {
View Full Code Here

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