Search in sources :

Example 11 with PdfPTable

use of com.itextpdf.text.pdf.PdfPTable in project trainning by fernandotomasio.

the class ApostilaDECEAPageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfContentByte canvas = writer.getDirectContentUnder();
    Image imageBottom;
    Image imageTop;
    Image imageCover;
    try {
        imageTop = Image.getInstance(IMAGE_TOP);
        imageTop.scaleAbsoluteHeight(42);
        imageBottom = Image.getInstance(IMAGE_BOTTOM);
        imageBottom.scaleAbsoluteHeight(14);
        imageCover = Image.getInstance(IMAGE_COVER);
        imageCover.scalePercent(30.3f);
        if (writer.getPageNumber() > 2) {
            // image.scaleAbsolute(PageSize.A4.rotate());
            imageBottom.setAbsolutePosition(0, 0);
            imageTop.setAbsolutePosition(0, 800);
            canvas.addImage(imageBottom);
            canvas.addImage(imageTop);
        } else {
            if (writer.getPageNumber() == 1) {
                imageCover.setAbsolutePosition(0, 490);
                canvas.addImage(imageCover);
            }
        }
    } catch (BadElementException ex) {
        Logger.getLogger(ApostilaDECEAPageFooter.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ApostilaDECEAPageFooter.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(ApostilaDECEAPageFooter.class.getName()).log(Level.SEVERE, null, ex);
    }
    PdfPTable table = new PdfPTable(1);
    table.setTotalWidth(527);
    table.setLockedWidth(true);
    table.getDefaultCell().setFixedHeight(20);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    if (writer.getPageNumber() > 2) {
        PdfPCell numberCell = new PdfPCell(new Phrase(String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 129, 201))));
        numberCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        numberCell.setBorder(Rectangle.NO_BORDER);
        table.addCell(numberCell);
    }
    table.writeSelectedRows(0, -1, 0, 34, writer.getDirectContent());
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) BaseColor(com.itextpdf.text.BaseColor) PdfPTable(com.itextpdf.text.pdf.PdfPTable) BadElementException(com.itextpdf.text.BadElementException) DocumentException(com.itextpdf.text.DocumentException) PdfContentByte(com.itextpdf.text.pdf.PdfContentByte) IOException(java.io.IOException) Phrase(com.itextpdf.text.Phrase) Image(com.itextpdf.text.Image) Font(com.itextpdf.text.Font)

Example 12 with PdfPTable

use of com.itextpdf.text.pdf.PdfPTable in project trainning by fernandotomasio.

the class CMPageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 40, 80, 20 });
        table.setTotalWidth(450);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(18);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        String anexo = "";
        if ((writer.getPageNumber() % 2) == 0) {
            document.setMargins(85, 56, 56, 85);
        } else {
            document.setMargins(56, 85, 56, 85);
        }
    // if (writer.getPageNumber() > 6) {
    // 
    // if (writer.getPageNumber() % 2 != 0) {
    // table.addCell(new Phrase(header, new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // 
    // table.getDefaultCell().setHorizontalAlignment(
    // Element.ALIGN_RIGHT);
    // PdfPCell anexoCell = new PdfPCell(new Phrase(
    // String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // anexoCell.setBorder(Rectangle.NO_BORDER);
    // table.addCell(anexoCell);
    // 
    // //                    table.addCell(new Phrase(
    // //                            String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // 
    // 
    // } else {
    // table.addCell(new Phrase(
    // String.format("%d", writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // table.getDefaultCell().setHorizontalAlignment(
    // Element.ALIGN_RIGHT);
    // PdfPCell anexoCell = new PdfPCell(new Phrase(
    // String.format(anexo, writer.getPageNumber()), new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // anexoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // anexoCell.setBorder(Rectangle.NO_BORDER);
    // table.addCell(anexoCell);
    // 
    // table.addCell(new Phrase(header, new Font(Font.FontFamily.TIMES_ROMAN, 12)));
    // //table.getDefaultCell().setHorizontalAlignment(
    // //      Element.ALIGN_RIGHT);
    // 
    // }
    // 
    // }
    // 
    // PdfPCell cell = new PdfPCell(Image.getInstance(total));
    // cell.setBorder(Rectangle.NO_BORDER);
    // //table.addCell(cell);
    // 
    // if((writer.getPageNumber() % 2) == 0){
    // table.writeSelectedRows(0, -1,
    // 56, 817, writer.getDirectContent());
    // }else{
    // table.writeSelectedRows(0, -1,
    // 85, 817, writer.getDirectContent());
    // }
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}
Also used : ExceptionConverter(com.itextpdf.text.ExceptionConverter) PdfPTable(com.itextpdf.text.pdf.PdfPTable) DocumentException(com.itextpdf.text.DocumentException)

Example 13 with PdfPTable

use of com.itextpdf.text.pdf.PdfPTable in project trainning by fernandotomasio.

the class DOC002PDF method buildComplementacaoInstrucao.

