Example usage for com.itextpdf.text Paragraph add

List of usage examples for com.itextpdf.text Paragraph add

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph add.

Prototype

@Override
public boolean add(Element o) 

Source Link

Document

Adds an Element to the Paragraph.

Usage

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.MultiStateOffenderLetterFC.java

private static void writePdf(TrackingRecordScreeningLetter screeningLetter, OutputStream ba,
        HttpServletRequest request) throws DocumentException, BadElementException, IOException {
    Document document = null;//from ww  w . ja v a 2 s.com
    Paragraph paragraph = null;
    ListItem item = null;
    document = new Document(PageSize.LETTER, 50, 50, 125, 0);
    PdfWriter writer = PdfWriter.getInstance(document, ba);
    StringBuilder sb = null;
    SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy");

    document.open();

    LetterheadStamper.stampLetter(writer, request);

    paragraph = getParagraph(10.0f);
    paragraph.add(new Phrase("MSO FC", smallfont));
    paragraph.setIndentationLeft(415);
    document.add(paragraph);
    paragraph.clear();
    paragraph.add(new Phrase("Rev 3/12", smallfont));
    paragraph.setSpacingAfter(50);
    document.add(paragraph);

    // Add report date
    paragraph = getParagraph();
    paragraph.add(new Phrase(df.format(screeningLetter.getLetterDate()), mediumfont));
    paragraph.setIndentationLeft(350);
    document.add(paragraph);

    // Add applicant name and address information
    paragraph = getParagraph();
    paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName().toUpperCase(),
            mediumfont));
    paragraph.setSpacingBefore(5);
    document.add(paragraph);
    if (StringUtils.isNotBlank(screeningLetter.getAddress().getAddressOne())) {
        paragraph = getParagraph();
        paragraph.add(new Phrase(screeningLetter.getAddress().getAddressOne().toUpperCase(), mediumfont));
        document.add(paragraph);
    }
    if (StringUtils.isNotBlank(screeningLetter.getAddress().getAddressTwo())) {
        // Add facility location address two
        paragraph = getParagraph();
        paragraph.add(new Phrase(screeningLetter.getAddress().getAddressTwo().toUpperCase(), mediumfont));
        document.add(paragraph);
    }
    if (StringUtils.isNotBlank(screeningLetter.getAddress().getCityStateZip())) {
        paragraph = getParagraph();
        paragraph.add(new Phrase(screeningLetter.getAddress().getCityStateZip().toUpperCase(), mediumfont));
        document.add(paragraph);
    }

    // Add subject information
    paragraph = getParagraph();
    paragraph.add(new Phrase("RE: Notice of additional Criminal Background Screening information needed:",
            mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    // Add Screening Person's Name/ID
    paragraph = getParagraph(16.0f);
    paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName() + " ("
            + screeningLetter.getTrackingRecordScreening().getPersonIdentifier() + ")", mediumfont));
    // Indent this line to line up with 'Notice' in subject line
    paragraph.setIndentationLeft(22);
    document.add(paragraph);

    // Add salutation
    paragraph = getParagraph();
    paragraph.add(new Phrase("Dear " + screeningLetter.getTrackingRecordScreening().getFirstAndLastName() + ":",
            mediumfont));
    paragraph.setSpacingBefore(18);
    document.add(paragraph);

    // Start letter detail
    sb = new StringBuilder();
    sb.append(
            "As a follow-up to the request for background screening by the Department of Human Services, Office of Licensing, ");
    sb.append("this is to notify you that additional criminal background screening information is needed.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = getParagraph();
    paragraph.add(new Phrase(
            "Enclosed are two fingerprint cards for you to provide complete, accurate and legible identifying information. ",
            mediumfont));
    paragraph.add(new Phrase("Return the completed fingerprint cards with a $36.50 fee in the form of a ",
            mediumfont));
    paragraph.add(new Phrase("cashier's check or money order ", mediumfontI));
    paragraph.add(new Phrase("(no personal checks) payable to the ", mediumfont));
    paragraph.add(new Phrase("Department of Human Resources, ", mediumfontI));
    paragraph.add(new Phrase(
            "to the Office of Licensing within 15 calendar days of your receipt of this notice.", mediumfont));
    paragraph.setSpacingBefore(10);
    paragraph.setSpacingAfter(10);
    document.add(paragraph);

    // Add the fingerprint card procedures as an indented bullet list
    List procedure = new List(false, 10);
    procedure.setIndentationLeft(10);
    item = getListItem();
    item.add(new Phrase(
            "Prints should be taken by a local law enforcement office, or an agency approved by law enforcement.",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase("The FBI will reject a card with any highlighting.", mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "Use only these cards showing identification from the Office of Licensing. We will be glad to give you replacement cards if requested.",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    procedure.add(new Phrase(
            "If mailing the cards back to us, return by regular mail (please do not fold the cards).",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "Fingerprint cards must be completely filled out or they will be returned for completion.",
            mediumfont));
    procedure.add(item);
    document.add(procedure);

    sb = new StringBuilder();
    sb.append(
            "Failure to return the completed fingerprint cards and fee within 15 calendar days will result in your background screening ");
    sb.append(
            "application being denied, and you will not be eligible to be associated with the licensed program in any capacity ");
    sb.append(
            "or will not be eligible to proceed with foster care or adoption until all clearance procedures are completed.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    sb = new StringBuilder();
    sb.append(
            "Please allow up to 12 weeks for the completion of the clearance process. For assistance or inquiries, you can contact the Office of Licensing ");
    sb.append("at (801) 538-4242.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = getParagraph();
    paragraph.add(new Phrase("Sincerely,", mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = getParagraph();
    paragraph.add(new Phrase(screeningLetter.getCreatedBy().getFirstAndLastName(), mediumfont));
    paragraph.setSpacingBefore(25);
    document.add(paragraph);

    paragraph = getParagraph();
    paragraph.add(new Phrase("Background Screening Unit", mediumfont));
    document.add(paragraph);

    if (screeningLetter.getTrackingRecordScreening() != null
            && screeningLetter.getTrackingRecordScreening().getFacility() != null
            && screeningLetter.getTrackingRecordScreening().getFacility().getLicensingSpecialist() != null
            && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility()
                    .getLicensingSpecialist().getIntials())) {
        paragraph = getParagraph();
        paragraph.add(new Phrase("CC: " + screeningLetter.getTrackingRecordScreening().getFacility()
                .getLicensingSpecialist().getIntials(), mediumfont));
        paragraph.setSpacingBefore(10);
        document.add(paragraph);
    }

    document.close();
}

From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.MultiStateOffenderLetterTX.java

private static void writePdf(TrackingRecordScreeningLetter screeningLetter, OutputStream ba,
        HttpServletRequest request) throws DocumentException, BadElementException, IOException {
    Document document = null;//ww w  . j a v a 2 s.  c o  m
    Paragraph paragraph = null;
    ListItem item = null;
    document = new Document(PageSize.LETTER, 50, 50, 125, 0);
    PdfWriter writer = PdfWriter.getInstance(document, ba);
    StringBuilder sb = null;
    SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy");

    document.open();

    LetterheadStamper.stampLetter(writer, request);

    paragraph = getParagraph(10.0f);
    paragraph.add(new Phrase("MSO TX", smallfont));
    paragraph.setIndentationLeft(415);
    document.add(paragraph);
    paragraph.clear();
    paragraph.add(new Phrase("Rev 3/12", smallfont));
    paragraph.setSpacingAfter(50);
    document.add(paragraph);

    // Add report date
    paragraph = getParagraph();
    paragraph.add(new Phrase(df.format(screeningLetter.getLetterDate()), mediumfont));
    paragraph.setIndentationLeft(350);
    document.add(paragraph);

    // Add facility name and address information
    paragraph = getParagraph();
    paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getName().toUpperCase(),
            mediumfont));
    paragraph.setSpacingBefore(5);
    document.add(paragraph);
    if (screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress() != null) {
        if (StringUtils.isNotBlank(
                screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getAddressOne())) {
            paragraph = getParagraph();
            paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress()
                    .getAddressOne().toUpperCase(), mediumfont));
            document.add(paragraph);
        }
        if (StringUtils.isNotBlank(
                screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getAddressTwo())) {
            // Add facility location address two
            paragraph = getParagraph();
            paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress()
                    .getAddressTwo().toUpperCase(), mediumfont));
            document.add(paragraph);
        }
        if (StringUtils.isNotBlank(
                screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getCityStateZip())) {
            paragraph = getParagraph();
            paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress()
                    .getCityStateZip().toUpperCase(), mediumfont));
            document.add(paragraph);
        }
    }

    // Add subject information
    paragraph = getParagraph();
    paragraph.add(new Phrase("RE: Notice of additional Criminal Background Screening information needed:",
            mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    // Add Screening Person's Name/ID
    sb = new StringBuilder();
    paragraph = getParagraph(16.0f);
    paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName() + " ("
            + screeningLetter.getTrackingRecordScreening().getPersonIdentifier() + ")", mediumfont));
    // Indent this line to line up with 'Notice' in subject line
    paragraph.setIndentationLeft(22);
    document.add(paragraph);

    // Add salutation
    paragraph = getParagraph();
    paragraph.add(new Phrase("Dear Director:", mediumfont));
    paragraph.setSpacingBefore(18);
    document.add(paragraph);

    // Start letter detail
    sb = new StringBuilder();
    sb.append(
            "As a follow-up to the request for background screening by the Department of Human Services, Office of Licensing, ");
    sb.append("this is to notify you that additional criminal background screening information is needed.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = getParagraph();
    paragraph.add(new Phrase(
            "Enclosed are two fingerprint cards for the applicant to provide complete, accurate and legible identifying information. ",
            mediumfont));
    paragraph.add(new Phrase("Return the completed fingerprint cards with a $36.50 fee in the form of a ",
            mediumfont));
    paragraph.add(new Phrase("cashier's check or money order ", mediumfontI));
    paragraph.add(new Phrase("(no personal checks) payable to the ", mediumfont));
    paragraph.add(new Phrase("Department of Human Resources, ", mediumfontI));
    paragraph.add(new Phrase(
            "to the Office of Licensing within 15 calendar days of your receipt of this notice. Do not put multiple fingerprints ",
            mediumfont));
    paragraph.add(new Phrase("with one payment, unless for a couple with the same last name.", mediumfont));
    paragraph.setSpacingBefore(10);
    paragraph.setSpacingAfter(10);
    document.add(paragraph);

    // Add the fingerprint card procedures as an indented bullet list
    List procedure = new List(false, 10);
    procedure.setIndentationLeft(22);
    item = getListItem();
    item.add(new Phrase(
            "Prints should be taken by a local law enforcement office, or an agency approved by law enforcement.",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase("The FBI will reject a card with any highlighting.", mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "Use only these cards showing identification from the Office of Licensing. We will be glad to give you replacement cards if requested.",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "If mailing the cards back to us, return by regular mail (please do not fold the cards).",
            mediumfont));
    procedure.add(item);
    item = getListItem();
    item.add(new Phrase(
            "Fingerprint cards must be completely filled out or they will be returned for completion.",
            mediumfont));
    procedure.add(item);
    document.add(procedure);

    sb = new StringBuilder();
    sb.append(
            "Failure to return the completed fingerprint cards and fee within 15 calendar days will result in the background screening ");
    sb.append(
            "application being denied, and the applicant will not be eligible to be associated with the licensed program in any capacity ");
    sb.append(
            "or will not be eligible to proceed with foster care or adoption until all clearance procedures are completed.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    sb = new StringBuilder();
    sb.append(
            "Please allow up to 12 weeks for the completion of the clearance process. For assistance or inquiries, please contact the Office of Licensing ");
    sb.append("at (801) 538-4242.");
    paragraph = getParagraph();
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = new Paragraph();
    paragraph.add(new Phrase("Sincerely,", mediumfont));
    paragraph.setSpacingBefore(10);
    document.add(paragraph);

    paragraph = new Paragraph();
    paragraph.add(new Phrase(screeningLetter.getCreatedBy().getFirstAndLastName(), mediumfont));
    paragraph.setSpacingBefore(25);
    document.add(paragraph);

    paragraph = new Paragraph();
    paragraph.add(new Phrase("Background Screening Unit", mediumfont));
    document.add(paragraph);

    document.close();
}

From source file:gov.utah.dts.det.ccl.documents.reporting.reports.TopFindingsReport.java

@Override
public void render(Map<String, Object> context, OutputStream outputStream, FileDescriptor fileDescriptor)
        throws TemplateException {
    List<Object[]> results = getResults(context);

    setFileName(context, fileDescriptor);

    Document document = new Document(PAGE_SIZE, 36, 36, 36, 36);
    try {//from  www.  ja v  a2  s .  com
        PdfWriter.getInstance(document, outputStream);
        document.open();

        StringBuilder sb = new StringBuilder((String) context.get(LICENSE_TYPE_KEY));
        sb.append(" Top Findings Report");
        Paragraph heading = new Paragraph(sb.toString(), HEADING_FONT);
        heading.setAlignment(Element.ALIGN_CENTER);
        document.add(heading);

        Date startDate = (Date) context.get(DATE_RANGE_START_KEY);
        Date endDate = (Date) context.get(DATE_RANGE_END_KEY);
        ReportType reportType = ReportType.valueOf((String) context.get(REPORT_TYPE_KEY));

        clearStringBuilder(sb);
        sb.append(DATE_FORMATTER.format(startDate));
        sb.append(" - ");
        sb.append(DATE_FORMATTER.format(endDate));

        Paragraph date = new Paragraph(sb.toString(), FONT);
        date.setAlignment(Element.ALIGN_RIGHT);
        document.add(date);

        PdfPTable table = new PdfPTable(2);
        table.setHeaderRows(1);
        table.setSpacingBefore(FONT_SIZE);
        table.setWidthPercentage(100f);
        table.setWidths(new float[] { 80f, 20f });
        setDefaultCellAttributes(table.getDefaultCell());

        table.addCell(getHeaderCell("Rule Number"));
        table.addCell(getHeaderCell(reportType.getLabel()));

        double total = 0;
        for (Iterator<Object[]> itr = results.iterator(); itr.hasNext();) {
            Object[] row = itr.next();
            Paragraph p = new Paragraph();
            p.add(new Paragraph((String) row[0], TABLE_HEADER_FONT));
            p.add(new Paragraph((String) row[1], FONT));
            table.addCell(p);
            double rowTotal = ((BigDecimal) row[2]).doubleValue();
            total += rowTotal;
            if (reportType == ReportType.CMP_AMOUNT) {
                PdfPCell cell = getCurrencyCell(CURRENCY_FORMATTER.format(rowTotal));
                table.addCell(cell);
            } else {
                table.addCell(getNumberCell(Integer.toString((int) rowTotal)));
            }
        }

        PdfPCell totCell = getHeaderCell("Total");
        totCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(totCell);

        if (reportType == ReportType.CMP_AMOUNT) {
            PdfPCell cell = getHeaderCell(CURRENCY_FORMATTER.format(total));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        } else {
            PdfPCell cell = getHeaderCell(Integer.toString((int) total));
            table.addCell(cell);
        }

        document.add(table);
    } catch (DocumentException de) {
        throw new TemplateException(de);
    }
    document.close();
}

From source file:grupoj.entregajsf.toPDF.PdfCreator.java

private static void addEvent(Document doc, Evento ev) throws DocumentException {
    doc.addTitle(ev.getNombre());//from   w w  w.j  a  va2 s .  c  o  m
    Paragraph evento = new Paragraph();
    evento.add(new Paragraph(ev.getNombre(), catFont));
    evento.add(new Paragraph(" "));
    evento.add(new Paragraph(ev.getDescripcion(), subFont));
    evento.add(new Paragraph(" "));
    evento.add(new Paragraph(
            "Fecha de inicio: " + new SimpleDateFormat("dd/MM/yyyy-HH:mm").format(ev.getFecha_inicio()),
            subFont));
    evento.add(new Paragraph(
            "Fecha de fin:" + new SimpleDateFormat("dd/MM/yyyy-HH:mm").format(ev.getFecha_fin()), subFont));
    evento.add(new Paragraph(" "));
    evento.add(new Paragraph(ev.getDonde_comprar(), smallBold));
    evento.add(new Paragraph(" "));
    doc.add(evento);
}

From source file:GUI.Carburant.java

private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);/* ww  w  .ja va2  s .co m*/
    // Lets write a big header
    preface.add(new Paragraph("Carburant", catFont));

    addEmptyLine(preface, 1);

    preface.add(new Paragraph(
            "Report generated by: " + System.getProperty("Car Fleet Management App") + ", " + new Date(),
            smallBold));
    addEmptyLine(preface, 3);

    preface.add(new Paragraph("Carburant details ", smallBold));

    int rowNumber = this.tableJT.getSelectedRow();

    // immatriculation
    preface.add(new Paragraph("Numero de souche : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 0).toString(), smallBold));

    //marque
    preface.add(new Paragraph("Immatriculation : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 1).toString(), smallBold));

    //etat
    preface.add(new Paragraph("Prix de bon : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 4).toString(), smallBold));

    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Thank you for using Car Fleet Management App", smallBold));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:GUI.Cars.java

private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);//from   w  w w.  j a  va2s. c  om
    // Lets write a big header
    preface.add(new Paragraph("Cars", catFont));

    addEmptyLine(preface, 1);

    preface.add(new Paragraph(
            "Report generated by: " + System.getProperty("Car Fleet Management App") + ", " + new Date(),
            smallBold));
    addEmptyLine(preface, 3);

    preface.add(new Paragraph("Car details ", smallBold));

    int rowNumber = this.tableJT.getSelectedRow();

    // immatriculation
    preface.add(new Paragraph("Immatriculation : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 0).toString(), smallBold));

    //marque
    preface.add(new Paragraph("Marque : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 2).toString(), smallBold));

    //etat
    preface.add(new Paragraph("Etat : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 9).toString(), smallBold));

    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Thank you for using Car Fleet Management App", smallBold));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:GUI.Fixings.java

private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);// www .  j  a  v a 2  s .  c o  m
    // Lets write a big header
    preface.add(new Paragraph("Fixing", catFont));

    addEmptyLine(preface, 1);

    preface.add(new Paragraph(
            "Report generated by: " + System.getProperty("Car Fleet Management App") + ", " + new Date(),
            smallBold));
    addEmptyLine(preface, 3);

    preface.add(new Paragraph("Fixing details ", smallBold));

    int rowNumber = this.tableJT.getSelectedRow();

    // immatriculation
    preface.add(new Paragraph("Numero de souche : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 0).toString(), smallBold));

    //marque
    preface.add(new Paragraph("Fournisseur : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 1).toString(), smallBold));

    //etat
    preface.add(new Paragraph("Immatriculation : ", redFont));
    preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 3).toString(), smallBold));

    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Thank you for using Car Fleet Management App", smallBold));

    document.add(preface);
    // Start a new page
    document.newPage();
}

From source file:GUI.GestionProjects.java

private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
    String IMAGE1 = lblPathImage.getText();
    Font red = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.RED);
    Chunk redText = new Chunk("Les information relatif au Projet : ", red);
    Font blue = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.BLUE);

    Document document = new Document();
    java.util.Date utilStartDate = jdateDeadLine.getDate();
    java.sql.Date sqlStartDate = new java.sql.Date(utilStartDate.getTime());
    try {/*  w  w w .  jav a2  s  .c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("Report.pdf"));
        document.open();

        Paragraph p1 = new Paragraph();
        p1.add(redText);
        p1.add(txtTitreProjet.getText());

        Chunk txtdesc = new Chunk("Decription du Projet: ", red);
        Paragraph p2 = new Paragraph();
        p2.add(txtdesc);
        p2.add(txtDescriptionProjet.getText());

        Chunk txtcat = new Chunk("Catgorie du Projet: ", red);
        Paragraph p3 = new Paragraph();
        p3.add(txtcat);
        p3.add(combo_Cat.getSelectedItem().toString());

        Chunk txtfin = new Chunk("Mode de finnancement du Projet: ", red);
        Paragraph p4 = new Paragraph();
        p4.add(txtfin);
        p4.add(ComboFinnancementProjet.getSelectedItem().toString());

        Chunk txtdate = new Chunk("Date DeadLine Projet: ", red);
        Paragraph p5 = new Paragraph();
        p5.add(txtdate);
        p5.add(sqlStartDate.toString());

        p1.setSpacingAfter(25);
        p1.setSpacingBefore(25);
        p1.setAlignment(Element.ALIGN_CENTER);
        p1.setIndentationLeft(50);
        p1.setIndentationRight(50);

        document.add(p1);
        document.add(p2);
        document.add(p3);
        document.add(p4);
        document.add(p5);

        if (Desktop.isDesktopSupported()) {
            try {
                File myFile = new File("Report.pdf");
                Desktop.getDesktop().open(myFile);
            } catch (IOException ex) {
                // no application registered for PDFs
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    document.close();
    // TODO add your handling code here:
}

From source file:GUI_Apoteker.Panel_Detil_PO.java

private Paragraph getPreface(String status) {
    Paragraph preface = new Paragraph();
    Calendar cal = new GregorianCalendar();
    String tanggal = "0";
    if (cal.get(Calendar.DATE) < 0) {
        tanggal = "0" + cal.get(Calendar.DATE);
    } else {/*www. j a  v a  2  s .c om*/
        tanggal = "" + cal.get(Calendar.DATE);
    }
    int bulan = (cal.get(Calendar.MONTH)) + 1;
    ;
    int tahun = cal.get(Calendar.YEAR);
    preface.setAlignment(Element.ALIGN_CENTER);

    Chunk chunk = new Chunk("Laporan Pemesanan Obat dengan ID - PO" + po.getId_Pemesanan_obat(), font1);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    chunk = new Chunk("Apotek 'SI-KLINIK'", font2);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    chunk = new Chunk("Tanggal : " + po.getTgl_Pemesanan(), font3);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    chunk = new Chunk("Nama Supplier : " + po.getNama_supplier(), font5);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    return preface;
}

From source file:GUI_StafKlinik.Panel_Laporan_Keuangan.java

private Paragraph getPreface(String status) {
    Paragraph preface = new Paragraph();
    Calendar cal = new GregorianCalendar();
    String tanggal = "0";
    if (cal.get(Calendar.DATE) < 0) {
        tanggal = "0" + cal.get(Calendar.DATE);
    } else {/*from  w  ww.j  a v a 2s. com*/
        tanggal = "" + cal.get(Calendar.DATE);
    }
    int bulan = (cal.get(Calendar.MONTH)) + 1;
    ;
    int tahun = cal.get(Calendar.YEAR);
    preface.setAlignment(Element.ALIGN_CENTER);
    Chunk chunk = new Chunk("Laporan Keuangan", font1);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    chunk = new Chunk("SI Klinik", font2);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    chunk = new Chunk("Periode : " + tanggal1 + " s/d " + tanggal2, font3);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    chunk = new Chunk("Diambil pada tanggal " + tanggal + "/" + bulan + "/" + tahun, font5);
    preface.add(Chunk.NEWLINE);
    preface.add(chunk);
    return preface;
}