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());
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations