Search in sources :

Example 31 with PdfPTable

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

the class DOC002PDF method buildFrontispicio.

private void buildFrontispicio(Document document, CurriculoMinimoDTO curriculoMinimo) throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    Paragraph p1 = new Paragraph();
    p1.setAlignment(Element.ALIGN_CENTER);
    p1.add(new Phrase("MINISTÉRIO DA DEFESA", fontManager.getH1Font()));
    document.add(p1);
    Paragraph p2 = new Paragraph();
    p2.setAlignment(Element.ALIGN_CENTER);
    p2.add(new Phrase("COMANDO DA AERONÁUTICA", fontManager.getH1Font()));
    document.add(p2);
    Paragraph p3 = new Paragraph();
    p3.setAlignment(Element.ALIGN_CENTER);
    p3.add(new Phrase("DEPARTAMENTO DE CONTROLE DO ESPAÇO AÉREO", fontManager.getDefaultFont()));
    document.add(p3);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        String path = classLoader.getResource("aer.png").getPath();
        Image image = Image.getInstance(path);
        image.setAlignment(Element.ALIGN_CENTER);
        image.scalePercent(18);
        document.add(image);
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
    }
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    Paragraph p4 = new Paragraph();
    p4.setAlignment(Element.ALIGN_CENTER);
    p4.add(new Phrase("ENSINO", fontManager.getH1Font()));
    document.add(p4);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
    PdfPTable t = new PdfPTable(1);
    PdfPCell unica = new PdfPCell();
    unica.setPadding(10);
    // Paragraph p5 = new Paragraph();
    // p5.setAlignment(Element.ALIGN_CENTER);
    // p5.add(new Phrase("ICA 56-3", fontManager.getDefaultFont()));
    // p5.add(Chunk.NEWLINE);
    Paragraph p6 = new Paragraph();
    p6.setAlignment(Element.ALIGN_CENTER);
    // p6.add(new Phrase(curriculoMinimo.getCurso().getDescricao(), fontManager.getDefaultFont()));
    // Paragraph p7 = new Paragraph();
    // p7.setAlignment(Element.ALIGN_CENTER);
    // p7.add(new Phrase("PLANO DE UNIDADES DIDÁTICAS DO CURSO " + curriculoMinimo.getCurso().getCodigo(), fontManager.getDefaultFont()));
    // Paragraph p8 = new Paragraph();
    // p8.setAlignment(Element.ALIGN_CENTER);
    // p8.add(new Phrase(curriculoMinimo.getAnoPublicacaoPUD(), fontManager.getDefaultFont()));
    p6.add(new Phrase("PLANO DE UNIDADES DIDÁTICAS DO CURSO " + curriculoMinimo.getCurso().getDescricao(), fontManager.getDefaultFont()));
    Paragraph p7 = new Paragraph();
    p7.setAlignment(Element.ALIGN_CENTER);
    p7.add(new Phrase(curriculoMinimo.getCurso().getCodigo(), fontManager.getDefaultFont()));
    Paragraph p8 = new Paragraph();
    p8.setAlignment(Element.ALIGN_CENTER);
    p8.add(new Phrase(curriculoMinimo.getAnoPublicacaoPUD(), fontManager.getDefaultFont()));
    // unica.addElement(p5);
    unica.addElement(Chunk.NEWLINE);
    unica.addElement(p6);
    unica.addElement(p7);
    unica.addElement(Chunk.NEWLINE);
    unica.addElement(p8);
    unica.addElement(Chunk.NEWLINE);
    t.addCell(unica);
    document.add(t);
    // document.add(Chunk.NEXTPAGE);
    // 
    // document.add(buildPrefacio(curriculoMinimo));
    document.add(Chunk.NEXTPAGE);
    document.add(Chunk.NEWLINE);
    document.add(Chunk.NEWLINE);
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) PdfPTable(com.itextpdf.text.pdf.PdfPTable) BadElementException(com.itextpdf.text.BadElementException) Phrase(com.itextpdf.text.Phrase) IOException(java.io.IOException) Image(com.itextpdf.text.Image) Paragraph(com.itextpdf.text.Paragraph)

Example 32 with PdfPTable

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

the class DOC002PDF method buildTableReferencias.

private PdfPTable buildTableReferencias(DisciplinaDTO disciplina) {
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(100);
    PdfPCell cellHeader;
    cellHeader = new PdfPCell(new Phrase("REFERÊNCIAS", fontManager.getBoldFont()));
    cellHeader.setPadding(10);
    table.addCell(cellHeader);
    PdfPCell cellContent;
    cellContent = new PdfPCell();
    ReferenciaDTO[] referencias = teachingDocumentsService.findAllReferenciasByDisciplina(disciplina.getId());
    for (ReferenciaDTO referencia : referencias) {
        Paragraph referenciaParagraph = new Paragraph(referencia.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) ReferenciaDTO(com.tomasio.projects.trainning.dto.ReferenciaDTO) Phrase(com.itextpdf.text.Phrase) Paragraph(com.itextpdf.text.Paragraph)

Example 33 with PdfPTable

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

the class EXC001IReport method makeReport.

@Override
public void makeReport() {
    AtividadesEnsinoService service = (AtividadesEnsinoService) services.get("atividadesEnsinoService");
    OrganizationalService organizationalService = (OrganizationalService) services.get("organizationalService");
    document = documentManager.getDocumentPortrait();
    os = documentManager.prepareDocument(document);
    writer = documentManager.getWritter();
    document.open();
    Long turmaId = (Long) params.get("turmaId");
    TurmaDTO turma = service.findTurmaEfetiva(turmaId);
    IndicacaoDTO[] indicacoes = service.findAllIndicacoesAlunos(turmaId);
    try {
        Paragraph p = null;
        p = new Paragraph(ReportUtil.convertEncode(turma.getCurso().getCodigo()) + " - " + ReportUtil.convertEncode(turma.getCurso().getDescricao()), fontManager.getH1Font());
        p.setAlignment(Element.ALIGN_LEFT);
        document.add(p);
        PdfPTable tableIndicacoes = new PdfPTable(4);
        tableIndicacoes.addCell(tableManager.getHeaderCell("Nome"));
        tableIndicacoes.addCell(tableManager.getHeaderCell("Nome de Guerra"));
        tableIndicacoes.addCell(tableManager.getHeaderCell("SARAM"));
        tableIndicacoes.addCell(tableManager.getHeaderCell("CPF"));
        tableIndicacoes.addCell(tableManager.getHeaderCell("Organização"));
        for (IndicacaoDTO indicacao : indicacoes) {
            PessoaDTO pessoa = organizationalService.findPessoa(indicacao.getPessoa().getId());
            String nomeGuerra = pessoa.getNomeGuerra();
            if (nomeGuerra == null) {
                nomeGuerra = "";
            }
            tableIndicacoes.addCell(tableManager.getPhraseCellLeft(pessoa.getTargetaCompleta()));
            tableIndicacoes.addCell(tableManager.getPhraseCellCenter(nomeGuerra));
            tableIndicacoes.addCell(tableManager.getPhraseCellCenter(pessoa.getSaram()));
            tableIndicacoes.addCell(tableManager.getPhraseCellCenter(pessoa.getCpf()));
            OrganizacaoDTO organizacao = organizationalService.findOrganizacao(indicacao.getOrganizacao().getId());
            tableIndicacoes.addCell(tableManager.getPhraseCellCenter(organizacao.getSigla()));
        }
        document.add(tableIndicacoes);
    } catch (DocumentException ex) {
        Logger.getLogger(EXC001IReport.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        document.close();
    }
}
Also used : TurmaDTO(com.tomasio.projects.trainning.dto.TurmaDTO) IndicacaoDTO(com.tomasio.projects.trainning.dto.IndicacaoDTO) Paragraph(com.itextpdf.text.Paragraph) PdfPTable(com.itextpdf.text.pdf.PdfPTable) PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) OrganizationalService(com.tomasio.projects.trainning.interfaces.OrganizationalService) DocumentException(com.itextpdf.text.DocumentException) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO) AtividadesEnsinoService(com.tomasio.projects.trainning.interfaces.AtividadesEnsinoService)

Example 34 with PdfPTable

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

the class PageFooter method onEndPage.

@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfPTable table = new PdfPTable(3);
    try {
        table.setWidths(new int[] { 24, 24, 2 });
        table.setTotalWidth(527);
        table.setLockedWidth(true);
        table.getDefaultCell().setFixedHeight(20);
        table.getDefaultCell().setBorder(Rectangle.BOTTOM);
        table.addCell(header);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(String.format("Pg %d de", writer.getPageNumber()));
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.BOTTOM);
        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)

Example 35 with PdfPTable

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

the class PUDPageFooter 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() > 5) {
    // if (writer.getPageNumber() >= 11
    // && writer.getPageNumber() <= 14) {
    // anexo ="Anexo A - Relação dos Cursos Previstos";
    // } else if (writer.getPageNumber() >= 15
    // && writer.getPageNumber() <= 251) {
    // anexo = "Anexo B - Cronograma e Folha de Rosto";
    // } else if (writer.getPageNumber() == 252) {
    // anexo ="Anexo C - Modelo de Ficha de Indicação CNS014";
    // }
    // if (writer.getPageNumber() % 2 != 0) {
    // table.addCell(new Phrase("", 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("", 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);
    // table.writeSelectedRows(0, -1,
    // 34, 803, 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)

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