Example usage for com.lowagie.text Paragraph Paragraph

List of usage examples for com.lowagie.text Paragraph Paragraph

Introduction

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

Prototype

public Paragraph(float leading, String string) 

Source Link

Document

Constructs a Paragraph with a certain String and a certain leading.

Usage

From source file:com.stratelia.webactiv.almanach.control.AlmanachPdfGenerator.java

License:Open Source License

private static void generateAlmanach(Chapter chapter, AlmanachSessionController almanach,
        List<DisplayableEventOccurrence> occurrences, String mode) throws AlmanachException {

    boolean monthScope = AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
            || AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode);
    boolean yearScope = AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode);

    int currentDay = -1;
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(almanach.getCurrentDay());
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    int currentMonth = calendar.get(Calendar.MONTH);
    int currentYear = calendar.get(Calendar.YEAR);

    if (yearScope) {
        // start from begin of current year
        calendar.set(Calendar.MONTH, 0);
    }/*  ww  w .  j  a  va 2 s. c  om*/

    // for each day of the current month
    while ((monthScope && currentMonth == calendar.get(Calendar.MONTH))
            || (yearScope && currentYear == calendar.get(Calendar.YEAR))) {
        Section section = null;
        if (AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode)) {
            section = chapter.addSection(generateParagraph(calendar, almanach), 0);
        }

        Font titleTextFont = new Font(Font.BOLD, 12, Font.SYMBOL, new Color(0, 0, 0));

        // get the events of the current day
        for (DisplayableEventOccurrence occurrence : occurrences) {
            EventDetail event = occurrence.getEventDetail();
            String theDay = DateUtil.date2SQLDate(calendar.getTime());
            String startDay = DateUtil.date2SQLDate(occurrence.getStartDate().asDate());
            String startHour = event.getStartHour();
            String endHour = event.getEndHour();

            if (startDay.compareTo(theDay) > 0) {
                continue;
            }

            String endDay = startDay;
            if (event.getEndDate() != null) {
                endDay = DateUtil.date2SQLDate(occurrence.getEndDate().asDate());
            }

            if (endDay.compareTo(theDay) < 0) {
                continue;
            }

            if (calendar.get(Calendar.DAY_OF_MONTH) != currentDay) {
                if (AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
                        || AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode)) {
                    section = chapter.addSection(generateParagraph(calendar, almanach), 0);
                }
                currentDay = calendar.get(Calendar.DAY_OF_MONTH);
            }

            Font textFont;
            if (event.getPriority() == 0) {
                textFont = new Font(Font.HELVETICA, 10, Font.NORMAL, new Color(0, 0, 0));
            } else {
                textFont = new Font(Font.HELVETICA, 10, Font.BOLD, new Color(0, 0, 0));
            }

            String eventTitle = event.getTitle();
            if (startDay.compareTo(theDay) == 0 && startHour != null && startHour.length() != 0) {
                eventTitle += " (" + startHour;
                if (endDay.compareTo(theDay) == 0 && endHour != null && endHour.length() != 0) {
                    eventTitle += "-" + endHour;
                }
                eventTitle += ")";
            }

            section.add(new Paragraph(eventTitle, titleTextFont));
            if (StringUtil.isDefined(event.getPlace())) {
                section.add(new Paragraph(event.getPlace(), titleTextFont));
            }
            if (StringUtil.isDefined(event.getDescription(almanach.getLanguage()))) {
                section.add(new Paragraph(event.getDescription(almanach.getLanguage()), textFont));
            }
            section.add(new Paragraph("\n"));

        } // end for
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
}

From source file:com.stratelia.webactiv.almanach.control.AlmanachPdfGenerator.java

License:Open Source License

