use of com.itextpdf.text.Phrase 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;
}
use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.
the class DOC002PDF method buildAtividadesAdministrativasTable.
private PdfPTable buildAtividadesAdministrativasTable(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 ADMINISTRATIVAS", fontManager.getBoldFont()));
cellHeader.setPadding(10);
cellHeader.setColspan(3);
table.addCell(cellHeader);
AtividadeAdministrativaDTO[] atividades = teachingDocumentsService.findAllAtividadesAdministrativasByPUD(curriculo.getId());
for (AtividadeAdministrativaDTO 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;
}
use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.
the class DOC002PDF method buildCover.
private void buildCover(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);
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("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.NEXTPAGE);
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
}
use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.
the class DOC002PDF method buildComplamentacaoInstrucaoTable.
private PdfPTable buildComplamentacaoInstrucaoTable(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("COMPLEMENTAÇÃO DA INSTRUÇÃO", fontManager.getBoldFont()));
cellHeader.setPadding(10);
cellHeader.setColspan(3);
table.addCell(cellHeader);
ComplementacaoInstrucaoDTO[] complementacoes = teachingDocumentsService.findAllComplementacoesInstrucaoByPUD(curriculo.getId());
for (ComplementacaoInstrucaoDTO complementacao : complementacoes) {
PdfPCell cellAdministracao;
cellAdministracao = new PdfPCell(new Phrase(complementacao.getDescricao(), fontManager.getDefaultFont()));
cellAdministracao.setPadding(10);
table.addCell(cellAdministracao);
PdfPCell cellCHAtividade;
cellCHAtividade = new PdfPCell(new Phrase(String.valueOf(complementacao.getQuantidadeTemposAula()), fontManager.getDefaultFont()));
cellCHAtividade.setPadding(10);
table.addCell(cellCHAtividade);
PdfPCell cellTecnica;
cellTecnica = new PdfPCell(new Phrase("AE", fontManager.getDefaultFont()));
cellTecnica.setPadding(10);
table.addCell(cellTecnica);
}
return table;
}
use of com.itextpdf.text.Phrase in project trainning by fernandotomasio.
the class DOC002PDF method makeReport.
@Override
public void makeReport() {
teachingDocumentsService = (TeachingDocumentsService) services.get("teachingDocumentsService");
document = documentManager.getDocumentPortrait();
os = documentManager.prepareDocument(document);
writer = documentManager.getWritter();
ChapterSectionTOC eventHandler = new ChapterSectionTOC();
writer.setPageEvent(eventHandler);
document.open();
try {
String curriculoMinimoIdParam = (String) params.get("curriculoMinimoId");
Long curriculoMinimoId = Long.parseLong(curriculoMinimoIdParam);
CurriculoMinimoDTO curriculoMinimo = teachingDocumentsService.findCurriculoMinimo(curriculoMinimoId);
buildCover(document, curriculoMinimo);
buildFrontispicio(document, curriculoMinimo);
document.add(buildPrefacio(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildAbreviaturas(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildDisposicoesPreliminares(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildAtividadesComplementares(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(buildComplementacaoInstrucao(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
// PdfPTable tableAtividadesAvaliativas = buildAtividadesAvaliativasTable(curriculoMinimo);
// document.add(tableAtividadesAvaliativas);
Paragraph p12 = new Paragraph();
p12.add(new Phrase("4 DETALHAMENTO DAS UNIDADES DIDÁTICAS", fontManager.getBoldFont()));
document.add(p12);
document.add(Chunk.NEWLINE);
DisciplinaDTO[] disciplinas = teachingDocumentsService.findAllDisciplinasByCurriculoMinimo(curriculoMinimo.getId());
for (DisciplinaDTO disciplina : disciplinas) {
PdfPTable tableDisciplina = buildTableDisciplina(disciplina);
document.add(tableDisciplina);
document.add(Chunk.NEWLINE);
UnidadeDidaticaDTO[] unidades = teachingDocumentsService.findAllUnidadesDidaticas(disciplina.getId());
PdfPTable unidadesHeaderTable = new PdfPTable(1);
unidadesHeaderTable.setWidthPercentage(100);
PdfPCell p20 = new PdfPCell(new Phrase("UNIDADES DIDÁTICAS", fontManager.getBoldFont()));
unidadesHeaderTable.addCell(p20);
unidadesHeaderTable.setHorizontalAlignment(Element.ALIGN_CENTER);
document.add(unidadesHeaderTable);
document.add(Chunk.NEWLINE);
for (UnidadeDidaticaDTO unidade : unidades) {
PdfPTable tableUnidade = buildTableUnidade(unidade);
document.add(tableUnidade);
document.add(Chunk.NEWLINE);
}
PdfPTable tableRecomendacoes = buildTableRecomendacoesMetodologicas(disciplina);
document.add(tableRecomendacoes);
document.add(Chunk.NEWLINE);
PdfPTable perfisTable = buildTablePerfisRelacionamento(disciplina);
document.add(perfisTable);
document.add(Chunk.NEWLINE);
PdfPTable referenciasTable = buildTableReferencias(disciplina);
document.add(referenciasTable);
document.add(Chunk.NEXTPAGE);
}
document.add(Chunk.NEXTPAGE);
document.add(buildDisposicoesFinais(curriculoMinimo));
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
document.add(buildAssinatura());
document.add(Chunk.NEXTPAGE);
document.add(buildSumario(eventHandler.titles));
} catch (DocumentException e) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
throw new CoreException(e.getMessage());
} finally {
document.close();
}
try {
PdfReader reader = new PdfReader(os.toByteArray());
int n = reader.getNumberOfPages();
String pagesInterval = String.format("1-4,%d, 5-%d", n, n - 1);
reader.selectPages(pagesInterval);
os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
stamper.close();
reader.close();
} catch (IOException ex) {
Logger.getLogger(DOC002PDF.class.getName()).log(Level.SEVERE, null, ex);
} catch (DocumentException ex) {
Logger.getLogger(DOC002PDF.class.getName()).log(Level.SEVERE, null, ex);
}
try {
PdfReader reader = new PdfReader(os.toByteArray());
os = new ByteArrayOutputStream();
PdfStamper stamper = new PdfStamper(reader, os);
int total = reader.getNumberOfPages();
PdfContentByte over = null;
int total_pages = total - 1;
for (int i = 1; i < total; i++) {
int actual_page = i - 1;
if (i > 5) {
over = stamper.getOverContent(i);
System.out.println(over);
over.beginText();
BaseFont baseFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "UTF-8", false);
over.setFontAndSize(baseFont, 12);
if ((i % 2) == 0) {
over.showTextAligned(PdfContentByte.ALIGN_RIGHT, actual_page + "/" + total_pages, 538, 803, 0);
} else {
over.showTextAligned(PdfContentByte.ALIGN_LEFT, actual_page + "/" + total_pages, 58, 803, 0);
}
over.endText();
}
}
// PdfContentByte content = stamper.getOverContent(1);
// ColumnText ct = new ColumnText( content );
// ct.setSimpleColumn(50,50,50,50);
// ct.setText(new Phrase("TESTANDO"));
// ct.go();
stamper.close();
reader.close();
} catch (IOException ex) {
// Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
} catch (DocumentException ex) {
Logger.getLogger(DOC001PDF.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations