Search in sources :

Example 11 with Image

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);
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) Image(com.itextpdf.text.Image)

Example 12 with Image

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);
}
Also used : PdfPCell(com.itextpdf.text.pdf.PdfPCell) Image(com.itextpdf.text.Image)

Example 13 with Image

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);
}
Also used : 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 14 with Image

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;
}
Also used : DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) IOException(java.io.IOException) Image(com.itextpdf.text.Image)

Example 15 with Image

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);
    }
}
Also used : Image(com.itextpdf.text.Image)

Aggregations

Image (com.itextpdf.text.Image)20 PdfPCell (com.itextpdf.text.pdf.PdfPCell)10 IOException (java.io.IOException)10 BadElementException (com.itextpdf.text.BadElementException)7 Phrase (com.itextpdf.text.Phrase)7 Paragraph (com.itextpdf.text.Paragraph)5 BufferedImage (java.awt.image.BufferedImage)5 DocumentException (com.itextpdf.text.DocumentException)3 PdfContentByte (com.itextpdf.text.pdf.PdfContentByte)3 PdfPTable (com.itextpdf.text.pdf.PdfPTable)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Font (com.itextpdf.text.Font)2 PdfReader (com.itextpdf.text.pdf.PdfReader)2 PdfStamper (com.itextpdf.text.pdf.PdfStamper)2 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)2 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)2 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)2 URL (java.net.URL)2 BaseColor (com.itextpdf.text.BaseColor)1 Document (com.itextpdf.text.Document)1