private static Paragraph generateParagraph(Calendar calendar, AlmanachSessionController almanach) {
    Font dateFont = new Font(Font.HELVETICA, 14, Font.NORMAL, new Color(0, 0, 255));
    Paragraph dateSection = new Paragraph(almanach.getString("GML.jour" + calendar.get(Calendar.DAY_OF_WEEK))
            + " " + calendar.get(Calendar.DAY_OF_MONTH) + " "
            + almanach.getString("GML.mois" + calendar.get(Calendar.MONTH)) + " " + calendar.get(Calendar.YEAR),
            dateFont);/*from ww  w  .j a va2 s.c  om*/
    return dateSection;
}

From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java

License:Open Source License

/**
 * Method declaration/*  w w w  .  j  a  v  a 2  s  .  c  om*/
 * @param name
 * @param completePubList
 * @param langue
 * @throws NewsEditoException
 * @see
 */
public static void generatePubList(String name, Collection<CompletePublication> completePubList, String langue)
        throws NewsEditoException {
    SilverTrace.info("NewsEdito", "PdfGenerator.generatePubList", "NewsEdito.MSG_ENTRY_METHOD",
            "Pdf name = " + name);
    try {
        CompletePublication first = completePubList.iterator().next();
        String fileName = FileRepositoryManager.getTemporaryPath(
                first.getPublicationDetail().getPK().getSpace(),
                first.getPublicationDetail().getPK().getComponentName()) + name;
        ResourceLocator message = new ResourceLocator(
                "com.stratelia.webactiv.newsEdito.multilang.newsEditoBundle", langue);
        // creation of the document with a certain size and certain margins
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);

        // we add some meta information to the document
        document.addAuthor("Generateur de PDF Silverpeas");
        document.addSubject("Compilation de publications Silverpeas");
        document.addCreationDate();

        PdfWriter.getInstance(document, new FileOutputStream(fileName));
        document.open();

        createFirstPage(document, langue);

        HeaderFooter header = new HeaderFooter(new Phrase(message.getString("publicationCompilation")), false);
        HeaderFooter footer = new HeaderFooter(new Phrase("Page "), new Phrase("."));

        footer.setAlignment(Element.ALIGN_CENTER);

        document.setHeader(header);
        document.setFooter(footer);

        document.newPage();

        Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255));
        Paragraph cTitle = new Paragraph(message.getString("listPublication"), titleFont);
        Chapter chapter = new Chapter(cTitle, 1);

        Iterator<CompletePublication> i = completePubList.iterator();
        CompletePublication complete = null;
        while (i.hasNext()) {
            complete = i.next();

            addPublication(chapter, complete);
        }

        document.add(chapter);

        document.close();
    } catch (Exception e) {
        throw new NewsEditoException("PdfGenerator.generatePubList", NewsEditoException.WARNING,
                "NewsEdito.EX_PROBLEM_TO_GENERATE_PUBLI_LIST", e);
    }
}

From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java

License:Open Source License

/**
 * Method declaration//from   ww w. j  av  a 2  s .  com
 * @param document
 * @param langue
 * @throws NewsEditoException
 * @see
 */
public static void createFirstPage(Document document, String langue) throws NewsEditoException {
    try {
        ResourceLocator message = new ResourceLocator(
                "com.stratelia.webactiv.newsEdito.multilang.newsEditoBundle", langue);

        Font masterFont = new Font(Font.HELVETICA, 40, Font.BOLD, new Color(0, 0, 0));
        Paragraph masterTitle = new Paragraph("\n\n\n\n" + message.getString("journalEditorial"), masterFont);

        masterTitle.setAlignment(Element.ALIGN_CENTER);

        Font secondFont = new Font(Font.HELVETICA, 20, Font.NORMAL, new Color(0, 0, 0));
        Paragraph secondTitle = new Paragraph(
                message.getString("editeLe") + " " + DateUtil.getOutputDate(new Date(), langue), secondFont);

        secondTitle.setAlignment(Element.ALIGN_CENTER);

        document.add(masterTitle);
        document.add(secondTitle);
    } catch (Exception e) {
        throw new NewsEditoException("PdfGenerator.createFirstPage", NewsEditoException.WARNING,
                "NewsEdito.EX_PROBLEM_TO_GENERATE_PAGE_ONE", e);
    }

}

