Search in sources :

Example 51 with Paragraph

use of com.itextpdf.text.Paragraph 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 52 with Paragraph

use of com.itextpdf.text.Paragraph 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 53 with Paragraph

use of com.itextpdf.text.Paragraph 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 54 with Paragraph

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

the class IReportUtil method fillChapter.

public static Chapter fillChapter(Chapter ch, String text) {
    if (text != null && text.length() > 0) {
        String[] split = text.split("\n");
        int countParagraphs = 0;
        for (String item : split) {
            if (item.length() > 1) {
                char c = item.charAt(1);
                if (c != '-' && c != ')' && c != '.') {
                    countParagraphs++;
                }
            }
        }
        if (countParagraphs > 1) {
            for (String item : split) {
                if (item.length() > 1) {
                    char c = item.charAt(1);
                    if (c == '-' || c == ')' || c == '.') {
                        Paragraph p = new Paragraph(item, fontManager.getDefaultFont());
                        p.setIndentationLeft(50);
                        p.setAlignment(Element.ALIGN_JUSTIFIED);
                        ch.add(p);
                    } else {
                        Paragraph p = new Paragraph(item, fontManager.getDefaultFont());
                        p.setAlignment(Element.ALIGN_JUSTIFIED);
                        ch.addSection(p);
                    }
                }
            }
        } else {
            for (String item : split) {
                if (item.length() > 1) {
                    char c = item.charAt(1);
                    if (c == '-' || c == ')' || c == '.') {
                        Paragraph p = new Paragraph(item, fontManager.getDefaultFont());
                        p.setIndentationLeft(50);
                        p.setAlignment(Element.ALIGN_JUSTIFIED);
                        ch.add(p);
                    } else {
                        Paragraph p = new Paragraph(item, fontManager.getDefaultFont());
                        p.setFirstLineIndent(50);
                        p.setAlignment(Element.ALIGN_JUSTIFIED);
                        ch.add(p);
                    }
                }
            }
        }
    }
    return ch;
}
Also used : Paragraph(com.itextpdf.text.Paragraph)

Example 55 with Paragraph

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

the class IReportUtil method fillChapterWithoutNumbers.

public static Chapter fillChapterWithoutNumbers(Chapter ch, String text) {
    if (text != null && text.length() > 0) {
        String[] split = text.split("\n");
        int countParagraphs = 0;
        for (String item : split) {
            if (item.length() > 1) {
                char c = item.charAt(1);
                if (c != '-' && c != ')' && c != '.') {
                    countParagraphs++;
                }
            }
        }
        for (String item : split) {
            if (item.length() > 1) {
                char c = item.charAt(1);
                if (c == '-' || c == ')' || c == '.') {
                    Paragraph p = new Paragraph(item, fontManager.getDefaultFont());
                    p.setIndentationLeft(50);
                    p.setAlignment(Element.ALIGN_JUSTIFIED);
                    ch.add(p);
                } else {
                    Paragraph p = new Paragraph(item, fontManager.getDefaultFont());
                    p.setFirstLineIndent(50);
                    p.setAlignment(Element.ALIGN_JUSTIFIED);
                    ch.add(p);
                }
            }
        }
    }
    return ch;
}
Also used : Paragraph(com.itextpdf.text.Paragraph)

Aggregations

Paragraph (com.itextpdf.text.Paragraph)67 Chapter (com.itextpdf.text.Chapter)25 PdfPTable (com.itextpdf.text.pdf.PdfPTable)18 Phrase (com.itextpdf.text.Phrase)14 PdfPCell (com.itextpdf.text.pdf.PdfPCell)13 Font (com.itextpdf.text.Font)11 IOException (java.io.IOException)11 DocumentException (com.itextpdf.text.DocumentException)10 Section (com.itextpdf.text.Section)10 Document (com.itextpdf.text.Document)8 ArrayList (java.util.ArrayList)8 ListItem (com.itextpdf.text.ListItem)7 BaseFont (com.itextpdf.text.pdf.BaseFont)7 FileOutputStream (java.io.FileOutputStream)7 List (com.itextpdf.text.List)6 Chunk (com.itextpdf.text.Chunk)5 Image (com.itextpdf.text.Image)5 PdfWriter (com.itextpdf.text.pdf.PdfWriter)5 ObjetivoDisciplinaDTO (com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO)5 SubunidadeDidaticaDTO (com.tomasio.projects.trainning.dto.SubunidadeDidaticaDTO)5