Example usage for com.itextpdf.text Image setAlignment

List of usage examples for com.itextpdf.text Image setAlignment

Introduction

In this page you can find the example usage for com.itextpdf.text Image setAlignment.

Prototype


public void setAlignment(final int alignment) 

Source Link

Document

Sets the alignment for the image.

Usage

From source file:sipl.recursos.GenerarPDFGrafica.java

private void addTitlePage(Document document)
        throws DocumentException, MalformedURLException, BadElementException, IOException {
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);/*w ww.j a  v  a  2s  .  c  o  m*/
    preface.add(new Paragraph(Titulo, catFont));
    addEmptyLine(preface, 1);
    preface.add(new Paragraph(
            "Reporte generado por: " + user.getNombre() + " " + user.getApellido() + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Este documento es creado a peticin del autor", smallBold));

    addEmptyLine(preface, 6);
    Image img = Image.getInstance(direc + "img//logo_unab.jpg");
    img.scaleAbsolute(70, 100);
    img.setAlignment(Image.ALIGN_CENTER);
    Chunk c = new Chunk(img, 0, 0);
    preface.add(c);
    document.add(preface);
    document.newPage();
    Paragraph preface1 = new Paragraph();
    preface1.add(new Paragraph("Grfica", smallBold));
    addEmptyLine(preface1, 20);
    img = Image.getInstance(imgG);
    img.scaleAbsolute(400, 300);
    img.setAlignment(Image.ALIGN_CENTER);
    c = new Chunk(img, 0, 0);
    preface1.add(c);
    document.add(preface1);
    document.newPage();
}

From source file:sipl.recursos.GenerarPDFListar.java

private void addTitlePage(Document document)
        throws DocumentException, MalformedURLException, BadElementException, IOException {
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);/*from   w  w  w  .j  a v a 2s  . com*/
    preface.add(new Paragraph(Titulo, catFont));
    addEmptyLine(preface, 1);
    preface.add(new Paragraph(
            "Reporte generado por: " + user.getNombre() + " " + user.getApellido() + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Este documento es creado a peticin del autor", smallBold));
    addEmptyLine(preface, 6);
    Image img = Image.getInstance(direc + "img//logo_unab.jpg");
    img.scaleAbsolute(70, 100);
    img.setAlignment(Image.ALIGN_CENTER);
    Chunk c = new Chunk(img, 0, 0);
    preface.add(c);
    document.add(preface);
    document.newPage();
}

From source file:sipl.recursos.GenerarPDFtipomaterial.java

private static void addTitlePage(Document document)
        throws DocumentException, MalformedURLException, BadElementException, IOException {
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);//  w  w w  .java  2  s  . co m
    preface.add(new Paragraph(Titulo, catFont));
    addEmptyLine(preface, 1);
    preface.add(new Paragraph(
            "Reporte generado por: " + user.getNombre() + " " + user.getApellido() + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));
    addEmptyLine(preface, 3);
    preface.add(new Paragraph("Este documento es creado a peticin del autor", smallBold));

    addEmptyLine(preface, 6);
    Image img = Image.getInstance(direc + "img//logo_unab.jpg");
    img.scaleAbsolute(70, 100);
    img.setAlignment(Image.ALIGN_CENTER);
    Chunk c = new Chunk(img, 0, 0);
    preface.add(c);
    document.add(preface);
    document.newPage();
    Paragraph preface1 = new Paragraph();
    preface1.add(new Paragraph("Grfica", smallBold));
    addEmptyLine(preface1, 20);
    img = Image.getInstance(imgG);
    img.scaleAbsolute(400, 300);
    img.setAlignment(Image.ALIGN_CENTER);
    c = new Chunk(img, 0, 0);
    preface1.add(c);
    document.add(preface1);
    document.newPage();
}

From source file:sistema.audizio.relatorio.Relatorio.java

public void gerar(Cliente cliente, Processo processo, Veiculo veiculo, Cidade cidade, Bairro bairro,
        Assessoria assesoria)// ww w. j  a  v a 2s. co  m
        throws DocumentException, FileNotFoundException, BadElementException, IOException {

    String local = "c:\\sistema\\audisio\\relatorios\\" + cliente.getNome() + "-N P-" + processo.getProcesso()
            + ".pdf";

    Document document = new Document();
    //PdfWriter.getInstance(document, new FileOutputStream("C:\\Users\\ZipNet\\Desktop\\Pdf's\\teste.pdf"));
    PdfWriter.getInstance(document, new FileOutputStream(local));
    document.open();

    Font f = new Font(FontFamily.COURIER, 15, Font.NORMAL);
    Font fgrande = new Font(FontFamily.HELVETICA, 25, Font.ITALIC);

    Image img = Image.getInstance("c:/sistema/audisio/imagens/relatorio.png");
    img.setAlignment(Element.ALIGN_LEFT);

    Paragraph titulo = new Paragraph("Relatrio de processo", fgrande);
    Paragraph Clienteente = new Paragraph("DADOS CLIENTE");
    Paragraph Processocesso = new Paragraph("DADOS PROCESSO");
    Paragraph veiculolo = new Paragraph("DADOS VE?CULO");

    titulo.setAlignment(Paragraph.ALIGN_RIGHT);
    Clienteente.setAlignment(Paragraph.ALIGN_CENTER);
    Processocesso.setAlignment(Paragraph.ALIGN_CENTER);
    veiculolo.setAlignment(Paragraph.ALIGN_CENTER);

    document.add(img);
    document.add(titulo);
    document.add(new Paragraph(" "));
    document.add(Clienteente);
    document.add(
            new Paragraph("______________________________________________________________________________"));

    document.add(new Paragraph("Nome..: " + cliente.getNome(), f));
    document.add(new Paragraph("Celular..: " + cliente.getCelular(), f));
    document.add(new Paragraph("Cep..: " + cliente.getCep(), f));
    document.add(new Paragraph("Cpf..: " + cliente.getCpf(), f));
    document.add(new Paragraph("Uf: " + cliente.getEstado(), f));
    document.add(new Paragraph("Endereo..: " + cliente.getEndereco() + ", " + cliente.getNum() + ", "
            + bairro.getNome() + ", " + cidade.getNome(), f));
    document.add(new Paragraph("E-mail..: " + cliente.getEmail(), f));
    document.add(new Paragraph(" "));
    document.add(veiculolo);
    document.add(
            new Paragraph("______________________________________________________________________________"));
    document.add(new Paragraph(" "));
    document.add(new Paragraph("Marca..: " + veiculo.getMarca(), f));
    document.add(new Paragraph("Modelo..: " + veiculo.getModelo(), f));
    document.add(new Paragraph("Placa..: " + veiculo.getPlaca(), f));
    document.add(new Paragraph("Estado..: " + veiculo.getEstado(), f));
    document.add(new Paragraph(" "));
    document.add(Processocesso);
    document.add(
            new Paragraph("______________________________________________________________________________"));
    document.add(new Paragraph(" "));
    document.add(new Paragraph("Processo..: " + processo.getProcesso(), f));
    document.add(new Paragraph("Data inicio..: " + processo.getData_inicio(), f));
    document.add(new Paragraph("Data trmino..: " + processo.getData_termino(), f));
    document.add(new Paragraph("Comarca..: " + processo.getComarca(), f));
    document.add(new Paragraph("Vara..: " + processo.getVara(), f));
    document.add(new Paragraph("Assesoria..: " + assesoria.getNome(), f));
    document.add(new Paragraph("Advogado..: " + assesoria.getNome_advogado(), f));
    document.close();
    JOptionPane.showMessageDialog(null, "RELATRIO CRIADO COM SUCESSO!\n" + local);

    try {
        java.awt.Desktop.getDesktop().open(new File(local));
    } catch (IOException ex) {
        Logger.getLogger(Cadastro.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:smile.ImprimirReporte.java

public void ImprimirReporte()
        throws DocumentException, FileNotFoundException, BadElementException, IOException {

    Document document = new Document(PageSize.LETTER.rotate());
    Image imagen = Image.getInstance("src/Imagen/dental.jpg");
    imagen.setAbsolutePosition(250f, 250f);
    imagen.setAlignment(Element.ALIGN_CENTER);

    String p1 = "Paciente: " + getNombre();
    String p2 = "Edad: " + getEdad() + "Sexo: " + getSexo();
    String p3 = "Fecha: " + getFecha();
    String p4 = "Motivo Consulta: " + getMotivo();
    String p5 = "Descrpcion: " + getDescripcion();

    PdfWriter.getInstance(document, new FileOutputStream("recibo.pdf"));
    document.open();/*from www .ja va  2 s  . c  o m*/
    document.add(imagen);
    document.add(new Paragraph(p1));
    document.add(new Paragraph(p2));
    document.add(new Paragraph(p3));
    document.add(new Paragraph(p4));
    document.add(new Paragraph(p5));

    PdfPTable table = new PdfPTable(3);

    table.addCell("Clase Esqueletal");
    table.addCell("Norma");
    table.addCell("Inicial");
    table.addCell("Convexidad Facial");
    table.addCell("+2+-2mm");
    table.addCell("");

    table.addCell("Maxilar Inferior");
    table.addCell("");
    table.addCell("");
    table.addCell("Eje Facial");
    table.addCell("90+-3");
    table.addCell("");
    table.addCell("Prof. Facial");
    table.addCell("87+-3");
    table.addCell("");
    table.addCell("Ang.Plano mandibular");
    table.addCell("26+-4");
    table.addCell("");
    table.addCell("Altura Facial Inferior");
    table.addCell("47+-4");
    table.addCell("");
    table.addCell("Arco Mandibular");
    table.addCell("26+-4");
    table.addCell("");

    table.addCell("Maxilar Superior");
    table.addCell("");
    table.addCell("");
    table.addCell("Profundidad Maxilar");
    table.addCell("90+-3");
    table.addCell("");

    table.addCell("Dientes");
    table.addCell("");
    table.addCell("");
    table.addCell("A-Pg");
    table.addCell("+1+-2mm");
    table.addCell("");
    table.addCell("Plano Oclusal");
    table.addCell("+1+-1mm");
    table.addCell("");
    table.addCell("Plano Mandibular");
    table.addCell("90+-5");
    table.addCell("");
    table.addCell("Plano Bana");
    table.addCell("E.Fac -5");
    table.addCell("");

    table.addCell("Estetica");
    table.addCell("");
    table.addCell("");
    table.addCell("Exposicion del l");
    table.addCell("+2.5 a 3mm");
    table.addCell("");
    table.addCell("Lab. Inf. Plano E");
    table.addCell("-2+-2mm");
    table.addCell("");
    table.addCell("Angulo masofacial inferior");
    table.addCell("85+-5");
    table.addCell("");

    document.add(table);

    document.close();
    System.out.println("Entre");
}

From source file:Tables.Printer.java

public void header(Document doc, String reportType) throws DocumentException {
    String companyInfo = "NJEIFORBI ACCOUNTS BOOK \nFINANCIAL REPORTS";

    Paragraph newLine = new Paragraph("\n");
    doc.add(newLine);/*from  w  ww .j  a v  a 2s  .co  m*/

    // add the paragraph to the document            

    /*new heading*/
    //adding the company logo.
    try {
        Image img = Image.getInstance(this.companyLogo);
        img.scaleAbsolute(80f, 80f);
        img.setAlt("Unity Systems");
        img.setAlignment(Element.ALIGN_CENTER);

        //            Image img = Image.getInstance(this.companyLogo);

        /*with the next 3 lines oc code, the image will align at the center of the page.*/
        //            img.setAbsolutePosition(
        //                (PageSize.A4.getWidth() - img.getScaledWidth()) / 2,
        //                (PageSize.A4.getHeight() - img.getScaledHeight()) / 2);

        doc.add(img);
    } catch (IOException | DocumentException ex) {
        Dialogs.create().title("Logo Not found").message(
                "The Company's logo has not been located. So the printout will be without the logo of the company")
                .showError();
        ex.printStackTrace();
    }

    Paragraph companyName = new Paragraph(companyInfo, this.companyNameFont);
    Paragraph reportTitle = new Paragraph(reportType, this.reportTitleFont);

    companyName.setAlignment(Element.ALIGN_CENTER);
    reportTitle.setAlignment(Element.ALIGN_CENTER);
    newLine.setAlignment(Element.ALIGN_CENTER);

    doc.add(companyName);
    doc.add(reportTitle);
    doc.add(newLine);

    /*new heading ends*/

}

From source file:Tables.PrinterClass.java

/***************HEADINGS HEADINGS HEADINGS */

private void makeCompanyHeading(Document doc) throws DocumentException, BadElementException, IOException {

    //adding the company logo.
    try {/*from w ww  .  j a v  a  2  s . com*/
        Image img = Image.getInstance(this.companyLogo);
        img.scaleAbsolute(80f, 80f);
        img.setAlt("Unity Systems");
        img.setAlignment(Element.ALIGN_CENTER);

        //            Image img = Image.getInstance(this.companyLogo);

        /*with the next 3 lines oc code, the image will align at the center of the page.*/
        //            img.setAbsolutePosition(
        //                (PageSize.A4.getWidth() - img.getScaledWidth()) / 2,
        //                (PageSize.A4.getHeight() - img.getScaledHeight()) / 2);

        doc.add(img);
    } catch (IOException | DocumentException ex) {
        Dialogs.create().title("Logo Not found").message(
                "The Company's logo has not been located. So the printout will be without the logo of the company")
                .showError();
        ex.printStackTrace();
    }

    Paragraph companyName = new Paragraph(this.companyName, this.companyNameFont);
    Paragraph newLine = new Paragraph("\n");
    Paragraph companyLocation = new Paragraph(
            this.companyLocation + "\n" + this.companyPoBox + "\n " + this.companyTel, this.companySubInfoFont);

    companyName.setAlignment(Element.ALIGN_CENTER);
    companyLocation.setAlignment(Element.ALIGN_CENTER);
    newLine.setAlignment(Element.ALIGN_CENTER);

    doc.add(companyName);
    doc.add(companyLocation);
    doc.add(newLine);

}

From source file:ucuenca.edu.sg.controller.util.GenerarActividades.java

public void cabezera() throws DocumentException, BadElementException, IOException {
       ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
       titulo1.setTexto("INFORME DE TAREA POR OBJETIVO");
       titulo1.getElementoRojo();//w  w w. j av  a  2  s  . c o m
       espacioBlanco.getElemento();
       documento.add(titulo1.getElemento());
       documento.add(espacioBlanco.getElemento());
       documento.add(lineaNormal.getLinea());
       documento.add(espacioBlanco.getElemento());
       documento.add(espacioBlanco.getElemento());

       Image foto = Image.getInstance(getEc().getRealPath("resources") + "/img/golden.jpg");
       foto.scaleToFit(130, 130);
       foto.setAlignment(Chunk.ALIGN_MIDDLE);
       documento.add(foto);

       tablaVertical.limpiar();
       tablaVertical.setTitulos("Nombre Empresa:", "Ubicacion:", "Fecha:");

       tablaVertical.setContenidos(new Object[] { "Gonlden Bringe Corporation S.A ",
               "Florencia Astudillo 1-28 y Av. 12 de Abril", fecha() });

       tablaVertical.setAlineamientos(new int[] { 0, 0 });
       tablaVertical.setAnchoTabla(50);
       tablaVertical.setPosicion(0);
       tablaVertical.setTamanos(new int[] { 30, 70 });
       tablaVertical.llenarTabla(false);
       documento.add(tablaVertical.getTabla());

       documento.add(espacioBlanco.getElemento());
       documento.add(espacioBlanco.getElemento());

   }

From source file:ucuenca.edu.sg.controller.util.ReporteMatrizBSC.java

private void cabezera() throws DocumentException, BadElementException, IOException {
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    titulo1.setTexto("REPORTE DE LA MATRIZ DEL CUADRO INTEGRAL");
    titulo1.getElementoRojo();//from  w  w w .  j  av a  2 s.co  m
    espacioBlanco.getElemento();
    documento.add(titulo1.getElemento());
    documento.add(espacioBlanco.getElemento());
    documento.add(lineaNormal.getLinea());
    documento.add(espacioBlanco.getElemento());
    documento.add(espacioBlanco.getElemento());

    Image foto = Image.getInstance(getEc().getRealPath("resources") + "/img/golden.jpg");
    foto.scaleToFit(130, 130);
    foto.setAlignment(Chunk.ALIGN_MIDDLE);
    documento.add(foto);

    tablaVertical.limpiar();
    tablaVertical.setTitulos("Nombre Empresa:", "Ubicacion:", "Fecha:");

    tablaVertical.setContenidos(new Object[] { "Gonlden Bringe Corporation S.A ",
            "Florencia Astudillo 1-28 y Av. 12 de Abril", fecha() });

    tablaVertical.setAlineamientos(new int[] { 0, 0 });
    tablaVertical.setAnchoTabla(50);
    tablaVertical.setPosicion(0);
    tablaVertical.setTamanos(new int[] { 30, 70 });
    tablaVertical.llenarTabla(false);
    documento.add(tablaVertical.getTabla());

    documento.add(espacioBlanco.getElemento());
    documento.add(espacioBlanco.getElemento());
}

From source file:utiles.ContarCajaPdf.java

/**
 * metodo que hace uso de la clase itext para generar archivos PDF
 * @param venta datos del tablemodels/*from w w w .j a va  2 s  .  c o  m*/
 * @throws Exception 
 */

public static void ITextHelloWorld(double venta) throws Exception {
    Document document = new Document();
    Paragraph parrafo, parrafo1, parrafo2;
    Image imagen = Image.getInstance("src/icon/Spa.jpg");

    // Le indicamos donde se guardara el archivo
    PdfWriter.getInstance(document,
            new FileOutputStream("src/pdfGenerados/" + venta + "_" + "caja_del_dia.pdf"));

    // Este codigo genera una tabla de 2 columnas
    PdfPTable table = new PdfPTable(2);
    String total = venta + " ";
    // addCell() agrega una celda a la tabla, el cambio de fila
    // ocurre automaticamente al llenar la fila
    table.addCell("Caja total del dia:");
    table.addCell(total);

    document.open();

    //Creamos una cantidad significativa de paginas para probar el encabezado

    parrafo = new Paragraph("Gracias por confiar en nuestros servicios SpaRelajate");
    parrafo1 = new Paragraph("           ");
    parrafo2 = new Paragraph("           ");

    //este codigo hace que se nos centre tanto el texto como la imagen
    parrafo.setAlignment(Element.ALIGN_CENTER);
    parrafo1.setAlignment(Element.ALIGN_CENTER);
    parrafo2.setAlignment(Element.ALIGN_CENTER);
    imagen.setAlignment(Element.ALIGN_CENTER);

    //aade la documentacion que tendra el pdf
    document.add(imagen);
    document.add(parrafo1);
    document.add(table);
    document.add(parrafo2);
    document.add(parrafo);
    document.close();

}