Package com.itextpdf.text

Examples of com.itextpdf.text.Paragraph


   */
  private void addAppendix_C_PersonsListedByBirthdayDayMonth() throws DocumentException {
    newPage();
    PersonListSort.sortByBirthdayDayMonth(persons);

    Paragraph paragraph = new Paragraph();
    Chunk chunk = new Chunk("Anhang C\r\n", fontHelvetica18Bold);
    Anchor anchor = new Anchor(chunk);
    anchor.setName("anhang-c");
    paragraph.add(anchor);
    document.add(paragraph);

    paragraph = new Paragraph();
    chunk =
      new Chunk("\r\n" + ANHANG_C_PERSONEN_SORTIERT_NACH_GEBURTSTAG_OHNE_JAHR + "\r\n", fontHelvetica18BoldItalic);
    paragraph.add(chunk);
    document.add(paragraph);

    int lastDay = Integer.MIN_VALUE + 2;
    int lastMonth = Integer.MIN_VALUE + 2;

    for (Person person : persons) {
      String birthday = person.getValue(Person.BIRTHDAY);
      int currDay = person.getBirthDay();
      int currMonth = person.getBirthMonth();
      int currYear = person.getBirthYear(false);
      if (currDay > 0 && currMonth > 0) {
        if (lastDay != currDay || lastMonth != currMonth) {
          paragraph = new Paragraph();
          lastDay = currDay;
          lastMonth = currMonth;
          String header = lastDay + ". " + Statics.months[lastMonth - 1];
          chunk = new Chunk("\r\n" + header + "\r\n", fontHelvetica12Bold);
          anchor = new Anchor(chunk);
          anchor.setName("dm-" + birthday.substring(0, birthday.lastIndexOf('.')));
          paragraph.add(anchor);
          document.add(paragraph);
        }
        paragraph = new Paragraph();
        String fullname = person.getValue(Person.NAME);
        if (createPrintVersion) {
          fullname += "  [" + (personsSorted.indexOf(person) + 1) + "]";
        }
        chunk = new Chunk(fullname, fontTimes12ItalicBlue);
        anchor = new Anchor(chunk);
        anchor.setReference("#p-" + person.getXREFID());
        paragraph.add(anchor);
        paragraph.add(new Chunk("  ("));
        anchor = new Anchor(new Chunk(Integer.toString(currYear)));
        anchor.setReference("#y-" + currYear);
        paragraph.add(anchor);
        paragraph.add(new Chunk(")"));
        document.add(paragraph);
      }
    }
  }
View Full Code Here


   * List all portraits of persons.
   */
  private void addAppendix_D_Images() throws DocumentException {
    newPage();

    Paragraph paragraph = new Paragraph();
    Chunk chunk = new Chunk("Anhang D\r\n", fontHelvetica18Bold);
    Anchor anchor = new Anchor(chunk);
    anchor.setName("anhang-d");
    paragraph.add(anchor);
    document.add(paragraph);

    paragraph = new Paragraph();
    chunk = new Chunk("\r\n" + ANHANG_D_BILDER + "\r\n", fontHelvetica18BoldItalic);
    paragraph.add(chunk);
    document.add(paragraph);

    if (!listImages_D.isEmpty()) {
      for (int i = 0; i < listImages_D.size(); i++) {
        if (i % 25 == 0) {
          if (i > 0) {
            newPage();
          }
          paragraph = new Paragraph();
          paragraph.add(new Chunk("\r\n"));
          document.add(paragraph);
        }
        Image image = listImages_D.get(i);
        Person person = listPersons_D.get(i);
        image.setBorderWidth(5);

        // Image anzeigen - dient gleichzeitig als Link und als Anchor.
        Chunk imageChunk = new Chunk(image, 0, 0, true);
        Anchor imageAnchor = new Anchor(imageChunk);
        imageAnchor.setName("anhang-d-" + i);
        imageAnchor.setReference("#p-" + person.getXREFID());
        document.add(imageAnchor);

        // Etwas Platz zum n�chsten Image lassen.
        document.add(new Phrase(" "));
      }
      document.add(new Paragraph());
    }
  }
