Example usage for com.itextpdf.text Paragraph setAlignment

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

Introduction

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

Prototype

public void setAlignment(int alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:org.spinsuite.print.ReportPrintData.java

License:Open Source License

/**
 * Create a PDF File//ww w.ja v a 2  s  . c  om
 * @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com 02/04/2014, 22:52:09
 * @param outFile
 * @throws FileNotFoundException
 * @throws DocumentException
 * @return void
 */
private void createPDF(File outFile) throws FileNotFoundException, DocumentException {
    Document document = new Document(PageSize.LETTER);

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile));
    PDFHeaderAndFooter event = new PDFHeaderAndFooter();
    writer.setPageEvent(event);
    document.open();
    //   
    document.addAuthor(ctx.getResources().getString(R.string.app_name));
    document.addCreationDate();
    //   
    Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName());
    //   Set Font
    title.getFont().setStyle(Font.BOLD);
    //   Set Alignment
    title.setAlignment(Paragraph.ALIGN_CENTER);
    //   Add Title
    document.add(title);
    //   Add New Line
    document.add(Chunk.NEWLINE);
    //   Parameters
    ProcessInfoParameter[] param = m_pi.getParameter();
    //   Get Parameter
    if (param != null) {
        //   
        boolean isFirst = true;
        //   Iterate
        for (ProcessInfoParameter para : param) {
            //   Get SQL Name
            String name = para.getInfo();
            StringBuffer textParameter = new StringBuffer();
            if (para.getParameter() == null && para.getParameter_To() == null)
                continue;
            else {
                //   Add Parameters Title
                if (isFirst) {
                    Paragraph titleParam = new Paragraph(
                            ctx.getResources().getString(R.string.msg_ReportParameters));
                    //   Set Font
                    titleParam.getFont().setStyle(Font.BOLDITALIC);
                    //   Add to Document
                    document.add(titleParam);
                    isFirst = false;
                }
                //   Add Parameters Name
                if (para.getParameter() != null && para.getParameter_To() != null) { //   From and To is filled
                    //   
                    textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ")
                            .append(para.getDisplayValue_To());
                } else if (para.getParameter() != null) { //   Only From
                    //   
                    textParameter.append(name).append(" = ").append(para.getDisplayValue());
                } else if (para.getParameter_To() != null) { //   Only To
                    //   
                    textParameter.append(name).append(" <= ").append(para.getDisplayValue_To());
                }
            }
            //   Add to Document
            Paragraph viewParam = new Paragraph(textParameter.toString());
            document.add(viewParam);
        }
    }
    document.add(Chunk.NEWLINE);
    //   
    InfoReportField[] columns = m_reportQuery.getColumns();
    //   Add Table
    PdfPTable table = new PdfPTable(columns.length);
    table.setSpacingBefore(4);
    //   Add Header
    PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName()));
    headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    headerCell.setColspan(columns.length);
    //   Add to Table
    table.addCell(headerCell);
    //   Add Header
    //   Decimal and Date Format
    DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length];
    SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length];
    for (int i = 0; i < columns.length; i++) {
        InfoReportField column = columns[i];
        //   Only Numeric
        if (DisplayType.isNumeric(column.DisplayType))
            cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern);
        //   Only Date
        else if (DisplayType.isDate(column.DisplayType))
            cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern);
        //   
        Phrase phrase = new Phrase(column.PrintName);
        PdfPCell cell = new PdfPCell(phrase);
        if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        else
            cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
        //   
        table.addCell(cell);
    }
    //   Add Detail
    for (int row = 0; row < m_data.size(); row++) {
        //   Get Row
        RowPrintData rPrintData = m_data.get(row);
        //   Iterate
        for (int col = 0; col < columns.length; col++) {
            InfoReportField column = columns[col];
            ColumnPrintData cPrintData = rPrintData.get(col);
            Phrase phrase = null;
            PdfPCell cell = new PdfPCell();
            //   
            String value = cPrintData.getValue();
            //   Only Values
            if (value != null) {
                if (DisplayType.isNumeric(column.DisplayType)) { //   Number
                    //   Format
                    DecimalFormat decimalFormat = cDecimalFormat[col];
                    //   Format
                    if (decimalFormat != null)
                        value = decimalFormat.format(DisplayType.getNumber(value));
                    //   Set Value
                    cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                } else if (DisplayType.isDate(column.DisplayType)) { //   Is Date
                    SimpleDateFormat dateFormat = cDateFormat[col];
                    if (dateFormat != null && value.trim().length() > 0) {
                        long date = Long.parseLong(value);
                        value = dateFormat.format(new Date(date));
                    }
                }
            }
            //   Set Value
            phrase = new Phrase(value);
            //   
            if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            else
                cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
            //   Set Font
            if (rPrintData.isFunctionRow()) {
                //   Set Function Value
                if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0)
                    phrase = new Phrase(cPrintData.getFunctionValue());
                //   Set Font
                phrase.getFont().setStyle(Font.BOLDITALIC);
            }
            //   Add to Table
            cell.setPhrase(phrase);
            table.addCell(cell);
        }
    }
    //   Add Table to Document
    document.add(table);
    //   New Line
    document.add(Chunk.NEWLINE);
    //   Add Footer
    StringBuffer footerText = new StringBuffer(Env.getContext("#SUser"));
    footerText.append("(");
    footerText.append(Env.getContext("#AD_Role_Name"));
    footerText.append("@");
    footerText.append(Env.getContext("#AD_Client_Name"));
    footerText.append(".");
    footerText.append(Env.getContext("#AD_Org_Name"));
    footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) ");
    //   Date
    SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME);
    footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = ");
    footerText.append(pattern.format(new Date()));
    //   
    Paragraph footer = new Paragraph(footerText.toString());
    footer.setAlignment(Paragraph.ALIGN_CENTER);
    //   Set Font
    footer.getFont().setSize(8);
    //   Add Footer
    document.add(footer);
    //   Close Document
    document.close();
}