From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java

License:Open Source License

/**
 * Method declaration/*  w w w. j a v a  2  s .  c  o  m*/
 * @param document
 * @param title
 * @param titleCount
 * @param publicationBm
 * @return
 * @throws NewsEditoException
 * @see
 */
public static Section addTitle(Document document, NodeDetail title, int titleCount, PublicationBm publicationBm)
        throws NewsEditoException {

    // we define some fonts
    Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255));

    Paragraph cTitle = new Paragraph(title.getName(), titleFont);
    Chapter chapter = new Chapter(cTitle, titleCount);

    if (title.getDescription() != null) {
        chapter.add(new Paragraph(title.getDescription()));

    }
    try {
        addPublications(chapter, title, publicationBm);
        document.add(chapter);
    } catch (Exception e) {
        throw new NewsEditoException("PdfGenerator.addTitle", NewsEditoException.WARNING,
                "NewsEdito.EX_NO_TITLE_ADDED", e);
    }

    return chapter;
}

From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java

License:Open Source License

/**
 * Method declaration//w ww  . j av  a 2 s  . c  o  m
 * @param section
 * @param complete
 * @see
 */
public static void addPublication(Section section, CompletePublication complete) {
    Font publicationFont = new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64));

    try {
        Paragraph pub = new Paragraph(complete.getPublicationDetail().getName(), publicationFont);
        Section subsection = section.addSection(pub, 0);

        if (complete.getPublicationDetail().getDescription() != null) {
            subsection.add(new Paragraph(complete.getPublicationDetail().getDescription()));
        }
        if ((complete.getInfoDetail() != null) && (complete.getModelDetail() != null)) {
            String toParse = complete.getModelDetail().getHtmlDisplayer();

            Iterator<InfoTextDetail> textIterator = complete.getInfoDetail().getInfoTextList().iterator();
            Iterator<InfoImageDetail> imageIterator = complete.getInfoDetail().getInfoImageList().iterator();

            int posit = toParse.indexOf("%WA");
            InfoTextDetail textDetail = null;
            Paragraph text = null;
            InfoImageDetail imageDetail = null;
            Image img = null;

            while (posit != -1) {
                if (posit > 0) {
                    toParse = toParse.substring(posit);
                }
                if (toParse.startsWith("%WATXTDATA%")) {
                    if (textIterator.hasNext()) {
                        textDetail = textIterator.next();
                        text = new Paragraph(textDetail.getContent());

                        subsection.add(text);
                    }
                    toParse = toParse.substring(11);
                } else if (toParse.startsWith("%WAIMGDATA%")) {
                    if (imageIterator.hasNext()) {
                        imageDetail = imageIterator.next();
                        String imagePath = FileRepositoryManager
                                .getAbsolutePath(imageDetail.getPK().getComponentName()) + getImagePath()
                                + File.separator + imageDetail.getPhysicalName();
                        SilverTrace.info("NewsEdito", "PDFGenerator.addPublication", "root.MSG_PARAM_VALUE",
                                "imagePath = " + imagePath);
                        img = Image.getInstance(imagePath);

                        subsection.add(img);
                    }
                    toParse = toParse.substring(11);
                }

                // et on recommence
                posit = toParse.indexOf("%WA");
            }
        }

    } catch (Exception e) {
        SilverTrace.warn("NewsEdito", "PdfGenerator.addPublication", "NewsEdito.EX_NO_PUBLI_ADDED");
    }
}

From source file:com.stratelia.webactiv.newsEdito.control.PdfGenerator.java

License:Open Source License

/**
 * Method declaration/*ww  w .  jav a2 s .c  om*/
 * @param document
 * @param archiveDetail
 * @param publicationBm
 * @param langue
 * @see
 */