View Full Code Here

   * Adds a new line to the currentParagraph.
   * @since 5.0.6
   */
  public void newLine() {
    if (currentParagraph == null) {
      currentParagraph = new Paragraph();
    }
    currentParagraph.add(createChunk("\n"));
  }
View Full Code Here

   * a new span.
   * @since 5.0.6
   */
  public void flushContent() {
    pushToStack(currentParagraph);
    currentParagraph = new Paragraph();
  }
View Full Code Here

   * Adds a link to the current paragraph.
   * @since 5.0.6
   */
  public void processLink() {
    if (currentParagraph == null) {
      currentParagraph = new Paragraph();
    }
    // The link provider allows you to do additional processing
    LinkProcessor i = (LinkProcessor) providers.get(HTMLWorker.LINK_PROVIDER);
    if (i == null || !i.process(currentParagraph, chain)) {
      // sets an Anchor for all the Chunks in the current paragraph
      String href = chain.getProperty(HtmlTags.HREF);
      if (href != null) {
        for (Chunk ck : currentParagraph.getChunks()) {
          ck.setAnchor(href);
        }
      }
    }
    // a link should be added to the current paragraph as a phrase
    if (stack.isEmpty()) {
      // no paragraph to add too, 'a' tag is first element
      Paragraph tmp = new Paragraph(new Phrase(currentParagraph));
      currentParagraph = tmp;
    } else {
      Paragraph tmp = (Paragraph) stack.pop();
      tmp.add(new Phrase(currentParagraph));
      currentParagraph = tmp;
    }
  }
View Full Code Here

   * of the different tags and properties in the hierarchy chain.
   * @param  chain  the hierarchy chain
   * @return  a Paragraph without any content
   */
  public Paragraph createParagraph(final ChainedProperties chain) {
    Paragraph paragraph = new Paragraph();
    updateElement(paragraph, chain);
    return paragraph;
  }
View Full Code Here

                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, Element.ALIGN_RIGHT);

                Image im = Image.getInstance(signatureGraphic);
                im.scaleToFit(signatureRect.getWidth(), signatureRect.getHeight());

                Paragraph p = new Paragraph();
                // must calculate the point to draw from to make image appear in middle of column
                float x = 0;
                // experimentation found this magic number to counteract Adobe's signature graphic, which
                // offsets the y co-ordinate by 15 units
                float y = -im.getScaledHeight() + 15;

                x = x + (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = y - (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x + (signatureRect.getWidth() - im.getScaledWidth()) / 2, y, false));
                ct2.addElement(p);
                ct2.go();
                break;
            case GRAPHIC:
                ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, Element.ALIGN_RIGHT);

                im = Image.getInstance(signatureGraphic);
                im.scaleToFit(signatureRect.getWidth(), signatureRect.getHeight());

                p = new Paragraph(signatureRect.getHeight());
                // must calculate the point to draw from to make image appear in middle of column
                x = (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x, y, false));
                ct2.addElement(p);
                ct2.go();
                break;
            default:
            }
View Full Code Here

            String url = FacesContext.getCurrentInstance().getExternalContext().getRealPath("resources/img/logo.PNG");
            Image image = Image.getInstance(url);
            document.add(image);

            document.addTitle("MTAMS - Application");
            document.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date()));

            /* Add PDF Content */
            pdfContent(document);
            document.close();