private Chapter buildComplementacaoInstrucao(CurriculoMinimoDTO curriculo) throws DocumentException {
    Chapter ch = new Chapter(new Paragraph("COMPLEMENTAÇÃO DA INSTRUÇÃO", fontManager.getBoldFont()), 3);
    ch.add(Chunk.NEWLINE);
    PdfPTable tableComplementacaoInstrucao = buildComplamentacaoInstrucaoTable(curriculo);
    ch.add(tableComplementacaoInstrucao);
    ch.add(Chunk.NEWLINE);
    PdfPTable tableFlexibilidade = buildFlexibilidadeTable(curriculo);
    ch.add(tableFlexibilidade);
    return ch;
}
Also used : PdfPTable(com.itextpdf.text.pdf.PdfPTable) Chapter(com.itextpdf.text.Chapter) Paragraph(com.itextpdf.text.Paragraph)

Example 14 with PdfPTable

use of com.itextpdf.text.pdf.PdfPTable in project trainning by fernandotomasio.

the class DOC002PDF method buildTableRecomendacoesMetodologicas.

private PdfPTable buildTableRecomendacoesMetodologicas(DisciplinaDTO disciplina) {
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100);
    PdfPCell cellHeader;
    cellHeader = new PdfPCell(new Phrase("RECOMENDACÕES METODOLÓGICAS", fontManager.getBoldFont()));
    cellHeader.setPadding(10);
    table.addCell(cellHeader);
    PdfPCell cellContent;
    cellContent = new PdfPCell();
    RecomendacaoMetodologicaDTO[] recomendacoes = teachingDocumentsService.findAllRecomendacoesMetodologicasByDisciplina(disciplina.getId());
    for (RecomendacaoMetodologicaDTO recomendacao : recomendacoes) {
        Paragraph referenciaParagraph = new Paragraph(recomendacao.getTexto(), fontManager.getDefaultFont());
        cellContent.addElement(referenciaParagraph);
    }
    cellContent.setPadding(10);
    table.addCell(cellContent);
    return table;
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) PdfPTable(com.itextpdf.text.pdf.PdfPTable) RecomendacaoMetodologicaDTO(com.tomasio.projects.trainning.dto.RecomendacaoMetodologicaDTO) Phrase(com.itextpdf.text.Phrase) Paragraph(com.itextpdf.text.Paragraph)

Example 15 with PdfPTable

use of com.itextpdf.text.pdf.PdfPTable in project trainning by fernandotomasio.

the class DOC002PDF method buildAtividadesAvaliativasTable.

private PdfPTable buildAtividadesAvaliativasTable(CurriculoMinimoDTO curriculo) throws DocumentException {
    PdfPTable table = new PdfPTable(3);
    table.setWidths(new int[] { 4, 1, 1 });
    table.setWidthPercentage(100);
    PdfPCell cellHeader;
    cellHeader = new PdfPCell(new Phrase("ATIVIDADES AVALIATIVAS", fontManager.getBoldFont()));
    cellHeader.setPadding(10);
    cellHeader.setColspan(3);
    table.addCell(cellHeader);
    AtividadeAvaliativaDTO[] atividades = teachingDocumentsService.findAllAtividadesAvaliativasByPUD(curriculo.getId());
    for (AtividadeAvaliativaDTO atividade : atividades) {
        PdfPCell cellAdministracao;
        cellAdministracao = new PdfPCell(new Phrase(atividade.getDescricao(), fontManager.getDefaultFont()));
        cellAdministracao.setPadding(10);
        table.addCell(cellAdministracao);
        PdfPCell cellCHAtividade;
        cellCHAtividade = new PdfPCell(new Phrase(String.valueOf(atividade.getQuantidadeTemposAula()), fontManager.getDefaultFont()));
        cellCHAtividade.setPadding(10);
        table.addCell(cellCHAtividade);
        PdfPCell cellTecnica;
        cellTecnica = new PdfPCell(new Phrase("CH", fontManager.getDefaultFont()));
        cellTecnica.setPadding(10);
        table.addCell(cellTecnica);
    }
    return table;
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) AtividadeAvaliativaDTO(com.tomasio.projects.trainning.dto.AtividadeAvaliativaDTO) PdfPTable(com.itextpdf.text.pdf.PdfPTable) Phrase(com.itextpdf.text.Phrase)

Aggregations

PdfPTable (com.itextpdf.text.pdf.PdfPTable)44 PdfPCell (com.itextpdf.text.pdf.PdfPCell)24 Paragraph (com.itextpdf.text.Paragraph)18 Phrase (com.itextpdf.text.Phrase)17 DocumentException (com.itextpdf.text.DocumentException)12 Font (com.itextpdf.text.Font)8 IOException (java.io.IOException)8 ExceptionConverter (com.itextpdf.text.ExceptionConverter)6 Document (com.itextpdf.text.Document)5 BadElementException (com.itextpdf.text.BadElementException)4 BaseFont (com.itextpdf.text.pdf.BaseFont)4 PdfContentByte (com.itextpdf.text.pdf.PdfContentByte)4 PdfWriter (com.itextpdf.text.pdf.PdfWriter)4 FileOutputStream (java.io.FileOutputStream)4 BaseColor (com.itextpdf.text.BaseColor)3 Chapter (com.itextpdf.text.Chapter)3 Chunk (com.itextpdf.text.Chunk)3 Image (com.itextpdf.text.Image)3 ListItem (com.itextpdf.text.ListItem)3 PdfReader (com.itextpdf.text.pdf.PdfReader)3