public static void addEditorial(Document document, NodeDetail archiveDetail, PublicationBm publicationBm,
        String langue) throws NewsEditoException {

    SilverTrace.info("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.MSG_ENTRY_METHOD");

    try {
        ResourceLocator message = new ResourceLocator(
                "com.stratelia.webactiv.newsEdito.multilang.newsEditoBundle", langue);
        Collection<PublicationDetail> pubList = publicationBm.getDetailsByFatherPK(archiveDetail.getNodePK());
        Iterator<PublicationDetail> i = pubList.iterator();

        if (i.hasNext()) {
            try {

                Font publicationFont = new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64));
                Font titleFont = new Font(Font.HELVETICA, 24, Font.NORMAL, new Color(255, 255, 255));

                Paragraph cTitle = new Paragraph(message.getString("editorial"), titleFont);
                Chapter chapter = new Chapter(cTitle, 0);

                chapter.setNumberDepth(0);

                PublicationDetail detail = null;
                Paragraph name = null;
                Section subsection = null;
                Image img = null;
                while (i.hasNext()) {

                    detail = i.next();
                    name = new Paragraph(detail.getName(), publicationFont);
                    subsection = chapter.addSection(name, 0);

                    subsection.setNumberDepth(0);

                    if (detail.getDescription() != null) {
                        subsection.add(new Paragraph(detail.getDescription()));

                    }
                    if (detail.getImage() != null) {

                        String imagePath = FileRepositoryManager
                                .getAbsolutePath(detail.getPK().getComponentName()) + getImagePath()
                                + File.separator + detail.getImage();
                        try {
                            SilverTrace.info("NewsEdito", "PDFGenerator.addEditorial", "root.MSG_PARAM_VALUE",
                                    "imagePath = " + imagePath);
                            img = Image.getInstance(imagePath);
                        } catch (Exception e) {
                            SilverTrace.info("NewsEdito", "PDFGenerator.addEditorial",
                                    "NewsEdito.MSG_CANNOT_RETRIEVE_IMAGE", "imagePath = " + imagePath);
                        }
                        if (img == null) {
                            SilverTrace.info("NewsEdito", "PdfGenerator.addEditorial",
                                    "NewsEdito.MSG_CANNOT_RETRIEVE_IMAGE");
                        } else {
                            subsection.add(img);
                        }
                    }
                }
                document.add(chapter);

            } catch (DocumentException de) {
                SilverTrace.warn("NewsEdito", "PdfGenerator.addEditorial", "NewsEdito.EX_NO_EDITO_ADDED");
            }

        }
    } catch (Exception e) {
        throw new NewsEditoException("PdfGenerator.addEditorial", NewsEditoException.WARNING,
                "NewsEdito.EX_PROBLEM_TO_ADD_EDITO", e);
    }

}

From source file:com.sumeet.kraiglist.pdfview.PdfReportView.java