View Full Code Here

        document.add(new Phrase(""));
    }

    public void pdfContent(Document document) throws DocumentException {
        SimpleDateFormat df = new SimpleDateFormat("EEE d MMMM, yyyy", Locale.getDefault());
        document.add(new Paragraph("MTAMS - Application Details", bigFont));
        document.add(new Paragraph("Personal", mediumFont));
        newLine(document);

        /**
         * Personal Details
         */
        PdfPTable table = new PdfPTable(2); // 2 columns.

        ArrayList<PdfPCell> cellList = new ArrayList<PdfPCell>();
        cellList.add(new PdfPCell(new Phrase("Staff ID:")));
        cellList.add(new PdfPCell(new Phrase(this.profileRef.getStaffid())));
        cellList.add(new PdfPCell(new Phrase("Title:")));
        cellList.add(new PdfPCell(new Phrase(this.profileRef.getTitle())));
        cellList.add(new PdfPCell(new Phrase("Surname:")));
        cellList.add(new PdfPCell(new Phrase(this.profileRef.getFamilyname())));
        cellList.add(new PdfPCell(new Phrase("First Name:")));
        cellList.add(new PdfPCell(new Phrase(this.profileRef.getFirstname())));

        for (int i = 0; i < cellList.size(); i++) {
            if (i % 2 == 0) {
                cellList.get(i).setBorder(Rectangle.NO_BORDER);
            }
            table.addCell(cellList.get(i));
        }
        document.add(table);

        /**
         * Travel Details
         */
        table = new PdfPTable(2);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Travel", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("Application Name:")));
        cellList.add(new PdfPCell(new Phrase(this.appRef.getDescription())));
        cellList.add(new PdfPCell(new Phrase("Date of Initial Departure:")));
        cellList.add(new PdfPCell(new Phrase(df.format(this.travelRef.getDatedeparture()))));

        cellList.add(new PdfPCell(new Phrase("Date of Final Return:")));
        cellList.add(new PdfPCell(new Phrase(df.format(this.travelRef.getDatereturn()))));

        cellList.add(new PdfPCell(new Phrase("Purpose of Travel:")));
        cellList.add(new PdfPCell(new Phrase(this.travelRef.getDescription())));

        for (int i = 0; i < cellList.size(); i++) {
            if (i % 2 == 0) {
                cellList.get(i).setBorder(Rectangle.NO_BORDER);
            }
            table.addCell(cellList.get(i));
        }

        document.add(table);

        /**
         * Itinerary Details
         */
        table = new PdfPTable(4);
        table.setWidthPercentage(90f);
        table.setHeaderRows(1);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Itinerary", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("Date", bold)));
        cellList.add(new PdfPCell(new Phrase("Destination", bold)));
        cellList.add(new PdfPCell(new Phrase("Leave Type", bold)));
        cellList.add(new PdfPCell(new Phrase("Travel Day/ Work Day", bold)));


        for (Itinerary i : hops) {
            //cellList.add(new PdfPCell(new Phrase(df.format(i.getDate()))));
            cellList.add(new PdfPCell(new Phrase("BLANK")));
            cellList.add(new PdfPCell(new Phrase(i.getDestinationCity())));
            cellList.add(new PdfPCell(new Phrase(i.getLeavetype())));
            cellList.add(new PdfPCell(new Phrase(i.getTravelday())));
        }

        for (int i = 0; i < cellList.size(); i++) {
            table.addCell(cellList.get(i));
        }
        document.add(table);

        /**
         * Quote CostCenter
         */
        table = new PdfPTable(2);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Quotes", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("Cost Center:")));
        cellList.add(new PdfPCell(new Phrase(this.quoteRef.getCostcenter())));

        for (int i = 0; i < cellList.size(); i++) {
            if (i % 2 == 0) {
                cellList.get(i).setBorder(Rectangle.NO_BORDER);
            }
            table.addCell(cellList.get(i));
        }

        document.add(table);

        /**
         * Flight Quotes
         */
        table = new PdfPTable(4);
        table.setWidthPercentage(90f);
        table.setHeaderRows(1);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Flight Quotes", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("From", bold)));
        cellList.add(new PdfPCell(new Phrase("To", bold)));
        cellList.add(new PdfPCell(new Phrase("Airline", bold)));
        cellList.add(new PdfPCell(new Phrase("Cost Quoted", bold)));


        Flightquotes f = selectedFlgQte;
        cellList.add(new PdfPCell(new Phrase(f.getFlightfromCity())));
        cellList.add(new PdfPCell(new Phrase(f.getFlighttoCity())));
        cellList.add(new PdfPCell(new Phrase(f.getQuotesource())));
        cellList.add(new PdfPCell(new Phrase(f.getCurrency() + " " + f.getQuotecost().toString())));

        for (int i = 0; i < cellList.size(); i++) {
            table.addCell(cellList.get(i));
        }
        document.add(table);

        /**
         * Car Quotes
         */
        table = new PdfPTable(4);
        table.setWidthPercentage(90f);
        table.setHeaderRows(1);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Flight Quotes", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("Collect Date", bold)));
        cellList.add(new PdfPCell(new Phrase("Return Date", bold)));
        cellList.add(new PdfPCell(new Phrase("Rental Company", bold)));
        cellList.add(new PdfPCell(new Phrase("Cost Quoted", bold)));


        Carquotes c = selectedCarQte;
        cellList.add(new PdfPCell(new Phrase(df.format(c.getDatecollect()))));
        cellList.add(new PdfPCell(new Phrase(df.format(c.getDatereturn()))));
        cellList.add(new PdfPCell(new Phrase(c.getProvider())));
        cellList.add(new PdfPCell(new Phrase(c.getCurrency() + " " + c.getQuotecost().toString())));

        for (int i = 0; i < cellList.size(); i++) {
            table.addCell(cellList.get(i));
        }
        document.add(table);

        /**
         * Accommodation Quotes
         */
        table = new PdfPTable(5);
        table.setWidthPercentage(90f);
        table.setHeaderRows(1);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Accomodation Quotes", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("Location", bold)));
        cellList.add(new PdfPCell(new Phrase("Checkin Date", bold)));
        cellList.add(new PdfPCell(new Phrase("Checkout Date", bold)));
        cellList.add(new PdfPCell(new Phrase("Hotel", bold)));
        cellList.add(new PdfPCell(new Phrase("Cost Quoted", bold)));


        Accomodationquotes a = selectedAccQte;
        cellList.add(new PdfPCell(new Phrase(a.getCity())));
        cellList.add(new PdfPCell(new Phrase(df.format(a.getDatecheckin()))));
        cellList.add(new PdfPCell(new Phrase(df.format(a.getDatecheckout()))));
        cellList.add(new PdfPCell(new Phrase(a.getAccomodationprovider())));
        cellList.add(new PdfPCell(new Phrase(a.getCurrency() + " " + a.getQuotecost().toString())));

        for (int i = 0; i < cellList.size(); i++) {
            table.addCell(cellList.get(i));
        }
        document.add(table);

        /**
         * Approval Section
         */
        newLine(document);
        table = new PdfPTable(2);
        cellList = new ArrayList<PdfPCell>();
        newLine(document);
        document.add(new Paragraph("Approval", mediumFont));
        newLine(document);
        cellList.add(new PdfPCell(new Phrase("Approved:")));
        cellList.add(new PdfPCell(new Phrase(this.getApproved() == 1 ? "YES" : "NO")));
        cellList.add(new PdfPCell(new Phrase("Authorizer Name:")));
        cellList.add(new PdfPCell(new Phrase(this.getApprovalName())));
View Full Code Here

        String url = FacesContext.getCurrentInstance().getExternalContext().getRealPath("resources/img/logo.PNG");
        Image image = Image.getInstance(url);
        document.add(image);

        document.addTitle("MTAMS - Application");
        document.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date()));

        /* Add PDF Content */
        pdfContent(document);
        document.close();

View Full Code Here

TOP

Related Classes of com.itextpdf.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.