Search in sources :

Example 46 with Phrase

use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.

the class CustomTableManager method getPhraseCellLeft.

@Override
public PdfPCell getPhraseCellLeft(String content) {
    PdfPCell c = new PdfPCell(new Phrase(ReportUtil.convertEncode(content), fontManager.getDefaultFont()));
    c.setLeading(12f, 0);
    c.setPadding(5);
    c.setHorizontalAlignment(Element.ALIGN_LEFT);
    c.setVerticalAlignment(Element.ALIGN_MIDDLE);
    return c;
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) Phrase(com.itextpdf.text.Phrase)

Example 47 with Phrase

use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.

the class CustomTableManager method getHeaderCell.

@Override
public PdfPCell getHeaderCell(String title) {
    PdfPCell header = new PdfPCell(new Phrase(ReportUtil.convertEncode(title), fontManager.getDefaultFont()));
    header.setHorizontalAlignment(Element.ALIGN_CENTER);
    header.setVerticalAlignment(Element.ALIGN_MIDDLE);
    return header;
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) Phrase(com.itextpdf.text.Phrase)

Example 48 with Phrase

use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.

the class TCAPageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 20, 80, 20 });
        table.setTotalWidth(527);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(20);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        String anexo = "";
        if (writer.getPageNumber() >= 8 && writer.getPageNumber() <= 11) {
            anexo = "Anexo A - Relação de cursos previstos";
        } else if (writer.getPageNumber() >= 8 && writer.getPageNumber() <= 224) {
            anexo = "Anexo B - Folha de Rosto dos Cursos Previstos";
        } else if (writer.getPageNumber() == 225) {
            anexo = "Anexo C - Modelo de Ficha de Indicação CNS014";
        }
        if (writer.getPageNumber() % 2 != 0) {
            table.addCell(new Phrase(header, new Font(Font.FontFamily.HELVETICA, 10)));
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            PdfPCell anexoCell = new PdfPCell(new Phrase(String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.HELVETICA, 10)));
            anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            anexoCell.setBorder(Rectangle.NO_BORDER);
            table.addCell(anexo);
            table.addCell(new Phrase(String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.HELVETICA, 10)));
        } else {
            table.addCell(new Phrase(String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.HELVETICA, 10)));
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            PdfPCell anexoCell = new PdfPCell(new Phrase(String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.HELVETICA, 10)));
            anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            anexoCell.setBorder(Rectangle.NO_BORDER);
            table.addCell(anexo);
            table.addCell(new Phrase(header, new Font(Font.FontFamily.HELVETICA, 10)));
        // table.getDefaultCell().setHorizontalAlignment(
        // Element.ALIGN_RIGHT);
        }
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.NO_BORDER);
        // table.addCell(cell);
        table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent());
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPCell(com.itextpdf.text.pdf.PdfPCell) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException) Phrase(com.itextpdf.text.Phrase) Font(com.itextpdf.text.Font)

Example 49 with Phrase

use of com.itextpdf.text.Phrase in project saga by timurstrekalov.

the class PdfReporter method createFooter.

private Element createFooter() {
    final Paragraph footer = new Paragraph();
    footer.add(new Phrase("Generated using ", FONT_FOOTER));
    final Anchor a = new Anchor(config.getProperty("app.name"), FONT_FOOTER);
    a.setReference("http://timurstrekalov.github.com/saga/");
    footer.add(a);
    footer.add(new Phrase(" version " + config.getProperty("app.version"), FONT_FOOTER));
    footer.setAlignment(Element.ALIGN_RIGHT);
    return footer;
}
Also used : Anchor(com.itextpdf.text.Anchor) Phrase(com.itextpdf.text.Phrase) Paragraph(com.itextpdf.text.Paragraph)

Example 50 with Phrase

use of com.itextpdf.text.Phrase in project saga by timurstrekalov.

the class PdfReporter method addFileStatsRows.

private void addFileStatsRows(final TestRunCoverageStatistics runStats, final PdfPTable table) {
    final List<ScriptCoverageStatistics> allFileStats = runStats.getFileStats();
    for (int i = 0; i < allFileStats.size(); i++) {
        final ScriptCoverageStatistics scriptCoverageStatistics = allFileStats.get(i);
        final boolean hasStatements = scriptCoverageStatistics.getHasStatements();
        final Phrase fileName = new Phrase();
        if (scriptCoverageStatistics.getParentName() != null) {
            fileName.add(new Chunk(scriptCoverageStatistics.getParentName() + "/", hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE));
            fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD_BOLD : FONT_TD_BOLD_EMPTY_FILE));
        } else {
            fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE));
        }
        final BaseColor bgColor = (i % 2 == 1) ? COLOR_ROW_ODD : COLOR_ROW_EVEN;
        final Font font = FONT_TD;
        table.addCell(createCell(fileName, 0, bgColor));
        table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getStatements()), font, 1, bgColor));
        table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getExecuted()), font, 2, bgColor));
        table.addCell(createCell(scriptCoverageStatistics.getCoverage() + "%", FONT_TD, 3, bgColor));
    }
}
Also used : BaseColor(com.itextpdf.text.BaseColor) Phrase(com.itextpdf.text.Phrase) Chunk(com.itextpdf.text.Chunk) Font(com.itextpdf.text.Font) ScriptCoverageStatistics(com.github.timurstrekalov.saga.core.model.ScriptCoverageStatistics)

Aggregations

Phrase (com.itextpdf.text.Phrase)50 PdfPCell (com.itextpdf.text.pdf.PdfPCell)42 PdfPTable (com.itextpdf.text.pdf.PdfPTable)17 Paragraph (com.itextpdf.text.Paragraph)14 Image (com.itextpdf.text.Image)7 IOException (java.io.IOException)7 Chunk (com.itextpdf.text.Chunk)6 Font (com.itextpdf.text.Font)6 BadElementException (com.itextpdf.text.BadElementException)5 DocumentException (com.itextpdf.text.DocumentException)5 ArrayList (java.util.ArrayList)5 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)4 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)4 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)4 ObjetivoDisciplinaDTO (com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO)4 BaseColor (com.itextpdf.text.BaseColor)3 List (com.itextpdf.text.List)3 ListItem (com.itextpdf.text.ListItem)3 BaseFont (com.itextpdf.text.pdf.BaseFont)3 PdfContentByte (com.itextpdf.text.pdf.PdfContentByte)3