use of com.itextpdf.text.BadElementException in project MtgDesktopCompanion by nicho92.
the class PDFExport method getCells.
private PdfPCell getCells(MagicCard card) throws BadElementException, IOException {
Image image1 = null;
try {
image1 = Image.getInstance(MTGControler.getInstance().getEnabledPicturesProvider().getPicture(card, null), null);
} catch (Exception e) {
image1 = Image.getInstance(MTGControler.getInstance().getEnabledPicturesProvider().getBackPicture(), null);
}
image1.scalePercent(60);
PdfPCell cell = new PdfPCell(image1, false);
cell.setBorder(0);
cell.setPadding(5);
return cell;
}
use of com.itextpdf.text.BadElementException 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.BadElementException in project trainning by fernandotomasio.
the class DOC001PDF method buildCover.
private void buildCover(Document document, CurriculoMinimoDTO curriculoMinimo) throws DocumentException {
Paragraph spaceParagraph = new Paragraph();
spaceParagraph.add(new Phrase("\n"));
document.add(spaceParagraph);
document.add(spaceParagraph);
document.add(spaceParagraph);
document.add(spaceParagraph);
document.add(spaceParagraph);
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(Chunk.NEWLINE);
// 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);
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.5f);
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);
Paragraph p4 = new Paragraph();
p4.setAlignment(Element.ALIGN_CENTER);
p4.add(new Phrase("ENSINO", fontManager.getH0Font()));
document.add(p4);
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
PdfPTable t = new PdfPTable(1);
t.setTotalWidth(286);
t.setLockedWidth(true);
PdfPCell unica = new PdfPCell();
unica.setFixedHeight(140);
unica.setPaddingTop(5);
unica.setVerticalAlignment(Element.ALIGN_MIDDLE);
Paragraph p5 = new Paragraph();
p5.setAlignment(Element.ALIGN_CENTER);
p5.add(new Phrase(curriculoMinimo.getNumeroPublicacaoCM(), fontManager.getSmallXBoldFont()));
Paragraph p6 = new Paragraph();
p6.setAlignment(Element.ALIGN_CENTER);
p6.add(new Phrase("CURRÍCULO MÍNIMO DO CURSO " + curriculoMinimo.getCurso().getDescricao(), fontManager.getSmallXBoldFont()));
Paragraph p7 = new Paragraph();
p7.setAlignment(Element.ALIGN_CENTER);
p7.add(new Phrase(curriculoMinimo.getCurso().getCodigo(), fontManager.getSmallXBoldFont()));
Paragraph p8 = new Paragraph();
p8.setAlignment(Element.ALIGN_CENTER);
p8.add(new Phrase(curriculoMinimo.getAnoPublicacaoCM(), fontManager.getSmallXBoldFont()));
unica.addElement(p5);
unica.addElement(Chunk.NEWLINE);
unica.addElement(p6);
unica.addElement(p7);
unica.addElement(Chunk.NEWLINE);
unica.addElement(p8);
t.addCell(unica);
document.add(t);
// document.add(Chunk.NEXTPAGE);
//
// document.add(buildPrefacio(curriculoMinimo));
document.add(Chunk.NEXTPAGE);
document.add(Chunk.NEXTPAGE);
}
use of com.itextpdf.text.BadElementException 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.BadElementException in project trainning by fernandotomasio.
the class DOC001PDF method buildFrontispicio.
private void buildFrontispicio(Document document, CurriculoMinimoDTO curriculoMinimo) throws DocumentException {
Paragraph spaceParagraph = new Paragraph();
spaceParagraph.add(new Phrase("\n"));
document.add(spaceParagraph);
document.add(spaceParagraph);
document.add(spaceParagraph);
document.add(spaceParagraph);
document.add(spaceParagraph);
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);
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.5f);
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);
Paragraph p4 = new Paragraph();
p4.setAlignment(Element.ALIGN_CENTER);
p4.add(new Phrase("ENSINO", fontManager.getH0Font()));
document.add(p4);
document.add(Chunk.NEWLINE);
document.add(Chunk.NEWLINE);
PdfPTable t = new PdfPTable(1);
t.setTotalWidth(286);
t.setLockedWidth(true);
PdfPCell unica = new PdfPCell();
unica.setFixedHeight(140);
unica.setPadding(10);
unica.setVerticalAlignment(Element.ALIGN_MIDDLE);
Paragraph p5 = new Paragraph();
p5.setAlignment(Element.ALIGN_CENTER);
p5.add(new Phrase(curriculoMinimo.getNumeroPublicacaoCM(), fontManager.getSmallXBoldFont()));
Paragraph p6 = new Paragraph();
p6.setAlignment(Element.ALIGN_CENTER);
p6.add(new Phrase("CURRÍCULO MÍNIMO DO CURSO " + curriculoMinimo.getCurso().getDescricao(), fontManager.getSmallXBoldFont()));
Paragraph p7 = new Paragraph();
p7.setAlignment(Element.ALIGN_CENTER);
p7.add(new Phrase(curriculoMinimo.getCurso().getCodigo(), fontManager.getSmallXBoldFont()));
Paragraph p8 = new Paragraph();
p8.setAlignment(Element.ALIGN_CENTER);
p8.add(new Phrase(curriculoMinimo.getAnoPublicacaoCM(), fontManager.getSmallXBoldFont()));
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);
}
Aggregations