From source file:org.spinsuite.view.report.ReportPrintData.java

License:Open Source License

/**
 * Create a PDF File//from w  w w. j a v  a 2s.  co  m
 * @author <a href="mailto:yamelsenih@gmail.com">Yamel Senih</a> 02/04/2014, 22:52:09
 * @param outFile
 * @throws FileNotFoundException
 * @throws DocumentException
 * @return void
 */
private void createPDF(File outFile) throws FileNotFoundException, DocumentException {
    Document document = new Document(PageSize.LETTER);

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile));
    PDFHeaderAndFooter event = new PDFHeaderAndFooter();
    writer.setPageEvent(event);
    document.open();
    //   
    document.addAuthor(ctx.getResources().getString(R.string.app_name));
    document.addCreationDate();
    //   
    Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName());
    //   Set Font
    title.getFont().setStyle(Font.BOLD);
    //   Set Alignment
    title.setAlignment(Paragraph.ALIGN_CENTER);
    //   Add Title
    document.add(title);
    //   Add New Line
    document.add(Chunk.NEWLINE);
    //   Parameters
    ProcessInfoParameter[] param = m_pi.getParameter();
    //   Get Parameter
    if (param != null) {
        //   
        boolean isFirst = true;
        //   Iterate
        for (ProcessInfoParameter para : param) {
            //   Get SQL Name
            String name = para.getInfo();
            StringBuffer textParameter = new StringBuffer();
            if (para.getParameter() == null && para.getParameter_To() == null)
                continue;
            else {
                //   Add Parameters Title
                if (isFirst) {
                    Paragraph titleParam = new Paragraph(
                            ctx.getResources().getString(R.string.msg_ReportParameters));
                    //   Set Font
                    titleParam.getFont().setStyle(Font.BOLDITALIC);
                    //   Add to Document
                    document.add(titleParam);
                    isFirst = false;
                }
                //   Add Parameters Name
                if (para.getParameter() != null && para.getParameter_To() != null) { //   From and To is filled
                    //   
                    textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ")
                            .append(para.getDisplayValue_To());
                } else if (para.getParameter() != null) { //   Only From
                    //   
                    textParameter.append(name).append(" = ").append(para.getDisplayValue());
                } else if (para.getParameter_To() != null) { //   Only To
                    //   
                    textParameter.append(name).append(" <= ").append(para.getDisplayValue_To());
                }
            }
            //   Add to Document
            Paragraph viewParam = new Paragraph(textParameter.toString());
            document.add(viewParam);
        }
    }
    document.add(Chunk.NEWLINE);
    //   
    InfoReportField[] columns = m_reportQuery.getColumns();
    //   Add Table
    PdfPTable table = new PdfPTable(columns.length);
    table.setSpacingBefore(4);
    //   Add Header
    PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName()));
    headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    headerCell.setColspan(columns.length);
    //   Add to Table
    table.addCell(headerCell);
    //   Add Header
    //   Decimal and Date Format
    DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length];
    SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length];
    for (int i = 0; i < columns.length; i++) {
        InfoReportField column = columns[i];
        //   Only Numeric
        if (DisplayType.isNumeric(column.DisplayType))
            cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern);
        //   Only Date
        else if (DisplayType.isDate(column.DisplayType))
            cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern);
        //   
        Phrase phrase = new Phrase(column.PrintName);
        PdfPCell cell = new PdfPCell(phrase);
        if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        else
            cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
        //   
        table.addCell(cell);
    }
    //   Add Detail
    for (int row = 0; row < m_data.size(); row++) {
        //   Get Row
        RowPrintData rPrintData = m_data.get(row);
        //   Iterate
        for (int col = 0; col < columns.length; col++) {
            InfoReportField column = columns[col];
            ColumnPrintData cPrintData = rPrintData.get(col);
            Phrase phrase = null;
            PdfPCell cell = new PdfPCell();
            //   
            String value = cPrintData.getValue();
            if (DisplayType.isNumeric(column.DisplayType)) { //   Number
                //   Format
                DecimalFormat decimalFormat = cDecimalFormat[col];
                //   Format
                if (decimalFormat != null)
                    value = decimalFormat.format(DisplayType.getNumber(value));
                //   Set Value
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            } else if (DisplayType.isDate(column.DisplayType)) { //   Is Date
                SimpleDateFormat dateFormat = cDateFormat[col];
                if (dateFormat != null) {
                    long date = Long.getLong(value, 0);
                    value = dateFormat.format(new Date(date));
                }
            }
            //   Set Value
            phrase = new Phrase(value);
            //   
            if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER))
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            else
                cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED);
            //   Set Font
            if (rPrintData.isFunctionRow()) {
                //   Set Function Value
                if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0)
                    phrase = new Phrase(cPrintData.getFunctionValue());
                //   Set Font
                phrase.getFont().setStyle(Font.BOLDITALIC);
            }
            //   Add to Table
            cell.setPhrase(phrase);
            table.addCell(cell);
        }
    }
    //   Add Table to Document
    document.add(table);
    //   New Line
    document.add(Chunk.NEWLINE);
    //   Add Footer
    StringBuffer footerText = new StringBuffer(Env.getContext(ctx, "#SUser"));
    footerText.append("(");
    footerText.append(Env.getContext(ctx, "#AD_Role_Name"));
    footerText.append("@");
    footerText.append(Env.getContext(ctx, "#AD_Client_Name"));
    footerText.append(".");
    footerText.append(Env.getContext(ctx, "#AD_Org_Name"));
    footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) ");
    //   Date
    SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME);
    footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = ");
    footerText.append(pattern.format(new Date()));
    //   
    Paragraph footer = new Paragraph(footerText.toString());
    footer.setAlignment(Paragraph.ALIGN_CENTER);
    //   Set Font
    footer.getFont().setSize(8);
    //   Add Footer
    document.add(footer);
    //   Close Document
    document.close();
}

