use of com.itextpdf.text.Image in project bamboobsc by billchen198318.
the class OrganizationReportPdfCommand method putSignature.
private void putSignature(PdfPTable table, Context context) throws Exception {
String uploadOid = (String) context.get("uploadSignatureOid");
if (StringUtils.isBlank(uploadOid)) {
return;
}
byte[] imageBytes = UploadSupportUtils.getDataBytes(uploadOid);
if (null == imageBytes) {
return;
}
Image signatureImgObj = Image.getInstance(imageBytes);
signatureImgObj.setWidthPercentage(40f);
PdfPCell cell = new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
cell.addElement(signatureImgObj);
table.addCell(cell);
}
use of com.itextpdf.text.Image in project bamboobsc by billchen198318.
the class PersonalReportPdfCommand method putSignature.
private void putSignature(PdfPTable table, Context context) throws Exception {
String uploadOid = (String) context.get("uploadSignatureOid");
if (StringUtils.isBlank(uploadOid)) {
return;
}
byte[] imageBytes = UploadSupportUtils.getDataBytes(uploadOid);
if (null == imageBytes) {
return;
}
Image signatureImgObj = Image.getInstance(imageBytes);
signatureImgObj.setWidthPercentage(40f);
PdfPCell cell = new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
cell.addElement(signatureImgObj);
table.addCell(cell);
}
use of com.itextpdf.text.Image 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);
}
use of com.itextpdf.text.Image in project trainning by fernandotomasio.
the class DOC001PDF method readPdfAsImage.
private Image readPdfAsImage(String documentUID) throws DocumentException {
try {
DocumentDTO portaria = ecmService.findDocumentByUUID(documentUID);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
document.newPage();
PdfReader reader = new PdfReader(portaria.getContentStream());
int n = reader.getNumberOfPages();
PdfImportedPage page;
for (int i = 1; i <= n; i++) {
page = writer.getImportedPage(reader, i);
Image imagePage = Image.getInstance(page);
imagePage.scaleToFit(PageSize.A4.getWidth(), PageSize.A4.getHeight());
PdfContentByte cb = writer.getDirectContent();
cb.addTemplate(page, 0, 0);
return imagePage;
}
} catch (IOException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
}
return null;
}
use of com.itextpdf.text.Image in project trainning by fernandotomasio.
the class DOC001PDF method buildAtoAprovacao.
private void buildAtoAprovacao(Document document, CurriculoMinimoDTO curriculoMinimo) throws DocumentException {
// document.add(Chunk.NEXTPAGE);
if (curriculoMinimo.getPortariaDocumentUID() != null) {
document.newPage();
Image imagePage = readPdfAsImage(curriculoMinimo.getPortariaDocumentUID());
document.add(imagePage);
document.add(Chunk.NEXTPAGE);
document.add(Chunk.NEXTPAGE);
}
}
Aggregations