Example usage for com.lowagie.text Paragraph setSpacingAfter

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

Introduction

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

Prototype

public void setSpacingAfter(float spacing) 

Source Link

Document

Sets the spacing after this paragraph.

Usage

From source file:appli_etudiants.ExportPDF.java

public static void main(Etudiants etudiant)
        throws SQLException, FileNotFoundException, BadElementException, IOException {
    try {//from w  ww .  j  av  a2 s  . c  o m
        Document document = new Document(PageSize.A4);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/tesPDF.pdf"));
        document.open();
        PdfContentByte canvas = writer.getDirectContentUnder();
        Image image = Image.getInstance("c:/fond_cv.jpg");
        image.setAbsolutePosition(0, 80);
        canvas.saveState();
        PdfGState state = new PdfGState();
        state.setFillOpacity(0.6f);
        canvas.setGState(state);
        canvas.addImage(image);
        canvas.restoreState();

        LineSeparator lineSepa = new LineSeparator();
        lineSepa.setLineColor(new Color(21, 96, 189));
        Paragraph para1 = new Paragraph();
        Paragraph para2 = new Paragraph(etudiant.getAdresse_rue());
        Paragraph para3 = new Paragraph(etudiant.getAdresse_cp() + " " + etudiant.getAdresse_ville());
        Paragraph para4 = new Paragraph(etudiant.getCourriel(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)));
        Paragraph para5 = new Paragraph(etudiant.getTel_personnel());
        Paragraph para6 = new Paragraph(etudiant.getTel_professionnel());
        Paragraph para7 = new Paragraph(etudiant.getSite_web());
        para1.add(new Chunk(etudiant.getPrenom(),
                FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD, new Color(21, 96, 189))));
        para1.add(
                new Chunk(" " + etudiant.getNom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD)));

        Image image1 = Image.getInstance(DaoS4.getPhoto());
        image1.scalePercent(50);
        image1.setAlignment(Image.RIGHT | Image.TEXTWRAP);
        image1.scaleAbsolute(94, 94);
        document.add(image1);

        document.add(para1);
        document.add(para2);
        document.add(para3);
        document.add(para4);
        document.add(para5);
        document.add(para6);
        para7.setSpacingAfter(25f);
        document.add(para7);
        Paragraph para8 = new Paragraph(DaoS4.getLibelleTitre());
        para8.setSpacingBefore(25f);
        para8.setSpacingAfter(20f);
        document.add(para8);

        Paragraph para9 = new Paragraph(new Chunk("EXPERIENCE PROFESSIONELLE",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para9.setSpacingBefore(15f);
        para9.setSpacingAfter(15f);
        document.add(para9);
        document.add(lineSepa);
        Paragraph para10 = new Paragraph(DaoS4.getLibelleExpPro());
        para10.setSpacingAfter(15f);
        document.add(para10);

        Paragraph para11 = new Paragraph(new Chunk("FORMATION",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para11.setSpacingBefore(15f);
        para11.setSpacingAfter(15f);
        document.add(para11);
        document.add(lineSepa);
        Paragraph para12 = new Paragraph(DaoS4.getLibelleFormation());
        para12.setSpacingAfter(15f);
        document.add(para12);

        Paragraph para13 = new Paragraph(new Chunk("INFORMATIQUE",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para13.setSpacingBefore(15f);
        para13.setSpacingAfter(15f);
        document.add(para13);
        document.add(lineSepa);
        Paragraph para14 = new Paragraph(DaoS4.getLibelleInformatique());
        para14.setSpacingAfter(15f);
        document.add(para14);

        Paragraph para15 = new Paragraph(new Chunk("LANGUE",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para15.setSpacingBefore(15f);
        para15.setSpacingAfter(15f);
        document.add(para15);
        document.add(lineSepa);
        Paragraph para16 = new Paragraph(DaoS4.getLibelleLangue());
        para16.setSpacingAfter(15f);
        document.add(para16);

        Paragraph para17 = new Paragraph(new Chunk("CENTRES D'INTERET",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para17.setSpacingBefore(15f);
        para17.setSpacingAfter(15f);
        document.add(para17);
        document.add(lineSepa);
        Paragraph para18 = new Paragraph(DaoS4.getLibelleInteret());
        para18.setSpacingAfter(15f);
        document.add(para18);

        document.close();
    } catch (DocumentException ex) {
        Logger.getLogger(ExportPDF.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:be.fedict.eid.applet.service.impl.PdfGenerator.java

License:Open Source License

public byte[] generatePdf(EIdData eIdData) throws DocumentException {
    Document document = new Document();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer = PdfWriter.getInstance(document, baos);

    document.open();/*from   w w  w  . j  a  v  a 2s.c om*/

    Paragraph titleParagraph = new Paragraph("eID Identity Data");
    titleParagraph.setAlignment(Paragraph.ALIGN_CENTER);

    Font titleFont = titleParagraph.getFont();
    titleFont.setSize((float) 20.0);
    titleFont.setStyle(Font.BOLD);
    titleParagraph.setSpacingAfter(20);
    document.add(titleParagraph);

    if (null != eIdData && null != eIdData.getIdentity()) {
        if (null != eIdData.getPhoto()) {
            try {
                Image image = createImageFromPhoto(eIdData.getPhoto());
                document.add(image);
            } catch (Exception e) {
                LOG.error("Error getting photo: " + e.getMessage());
            }

            Identity identity = eIdData.getIdentity();

            // metadata
            setDocumentMetadata(document, identity.firstName, identity.name);
            writer.createXmpMetadata();

            // create a table with the data of the eID card
            PdfPTable table = new PdfPTable(2);
            table.getDefaultCell().setBorder(0);

            table.addCell("Name");
            table.addCell(identity.name);

            table.addCell("First name");
            String firstName = identity.firstName;
            if (null != identity.middleName) {
                firstName += " " + identity.middleName;
            }
            table.addCell(firstName);

            table.addCell("Nationality");
            table.addCell(identity.nationality);

            table.addCell("National Registration Number");
            table.addCell(identity.nationalNumber);

            table.addCell("Gender");
            table.addCell(identity.gender.toString());

            table.addCell("Date of birth");
            SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
            table.addCell(formatter.format(identity.dateOfBirth.getTime()));

            table.addCell("Place of birth");
            table.addCell(identity.placeOfBirth);

            if (null != eIdData.getAddress()) {
                Address address = eIdData.getAddress();
                table.addCell("Address");
                PdfPCell cell = new PdfPCell();
                cell.setBorder(0);
                cell.addElement(new Paragraph(address.streetAndNumber));
                cell.addElement(new Paragraph(address.zip + " " + address.municipality));
                table.addCell(cell);
            }

            document.add(table);

            // TODO: to be tested
            /*
            try {
                Image barcodeImage =
                    createBarcodeImage(identity.nationalNumber, identity.cardNumber);
                    
                barcodeImage.setAlignment(Element.ALIGN_CENTER);
                Paragraph barcodePara = new Paragraph();
                barcodePara.add(barcodeImage);
                    
                document.add(barcodeImage);
            } catch (Exception e) {
                LOG.error("Error adding barcode: " + e.getMessage());
            }
            */
        } else {
            document.add(new Paragraph("No eID identity data available."));
        }
    }
    document.close();
    return baos.toByteArray();
}

From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java

License:Open Source License

protected void addTitle(final String titleText, final Font titleFont, final int align,
        final float spacingBefore, final float spacingAfter, final Document doc) throws DocumentException {
    final Paragraph titlePara = new Paragraph(titleText, titleFont);
    titlePara.setAlignment(align);//from w ww  .ja v  a 2  s  .c o m
    titlePara.setSpacingBefore(spacingBefore);
    titlePara.setSpacingAfter(spacingAfter);
    doc.add(titlePara);
}

From source file:br.com.nfsconsultoria.azcontrole.bean.VendaBean.java

public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException {
    Document pdf = (Document) document;
    pdf.setPageSize(PageSize.A4);/*from   w  w  w .ja  v a 2 s. c om*/
    pdf.addAuthor("Luis Carlos Santos");
    pdf.addTitle("Acordo Cadastrados");
    pdf.addCreator("NFS Consultoria");
    pdf.addSubject("Acordo Cadastrados");
    pdf.open();

    Font catFont = new Font(Font.TIMES_ROMAN, 18, Font.BOLD);

    Paragraph p = new Paragraph("Relatrio de Acordos", catFont);
    p.setAlignment(Element.ALIGN_CENTER);
    p.setSpacingAfter(20);

    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    String logo = externalContext.getRealPath("") + File.separator + "resources" + File.separator + "images"
            + File.separator + "banner.png";

    pdf.add(Image.getInstance(logo));
    pdf.add(p);
}

From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java

License:Open Source License

public static void createDiagnosenSheet(Patient patient, String filename, String footerText)
        throws DocumentException, IOException {

    StringBuffer sb = new StringBuffer("Diagnosen:\n");
    sb.append(patient.getDiagnosen());/*  w w w .  ja va 2  s  . com*/
    sb.append("\n");
    sb.append("Persnliche Anamnese:\n");
    sb.append(patient.getPersAnamnese());
    sb.append("\n");

    // step 1
    Document document = new Document(PageSize.A4);

    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
    // step 3
    //Rectangle rect = new Rectangle(30, 30, 559, 800);
    writer.setBoxSize("art", rect);

    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    event.setHeaderText(
            patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")");
    event.setFooterText(footerText);
    writer.setPageEvent(event);

    document.setMargins(36, 72, 60, 60);

    // step 3
    document.open();

    document.add(new Chunk("")); // << this will do the trick. 

    if (patient.getDiagnosen().length() > 0) {
        Paragraph p = new Paragraph("Diagnosen:", fontTimesTitle);
        p.setSpacingAfter(10f);
        document.add(p);

        String[] chunksDiag = patient.getDiagnosen().toString().split("(?m)^\\s*$");
        for (String chunk : chunksDiag) {
            document.add(new Paragraph(chunk, fontTimes));
        }
    } else {
        document.add(new Paragraph("Keine Diagnosen vorhanden", fontTimes));

    }

    if (patient.getPersAnamnese().length() > 0) {
        Paragraph p = new Paragraph("Persnliche Anamnese:", fontTimesTitle);
        p.setSpacingBefore(10f);
        p.setSpacingAfter(10f);

        document.add(p);

        String[] chunksAnam = patient.getPersAnamnese().toString().split("(?m)^\\s*$");
        for (String chunk : chunksAnam) {
            document.add(new Paragraph(chunk, fontTimes));
        }
    } else {
        document.add(new Paragraph("Keine Persnliche Anamnese vorhanden", fontTimes));

    }

    // step 5
    document.close();

}

From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java

License:Open Source License

public static void createFixMediSheet(Patient patient, String filename, String footerText)
        throws DocumentException, IOException {
    Prescription[] prescriptions = patient.getFixmedikation();
    StringBuffer sb = new StringBuffer();
    for (Prescription prescription : prescriptions) {
        //System.out.println("Prescription: " + prescription.getLabel() + "/" + prescription.getDosis());
        sb.append(prescription.getLabel());
        sb.append("\r\n");
    }/*w  w  w.  ja  v a2  s . c  om*/

    // step 1
    Document document = new Document(PageSize.A4);

    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
    // step 3
    //Rectangle rect = new Rectangle(30, 30, 559, 800);
    writer.setBoxSize("art", rect);

    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    event.setHeaderText(
            patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")");
    event.setFooterText(footerText);
    writer.setPageEvent(event);

    document.setMargins(36, 72, 60, 60);

    // step 3
    document.open();

    document.add(new Chunk("")); // << this will do the trick. 

    if (sb.length() > 0) {
        Paragraph p = new Paragraph("Fixmedikation:", fontTimesTitle);
        p.setSpacingAfter(10f);
        document.add(p);

        String[] chunksDiag = sb.toString().split("(?m)^\\s*$");
        for (String chunk : chunksDiag) {
            document.add(new Paragraph(chunk, fontTimes));
        }
    } else {

        //document.add(new Paragraph("Keine Medikationen vorhanden", fontTimes));
        Paragraph p = new Paragraph(new Chunk("Keine Medikationen vorhanden", fontTimesTitle));
        p.setSpacingBefore(20f);
        document.add(p);

    }

    // step 5
    document.close();

}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public Paragraph newParagraph() {
    Paragraph p = new Paragraph();
    p.setAlignment(alignment.value);//ww  w. ja  v  a 2s  .c o  m
    p.setFont(_defaultFont);
    currentFont = _defaultFont;
    p.setHyphenation(new HyphenationAuto("en", "US", 2, 2));
    p.setLeading(0F, getCurrentLeadingMultiplier());
    p.setSpacingAfter(_defaultFont.getSize() * 0.33F);
    currentParagraph = p;
    return p;
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public Paragraph newParagraphPre() {
    Paragraph p = new Paragraph();
    p.setAlignment(ITAlignment.LEFT.value);
    p.setFont(_defaultFontMono);//from w  w w.j  a v  a2  s  .  c o  m
    currentFont = _defaultFontMono;
    p.setLeading(0F, getCurrentLeadingMultiplier());
    p.setSpacingAfter(_defaultFont.getSize() * 0.33F);
    currentParagraph = p;
    return p;
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public Paragraph newHeadline(int i) {
    if (i < 1) {
        i = 1;/*from  ww  w.  j ava 2  s  .co m*/
    }
    if (i > 6) {
        i = 6;
    }
    Font hFont = FontFactory.getFont(_defaultFont.getFamilyname(), FontFactory.defaultEncoding,
            BaseFont.EMBEDDED, baseFontSize * HMULTS[i - 1], Font.BOLD);
    Paragraph h = new Paragraph();
    h.setAlignment(ITAlignment.CENTER.value);
    h.setFont(hFont);
    currentFont = hFont;
    h.setLeading(0F, getCurrentLeadingMultiplier());
    h.setSpacingAfter(_defaultFont.getSize() * 0.33F);
    currentParagraph = h;
    return h;
}

From source file:com.aryjr.nheengatu.pdf.PDFText.java

License:Open Source License

public static Paragraph createParagraph(final Text htmlText, TagsManager tm) {

    if (tm == null)
        tm = TagsManager.getInstance();/*from w ww  .  ja va2s .  c  om*/

    final Paragraph text = new Paragraph(htmlText != null ? htmlText.getText() : null, tm.getFont());
    text.setAlignment(tm.getAlign());
    text.setKeepTogether(true);
    // float b = tm.getSpacingBefore();
    // float a = tm.getSpacingAfter();
    text.setSpacingBefore(tm.getSpacingBefore());
    text.setSpacingAfter(tm.getSpacingAfter());
    text.setFirstLineIndent(tm.getTextIndent());
    text.setIndentationLeft(tm.getMarginLeft());
    // text.setFirstLineIndent(20f);
    text.setLeading(tm.getFont().getSize() * 1.5f);
    return text;
}