From source file:org.tvd.thptty.management.report.Report.java

private void addContent(Document document, int kind) throws DocumentException {
    //Anchor anchor = new Anchor(tableTitle, tahomaLargeFont);
    //anchor.setName("Bang Diem");

    // Second parameter is the number of the chapter
    //Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    //Paragraph subPara = new Paragraph(createdBy, tahomaLargeFont);
    Paragraph header = new Paragraph(tableTitle, tahomaLargeFont);
    header.setAlignment(Element.ALIGN_LEFT);
    header.add(new Paragraph(createdBy, tahomaLargeFont));
    addEmptyLine(header, 1);/*from   w ww.ja  v  a 2 s . com*/

    //Section subCatPart = catPart.addSection(subPara);

    Paragraph paragraph = new Paragraph();

    // Add a table
    if (kind == 1) {
        paragraph.add(createSubjectPointTable());
    } else if (kind == 2) {
        paragraph.add(createStatisticsStudentPointTable());
    }

    header.add(paragraph);

    // Now add all this to the document
    document.add(header);

}

From source file:org.yougi.web.report.EventAttendeeCertificate.java

License:Open Source License

public void generateCertificate(Attendee attendee) throws DocumentException {

    Font helvetica = new Font(Font.FontFamily.HELVETICA, 12);
    BaseFont baseFont = helvetica.getCalculatedBaseFont(false);
    canvas.saveState();/*from ww  w.ja  v a 2s.c  o m*/
    canvas.beginText();
    canvas.setFontAndSize(baseFont, 12);
    canvas.showTextAligned(Element.ALIGN_LEFT, "Validation code: " + attendee.getCertificateCode()
            + " ( http://www.cejug.net/certificate_validation.xhtml) ", 30, 30, 0);
    canvas.endText();
    canvas.restoreState();

    String[] contentLine = new String[8];
    contentLine[0] = "Certificamos que";
    contentLine[1] = attendee.getCertificateFullname();
    contentLine[2] = "participou do evento";
    contentLine[3] = attendee.getCertificateEvent();
    contentLine[4] = "realizado na";
    contentLine[5] = attendee.getCertificateVenue();
    contentLine[6] = "no dia " + DateTimeUtils.getFormattedDate(attendee.getCertificateDate(), "dd.MM.yyyy");

    Font normalFont = new Font(Font.FontFamily.HELVETICA, 24);
    Font largeFont = new Font(Font.FontFamily.HELVETICA, 28, Font.FontStyle.BOLD.ordinal());
    Paragraph p;

    for (int i = 0; i < 5; i++) {
        p = new Paragraph(" ", normalFont);
        this.document.add(p);
    }

    Font currentFont = normalFont;
    for (int i = 0; i < contentLine.length; i++) {
        p = new Paragraph(contentLine[i], currentFont);
        p.setAlignment(Element.ALIGN_CENTER);
        this.document.add(p);

        currentFont = currentFont.equals(normalFont) ? largeFont : normalFont;
    }
}