@Override
protected void buildPdfDocument(Map<String, Object> model, Document pdfdoc, PdfWriter pdfwriter,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession session = request.getSession();
    String name = (String) session.getAttribute("firstname");
    if (name == null) {
        name = "";
    }/*  w ww  .ja va2  s  .c o  m*/

    Font font_helvetica_12_normal_black = new Font(Font.HELVETICA, 12, Font.NORMAL, Color.BLACK);
    Font font_courier_16_italic_blue = new Font(Font.COURIER, 10, Font.ITALIC, Color.BLUE);
    Font font_courier_16_italic_red = new Font(Font.COURIER, 16, Font.ITALIC, Color.BLUE);
    Font font_times_16_bold_green = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.BLACK);

    Paragraph prg0 = new Paragraph(
            "                                             Terms of Use of MyNEU KRAIGLIST",
            font_helvetica_12_normal_black);
    Paragraph prg1 = new Paragraph(
            "____________________________________________________________________________________________________________",
            font_courier_16_italic_red);
    Paragraph prg2 = new Paragraph("");
    Chunk c1 = new Chunk("Hello " + name + ",", font_courier_16_italic_blue);
    Paragraph prg3 = new Paragraph("PRODUCT SALES : "
            + "The GSI Products listed on this Site are offered for sale solely pursuant to GSIs standard terms and conditions of sale applicable"
            + "to such products. The terms and conditions are accessible for viewing by clicking on the link on each product line home page."
            + "GSI objects to and rejects any other terms that may be proposed by any customer or potential customer. No offers to sell or purchase"
            + "GSI products are valid and binding on GSI unless and until specifically accepted, in writing, by GSI.",
            font_times_16_bold_green);
    //Phrase phr2 = new Phrase("Phrase 2", font_helvetica_16_normal_blue);
    Paragraph prg4 = new Paragraph("");
    Paragraph prg5 = new Paragraph("LICENSE TO USE THIS SITE : "
            + "We at the GSI Group Inc. and its subsidiaries (GSI) are happy to have you as a visitor. We have established the following"
            + "terms and conditions, including our Privacy Statement, as a requirement for visitors using our site. In order to use our site, you"
            + "must agree to these terms and conditions (Terms). BY CHOOSING TO ACCESS AND USE THIS SITE, YOU ARE EXPRESSLY"
            + "AGREEING TO BE LEGALLY BOUND BY THESE TERMS. IF YOU DO NOT AGREE, DO NOT USE OR VIEW THE SITE."
            + "These Terms apply only to the use of this Site and do not supercede any other contractual agreement between you and GSI."
            + "Use of Materials: Upon your agreement to the Terms, GSI grants you the right to view the site and to download materials from"
            + "this site for your personal, non-commercial use. You are not authorized to use the materials for any other purpose. If you do"
            + "download or otherwise reproduce the materials from this Site, you must reproduce all of GSIs proprietary markings, such as"
            + "copyright and trademark notices, in the same form and manner as the original."
            + "Private Pages: Some parts of this Site are not available to the general public, but only to certain business associates of GSI."
            + "These sections may only be accessed by authorized entities and are controlled by password-protected access. If you are not"
            + "authorized to use these sections, then you agree that you will not attempt to gain access. If you are authorized, then by accessing"
            + "those areas, you expressly agree to the supplemental terms that are posted as part of the access process."
            + "No Harmful Use: In exchange for our permission to use this Site, you agree that you will not do anything to harm the functioning"
            + "or content of the Site. You will not attempt to upload, insert or change any information or image to or on this Site, except for providing"
            + "information where prompted by the Site. You agree that you will not take any action that imposes an unreasonably or disproportionately"
            + "large load on the Site or interferes with its functioning. You also agree that you will not use any false identity"
            + "when interacting with the Site, or do anything that is fraudulent, obscene, libelous or legally prohibited."
            + "You may not use any deep-link, page-scrape, robot, spider or any other automatic device, program, algorithm or methodology"
            + "or any similar or equivalent manual process to access, acquire, copy or monitor any portion of the Site or any of its content,"
            + "or in any way reproduce or circumvent the navigational structure or presentation of the Site."
            + "INDEMNITY: YOU AGREE THAT YOU WILL DEFEND, INDEMNIFY AND HOLD HARMLESS GSI, ITS CUSTOMERS, SUPPLIERS"
            + "AND JOINT VENTURE PARTNERS AND THEIR RESPECTIVE EMPLOYEES, OFFICERS, DIRECTORS, CONTRACTORS,"
            + "VENDORS, ASSIGNEES AND AGENTS FOR AND AGAINST ANY COSTS, CLAIMS, DAMAGES, LOSSES, OR"
            + "OTHER LIABILITIES ARISING FROM YOUR USE OF THE SITE IN BREACH OF THESE TERMS OR IN VIOLATION OF THE"
            + "LAW. IF GSI TAKES ANY LEGAL ACTION AGAINST YOU AS A RESULT OF YOUR VIOLATION OF THESE TERMS, YOU"
            + "AGREE THAT YOU WILL BE RESPONSIBLE FOR AND WILL PAY ALL OF GSIS LEGAL FEES IN CONNECTION WITH"
            + "SUCH ACTION. ", font_times_16_bold_green);

    pdfdoc.add(c1);
    pdfdoc.add(prg0);
    pdfdoc.add(prg1);
    pdfdoc.add(prg2);
    pdfdoc.add(prg3);
    pdfdoc.add(prg4);
    pdfdoc.add(prg5);

}