From source file:org.zaproxy.zap.extension.alertReport.AlertReportExportPDF.java

License:Apache License

private static void addTitlePage(Document document, ExtensionAlertReportExport extensionExport)
        throws DocumentException {

    document.addHeader("Header1", "Header2");

    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 3);/* w  w  w .  j  a  v a  2  s.c  o  m*/
    // add logo first page
    addImage(preface, extensionExport.getParams().getLogoFileName(), 40f);

    addEmptyLine(preface, 4);
    // Lets write a big header
    Paragraph paragraph = new Paragraph(extensionExport.getParams().getTitleReport(), titleFont);
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);
    preface.add(paragraph);

    addEmptyLine(preface, 3);
    paragraph = new Paragraph(extensionExport.getParams().getCustomerName(), catFont);
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);
    preface.add(paragraph);

    addEmptyLine(preface, 15);

    preface.add(new Paragraph(
            extensionExport.getMessages().getString("alertreport.export.message.export.pdf.confidential"),
            smallBold));
    preface.add(new Paragraph(extensionExport.getParams().getConfidentialText(), litleFont));

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

From source file:org.zaproxy.zap.extension.alertReport.AlertReportExportPDF.java

License:Apache License

private static void addContent(Document document, java.util.List<Alert> alerts,
        ExtensionAlertReportExport extensionExport) throws DocumentException {

    Alert alert = alerts.get(0);// w w  w .j a va  2  s.co m

    Anchor anchor = new Anchor(alert.getAttack(), catFont);
    anchor.setName(alert.getAttack());

    Paragraph content = new Paragraph();
    content.add(new Paragraph(alert.getAlert(), catFont));
    content.add(new Paragraph(
            extensionExport.getMessages().getString("alertreport.export.message.export.pdf.description"),
            subFont));
    content.add(new Paragraph(getFieldAlertProperty(alert.getPluginId(), "description", alert.getDescription(),
            extensionExport)));
    addEmptyLine(content, 1);
    content.add(new Paragraph(
            extensionExport.getMessages().getString("alertreport.export.message.export.pdf.risk"), subFont));
    content.add(new Paragraph(getFieldAlertProperty(alert.getPluginId(),
            "risk." + String.valueOf(alert.getRisk()), Alert.MSG_RISK[alert.getRisk()], extensionExport)));
    addEmptyLine(content, 1);
    content.add(new Paragraph(
            extensionExport.getMessages().getString("alertreport.export.message.export.pdf.reability"),
            subFont));
    content.add(new Paragraph(
            getFieldAlertProperty(alert.getPluginId(), "reliability." + String.valueOf(alert.getReliability()),
                    Alert.MSG_RELIABILITY[alert.getReliability()], extensionExport)));
    addEmptyLine(content, 1);
    content.add(new Paragraph(
            extensionExport.getMessages().getString("alertreport.export.message.export.pdf.urls"), subFont));

    // write all url with the same pluginid
    for (int i = 0; i < alerts.size(); i++) {
        Alert alertAux = alerts.get(i);
        // add url link and attack
        anchor = new Anchor((i + 1) + "-" + alertAux.getUri());
        anchor.setReference(alertAux.getUri());
        content.add(anchor);
        if (!alertAux.getParam().isEmpty()) {
            content.add(
                    new Paragraph("           "
                            + extensionExport.getMessages()
                                    .getString("alertreport.export.message.export.pdf.parameters")
                            + ": " + alertAux.getParam()));
            addEmptyLine(content, 1);
        }
        if (!alertAux.getAttack().isEmpty()) {
            content.add(new Paragraph(
                    extensionExport.getMessages().getString("alertreport.export.message.export.pdf.attack"),
                    subFont));
            content.add(new Paragraph(alertAux.getAttack()));
            addEmptyLine(content, 1);
        }
        // add images test
        addEmptyLine(content, 1);
        String images = alertAux.getOtherInfo();
        if (!images.isEmpty()) {
            String[] list = images.split("\n");
            // for (int j = 0, lengh = list.length/2; j <= lengh; j += 2) {
            for (int j = 0; j < list.length; j++) {
                if (!((j + 1) >= list.length)) {
                    String step = list[j];
                    Paragraph paragraph = new Paragraph(step);
                    content.add(paragraph);
                    addEmptyLine(content, 1);
                    // add step and image
                    String imageName = "";
                    String path = extensionExport.getParams().getWorkingDirImages();
                    if (((j + 1) < list.length) && (!list[j + 1].isEmpty())) {
                        imageName = list[j + 1];
                        // if exist an image
                        try {
                            if ((imageName.endsWith(".png") || imageName.endsWith(".jpg"))
                                    && (!path.isEmpty())) {
                                addImage(content, path + "/" + imageName, 60f);
                                addEmptyLine(content, 1);
                                paragraph = new Paragraph(extensionExport.getMessages()
                                        .getString("alertreport.export.message.export.pdf.image") + ": "
                                        + Integer.toString(j), litleFont);
                                paragraph.setAlignment(Paragraph.ALIGN_CENTER);
                                content.add(paragraph);
                            } else {
                                paragraph = new Paragraph(imageName);
                                content.add(paragraph);
                                addEmptyLine(content, 1);
                            }
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                    j++;
                }

            }
        }

        addEmptyLine(content, 1);

    }
    if (!alert.getSolution().equals("")) {
        addEmptyLine(content, 1);
        content.add(new Paragraph(
                extensionExport.getMessages().getString("alertreport.export.message.export.pdf.solution"),
                subFont));
        content.add(new Paragraph(
                getFieldAlertProperty(alert.getPluginId(), "solution", alert.getSolution(), extensionExport)));
    }
    addEmptyLine(content, 1);
    if (!alert.getReference().equals("")) {
        content.add(new Paragraph(
                extensionExport.getMessages().getString("alertreport.export.message.export.pdf.references"),
                subFont));
        content.add(new Paragraph(alert.getReference()));
        addEmptyLine(content, 1);

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

}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addTitle(Document document) {
    Paragraph titleParagraph = new Paragraph();
    titleParagraph.setAlignment(Paragraph.ALIGN_CENTER);

    TitlePhrase name = new TitlePhrase(getUserFullname(), LifetimeFonts.FONT_HEADER);
    TitlePhrase email = new TitlePhrase(getUserEmail(), LifetimeFonts.FONT_KEY);

    titleParagraph.add(name);//from w w  w. ja  va  2s  .  c o  m
    titleParagraph.add(Chunk.NEWLINE);
    titleParagraph.add(email);
    titleParagraph.add(Chunk.NEWLINE);
    try {
        document.add(titleParagraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addReference(Document document) {
    ValuePhrase position = new ValuePhrase("Position:" + jobOffer.getPosition(), LifetimeFonts.FONT_ORG);
    ValuePhrase reference = new ValuePhrase("Reference:" + jobOffer.getReference(), LifetimeFonts.FONT_DEFAULT);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);/*  ww w .j av a 2s.  co  m*/
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(position);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(reference);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addIntroduction(Document document) {
    TitlePhrase introTitle = new TitlePhrase("Introduction", LifetimeFonts.FONT_BOLD);
    ValuePhrase introduction = new ValuePhrase(letter.getIntroduction(), LifetimeFonts.FONT_DEFAULT);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);/* ww  w .  j a va 2 s.c  om*/
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(introTitle);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(introduction);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addSalutation(Document document) {
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);//  ww  w.  j a va2s  . c o m
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new ValuePhrase("Dear " + jobOffer.getContactTitle() + " " + jobOffer.getContactName()));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}