From source file:Controleur.CtrlImprimerOrdonnance.java

public void RemplirOrdonnance() {
    ResultSet res;// w w w .  j  a v  a  2 s.  c  o m
    String nomEtablissement = "";
    String adresseEtablissement = "";
    int telEtablissement = 0;
    String nomPatient = "";
    String prenomPatient = "";
    String dateNaissPatient = null;
    String traitement = "";
    Etablissement etab = new Etablissement();
    try {
        res = etab.getEtablissement();
        nomEtablissement = res.getString("nomEtab");
        adresseEtablissement = res.getString("adresseEtab");
        telEtablissement = res.getInt("telEtab");
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage());
    }
    Medecin med1 = new Medecin();
    Medecin med2 = med1.getMedecinById(Fen.getIdm());
    String nomMedecin = med2.getNomMedecin();
    String prenomMedecin = med2.getPrenomMedecin();
    String specialiteMedecin = med2.getSpecialite();
    Patient patient = new Patient();
    res = patient.getPatient(Fen.getIdp());
    try {
        res.next();
        nomPatient = res.getString("nomPatient");
        prenomPatient = res.getString("prenomPatient");
        dateNaissPatient = res.getString("dateNaissance");
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, "erreur \n" + e.getMessage());
    }

    traitement = Fen.getTxtTraitement().getText();

    Document document = new Document(PageSize.A4);
    try {
        PdfWriter.getInstance(document, new FileOutputStream("./ordonnance.pdf"));
        document.open();
        Date d = new Date();
        Paragraph paragraph = new Paragraph(d.toLocaleString(),
                FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD));
        paragraph.setAlignment(Element.ALIGN_RIGHT);
        paragraph.setIndentationRight(50f);
        document.add(paragraph);
        paragraph = new Paragraph("Dr " + nomMedecin + " " + prenomMedecin,
                FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD));
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("SPECIALISTE EN " + specialiteMedecin);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph(nomEtablissement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph(adresseEtablissement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("Tl : " + telEtablissement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("                      ");
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("nom & prenom :" + nomPatient + " " + prenomPatient,
                FontFactory.getFont(FontFactory.COURIER, 20, Font.BOLD));
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("Ne(e) le :" + dateNaissPatient);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph("                       ");
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);

        Chunk chunk = new Chunk("Ordonnance", FontFactory.getFont(FontFactory.COURIER, 30, Font.BOLD));
        chunk.setUnderline(Color.BLACK, 3.0f, 0.0f, 0.0f, -0.2f, PdfContentByte.LINE_CAP_BUTT);
        paragraph = new Paragraph();
        paragraph.setAlignment(Element.ALIGN_CENTER);
        paragraph.add(chunk);
        document.add(paragraph);

        paragraph = new Paragraph("                       ");
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);
        paragraph = new Paragraph(traitement);
        paragraph.setIndentationLeft(50f);
        document.add(paragraph);

        Runtime r = Runtime.getRuntime();
        r.exec("cmd /C ./ordonnance.pdf");
    } catch (DocumentException de) {
        de.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    document.close();
}

From source file:Cotizacion.ExportarPDF.java

private static void acomodarDatosNormal(Paragraph datosNormal) throws BadElementException {
    nombreCliente = Cotizacion.PanelCotizacion.labelObtenerNombreCliente.getText();
    anexo = Cotizacion.PanelCotizacion.labelAnexo.getText();
    datosNormal.add(new Paragraph(nombreCliente, fuenteNegrita));
    datosNormal.add(new Paragraph(anexo, fuenteNormal));
    agregarLineasEnBlanco(datosNormal, 1);
    datosNormal.setAlignment(0);//from   w  ww.j av  a 2  s. c  o  m
}