Example usage for com.itextpdf.text Image setAbsolutePosition

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

Introduction

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

Prototype


public void setAbsolutePosition(final float absoluteX, final float absoluteY) 

Source Link

Document

Sets the absolute position of the Image.

Usage

From source file:utils.pdf.cv_templates.Template1.java

private void addImageBackgroundTop() throws DocumentException, IOException {
    Image back_img = Image.getInstance(BACK_IMAGE);
    back_img.setAbsolutePosition((PageSize.A4.getWidth() - back_img.getScaledWidth()) / 2,
            (PageSize.A4.getHeight() - back_img.getScaledHeight()) / 2);
    back_img.setAbsolutePosition(0, 823);
    document.add(back_img);// w  w w .  ja  v  a2s  .  co  m
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageBackgroundBottom() throws DocumentException, IOException {
    Image back_img = Image.getInstance(BACK_IMAGE);
    back_img.setAbsolutePosition((PageSize.A4.getWidth() - back_img.getScaledWidth()) / 2,
            (PageSize.A4.getHeight() - back_img.getScaledHeight()) / 2);
    back_img.setAbsolutePosition(0, 0);/*ww w  .  j  av a2s. c  om*/
    document.add(back_img);
}

From source file:utils.pdf.cv_templates.Template3.java

private void addBackgroundImage() throws DocumentException, IOException {
    Image back_img = Image.getInstance(BACK_IMAGE);
    back_img.setAbsolutePosition((PageSize.A4.getWidth() - back_img.getScaledWidth()) / 2,
            (PageSize.A4.getHeight() - back_img.getScaledHeight()) / 2);
    document.add(back_img);//from  ww  w .  ja va  2  s  .  co  m
}

From source file:utils.pdf.cv_templates.Template3.java

private void addLineImage() throws DocumentException, IOException {
    Image short_line_img = Image.getInstance(SHORT_LINE_IMAGE);
    short_line_img.setAbsolutePosition(213, 756);
    short_line_img.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
    short_line_img.setBorderWidth(10);
    short_line_img.setBorderColor(BaseColor.WHITE);
    short_line_img.scaleToFit(300, 55);
    document.add(short_line_img);
}

From source file:utils.pdf.cv_templates.Template4.java

private void addImage(User user) throws DocumentException, IOException {
    Image photo_img;
    if (!user.photo.id.equals("")) {
        photo_img = Image//from  w  w w  . j a v  a  2  s.  c o m
                .getInstance(String.format("https://s3.amazonaws.com/aunclickdelempleo2/" + user.photo.id));
    } else {
        photo_img = Image.getInstance(String.format("public/images/orientation/photo/ic_profile.png"));
    }

    photo_img.setAbsolutePosition(450, 690);
    photo_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    photo_img.setBorder(Image.BOX);
    photo_img.setBorderWidth(10);
    photo_img.setBorderColor(BaseColor.WHITE);
    photo_img.scaleToFit(1000, 115);
    document.add(photo_img);
}

From source file:utils.PrintUtils.java

public void entetePortrait(Document document, Etablissement etablissement) throws Exception {
    Image image = Image.getInstance(Utilitaires.path + "/" + "resources/images/logo1.png");
    image.setAbsolutePosition(400f, 450f);
    document.add(image);/*from   w  w  w. ja v a2 s .c  om*/

    document.add(new Paragraph("" + etablissement.getNom(), normalFont));
    document.add(new Paragraph("" + etablissement.getAdresse().getAdresse(), normalFont));
    document.add(new Paragraph("Tl." + etablissement.getAdresse().getContact(), normalFont));
}

From source file:uy.gub.imm.sae.web.mbean.reserva.PasoFinalMBean.java

License:Open Source License

public String imprimirTicket() {
    try {// ww  w  . j av a2  s .  co m

        BaseColor colorBlack = new BaseColor(0, 0, 0);

        BaseFont times = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        BaseFont helveticaBold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252,
                BaseFont.NOT_EMBEDDED);
        BaseFont symbol = BaseFont.createFont(BaseFont.SYMBOL, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

        SimpleDateFormat sdfHr = new SimpleDateFormat("HH:mm");
        SimpleDateFormat sdfFecha = new SimpleDateFormat("dd/MM/yyyy");

        Rectangle pageSize = new Rectangle(210, 210);

        Document document = new Document(pageSize);
        document.addTitle(getI18N().getText("etiqueta.reserva.title"));

        ByteArrayOutputStream os = new ByteArrayOutputStream();

        PdfWriter pdfWriter = PdfWriter.getInstance(document, os);
        document.open();

        PdfContentByte pdfContent = pdfWriter.getDirectContent();

        InputStream is = PasoFinalMBean.class.getResourceAsStream(SAEProfile.getInstance().getProperties()
                .getProperty(SAEProfile.PROFILE_UI_TEMPLATES_IMAGES_LOGO_TICKET_KEY));

        byte[] arrImage = new byte[4096];
        is.read(arrImage);

        Image img = Image.getInstance(arrImage);

        img.scaleAbsolute(100, 30);
        img.setAbsolutePosition(55, 170);
        document.add(img);

        //Dibujo primer lnea
        LineSeparator line = new LineSeparator();
        line.setAlignment(LineSeparator.ALIGN_CENTER);
        line.setLineColor(colorBlack);
        line.setLineWidth(0.5f);

        line.drawLine(pdfContent, 10, 200, 170);

        //Etiqueta RESERVA
        pdfContent.beginText();
        pdfContent.setFontAndSize(helveticaBold, 15);
        pdfContent.setTextMatrix(45, 150);
        pdfContent.showText(getI18N().getText("etiqueta.reserva.showText"));
        pdfContent.endText();

        //Fecha de la reserva
        String fecha_reserva = sdfFecha.format(sesionMBean.getDisponibilidad().getHoraInicio());

        pdfContent.beginText();
        pdfContent.setFontAndSize(symbol, 16);
        pdfContent.setTextMatrix(130, 150);
        pdfContent.showText(fecha_reserva);
        pdfContent.endText();

        //Dibujo segunda lnea
        line.drawLine(pdfWriter.getDirectContent(), 10, 200, 140);

        int etiqHoraTamanio = 25;
        int etiqHoraX = 15;
        int etiqHoraY = 85;

        int valorHoraTamanio = 40;
        int valorHoraX = 105;
        int valorHoraY = 80;

        String serie = sesionMBean.getRecurso().getSerie();
        boolean conSerie = (serie != null) && (serie.length() >= 1);

        if (sesionMBean.getRecurso().getMostrarNumeroEnTicket()) {

            if (!conSerie) {
                //Ajusto valor y etiqueta hora
                etiqHoraTamanio = 20;
                etiqHoraX = 15;
                etiqHoraY = 110;

                valorHoraTamanio = 30;
                valorHoraX = 120;
                valorHoraY = 107;

                //Etiqueta NUMERO
                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(15, 65);
                pdfContent.showText(getI18N().getText("etiqueta.numero.numero"));
                pdfContent.endText();

                //Numero de la reserva
                String nro = sesionMBean.getReservaConfirmada().getNumero().toString();
                int nro_pos = 135;

                if (nro.length() == 1) {
                    nro_pos = 135;
                } else if (nro.length() == 2) {
                    nro_pos = 125;
                } else {
                    nro_pos = 105;
                }

                pdfContent.beginText();
                pdfContent.setFontAndSize(symbol, 60);
                pdfContent.setTextMatrix(nro_pos, 55);
                pdfContent.showText(nro);
                pdfContent.endText();
            } else {
                //<<<<<< Agregado >>>>>>
                //Ajusto valor y etiqueta hora
                etiqHoraTamanio = 20;
                etiqHoraX = 15;
                etiqHoraY = 123;

                valorHoraTamanio = 20;
                valorHoraX = 120;
                valorHoraY = 122;

                //Etiqueta SERIE
                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(15, 87);
                pdfContent.showText(getI18N().getText("etiqueta.numero.serie"));
                pdfContent.endText();

                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(120, 87);
                pdfContent.showText(serie);
                pdfContent.endText();

                //Etiqueta NUMERO
                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(15, 50);
                pdfContent.showText(getI18N().getText("etiqueta.numero.numero"));
                pdfContent.endText();

                //Numero de la reserva
                String nro = sesionMBean.getReservaConfirmada().getNumero().toString();
                int nro_pos = 135;

                if (nro.length() == 1) {
                    nro_pos = 135;
                } else if (nro.length() == 2) {
                    nro_pos = 125;
                } else {
                    nro_pos = 105;
                }

                pdfContent.beginText();
                pdfContent.setFontAndSize(symbol, 40);
                pdfContent.setTextMatrix(nro_pos, 47);
                pdfContent.showText(nro);
                pdfContent.endText();
            }
        }

        //Etiqueta HORA
        pdfContent.beginText();
        pdfContent.setFontAndSize(helveticaBold, etiqHoraTamanio);
        pdfContent.setTextMatrix(etiqHoraX, etiqHoraY);
        pdfContent.showText(getI18N().getText("etiqueta.hora.hora"));
        pdfContent.endText();

        //Hora de la reserva
        pdfContent.beginText();
        pdfContent.setFontAndSize(symbol, valorHoraTamanio);
        pdfContent.setTextMatrix(valorHoraX, valorHoraY);
        pdfContent.showText(sdfHr.format(sesionMBean.getDisponibilidad().getHoraInicio()));
        pdfContent.endText();

        //Dibujo tercer lnea
        line.drawLine(pdfWriter.getDirectContent(), 10, 200, 45);

        String ticketEtiqUno = sesionMBean.getRecurso().getTextoRecurso().getTicketEtiquetaUno();
        String ticketEtiqDos = sesionMBean.getRecurso().getTextoRecurso().getTicketEtiquetaDos();
        int largoEtiqUno = 0;
        int largoEtiqDos = 0;
        int xValores = 0;

        if (ticketEtiqUno != null) {
            largoEtiqUno = ticketEtiqUno.length();
        }

        if (ticketEtiqDos != null) {
            largoEtiqDos = ticketEtiqDos.length();
        }

        if (largoEtiqUno > largoEtiqDos) {
            xValores = 8 * (largoEtiqUno + 1);
        } else {
            xValores = 8 * (largoEtiqDos + 1);
        }

        //Etiqueta uno
        if (ticketEtiqUno != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(helveticaBold, 10);
            pdfContent.setTextMatrix(10, 30);
            pdfContent.showText(ticketEtiqUno + ":");
            pdfContent.endText();
        }

        //Valor etiqueta uno
        String valorEtiqUno = sesionMBean.getRecurso().getTextoRecurso().getValorEtiquetaUno();
        if (valorEtiqUno != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(times, 10);
            pdfContent.setTextMatrix(xValores, 30);
            pdfContent.showText(valorEtiqUno);
            pdfContent.endText();
        }

        //Etiqueta dos

        if (ticketEtiqDos != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(helveticaBold, 10);
            pdfContent.setTextMatrix(10, 15);
            pdfContent.showText(ticketEtiqDos + ":");
            pdfContent.endText();
        }

        //Valor etiqueta dos
        String valorEtiqDos = sesionMBean.getRecurso().getTextoRecurso().getValorEtiquetaDos();
        if (valorEtiqDos != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(times, 10);
            pdfContent.setTextMatrix(xValores, 15);
            pdfContent.showText(valorEtiqDos);
            pdfContent.endText();
        }

        pdfWriter.addJavaScript("this.print({bUI: true, bSilent: true, bShrinkToFit: true});", false);
        pdfWriter.addJavaScript("this.closeDoc(true);");

        document.close();

        FacesContext facesContext = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        response.setContentType("application/pdf");

        os.writeTo(response.getOutputStream());

        response.getOutputStream().flush();
        response.getOutputStream().close();
        facesContext.responseComplete();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}

From source file:uy.gub.imm.sae.web.mbean.reserva.PasoFinalMBean.java

License:Open Source License

public String guardarTicket() {
    try {/*from   ww  w. j  a v  a2 s  .c  o m*/

        BaseColor colorBlack = new BaseColor(0, 0, 0);

        BaseFont times = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        BaseFont helveticaBold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252,
                BaseFont.NOT_EMBEDDED);
        BaseFont symbol = BaseFont.createFont(BaseFont.SYMBOL, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

        SimpleDateFormat sdfHr = new SimpleDateFormat("HH:mm");
        SimpleDateFormat sdfFecha = new SimpleDateFormat("dd/MM/yyyy");

        Rectangle pageSize = new Rectangle(210, 210);

        Document document = new Document(pageSize);
        document.addTitle(getI18N().getText("etiqueta.reserva.title"));

        ByteArrayOutputStream os = new ByteArrayOutputStream();

        PdfWriter pdfWriter = PdfWriter.getInstance(document, os);
        document.open();

        PdfContentByte pdfContent = pdfWriter.getDirectContent();

        InputStream is = PasoFinalMBean.class.getResourceAsStream(SAEProfile.getInstance().getProperties()
                .getProperty(SAEProfile.PROFILE_UI_TEMPLATES_IMAGES_LOGO_TICKET_KEY));

        byte[] arrImage = new byte[4096];
        is.read(arrImage);

        Image img = Image.getInstance(arrImage);

        img.scaleAbsolute(100, 30);
        img.setAbsolutePosition(55, 170);
        document.add(img);

        //Dibujo primer lnea
        LineSeparator line = new LineSeparator();
        line.setAlignment(LineSeparator.ALIGN_CENTER);
        line.setLineColor(colorBlack);
        line.setLineWidth(0.5f);

        line.drawLine(pdfContent, 10, 200, 170);

        //Etiqueta RESERVA
        pdfContent.beginText();
        pdfContent.setFontAndSize(helveticaBold, 15);
        pdfContent.setTextMatrix(45, 150);
        pdfContent.showText(getI18N().getText("etiqueta.reserva.showText"));
        pdfContent.endText();

        //Fecha de la reserva
        String fecha_reserva = sdfFecha.format(sesionMBean.getDisponibilidad().getHoraInicio());

        pdfContent.beginText();
        pdfContent.setFontAndSize(symbol, 16);
        pdfContent.setTextMatrix(130, 150);
        pdfContent.showText(fecha_reserva);
        pdfContent.endText();

        //Dibujo segunda lnea
        line.drawLine(pdfWriter.getDirectContent(), 10, 200, 140);

        int etiqHoraTamanio = 25;
        int etiqHoraX = 15;
        int etiqHoraY = 85;

        int valorHoraTamanio = 40;
        int valorHoraX = 105;
        int valorHoraY = 80;

        String serie = sesionMBean.getRecurso().getSerie();
        boolean conSerie = (serie != null) && (serie.length() >= 1);

        if (sesionMBean.getRecurso().getMostrarNumeroEnTicket()) {

            if (!conSerie) {
                //Ajusto valor y etiqueta hora
                etiqHoraTamanio = 20;
                etiqHoraX = 15;
                etiqHoraY = 110;

                valorHoraTamanio = 30;
                valorHoraX = 120;
                valorHoraY = 107;

                //Etiqueta NUMERO
                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(15, 65);
                pdfContent.showText(getI18N().getText("etiqueta.numero.numero"));
                pdfContent.endText();

                //Numero de la reserva
                String nro = sesionMBean.getReservaConfirmada().getNumero().toString();
                int nro_pos = 135;

                if (nro.length() == 1) {
                    nro_pos = 135;
                } else if (nro.length() == 2) {
                    nro_pos = 125;
                } else {
                    nro_pos = 105;
                }

                pdfContent.beginText();
                pdfContent.setFontAndSize(symbol, 60);
                pdfContent.setTextMatrix(nro_pos, 55);
                pdfContent.showText(nro);
                pdfContent.endText();
            } else {

                //Ajusto valor y etiqueta hora
                etiqHoraTamanio = 20;
                etiqHoraX = 15;
                etiqHoraY = 123;

                valorHoraTamanio = 20;
                valorHoraX = 120;
                valorHoraY = 122;

                //Etiqueta SERIE
                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(15, 87);
                pdfContent.showText(getI18N().getText("etiqueta.numero.serie"));
                pdfContent.endText();

                pdfContent.beginText();
                pdfContent.setFontAndSize(symbol, 20);
                pdfContent.setTextMatrix(120, 87);
                pdfContent.showText(serie);
                pdfContent.endText();

                //Etiqueta NUMERO
                pdfContent.beginText();
                pdfContent.setFontAndSize(helveticaBold, 20);
                pdfContent.setTextMatrix(15, 50);
                pdfContent.showText(getI18N().getText("etiqueta.numero.numero"));
                pdfContent.endText();

                //Numero de la reserva
                String nro = sesionMBean.getReservaConfirmada().getNumero().toString();
                int nro_pos = 135;

                if (nro.length() == 1) {
                    nro_pos = 135;
                } else if (nro.length() == 2) {
                    nro_pos = 125;
                } else {
                    nro_pos = 105;
                }

                pdfContent.beginText();
                pdfContent.setFontAndSize(symbol, 40);
                pdfContent.setTextMatrix(nro_pos, 47);
                pdfContent.showText(nro);
                pdfContent.endText();
            }
        }

        //Etiqueta HORA
        pdfContent.beginText();
        pdfContent.setFontAndSize(helveticaBold, etiqHoraTamanio);
        pdfContent.setTextMatrix(etiqHoraX, etiqHoraY);
        pdfContent.showText(getI18N().getText("etiqueta.hora.hora"));
        pdfContent.endText();

        //Hora de la reserva
        pdfContent.beginText();
        pdfContent.setFontAndSize(symbol, valorHoraTamanio);
        pdfContent.setTextMatrix(valorHoraX, valorHoraY);
        pdfContent.showText(sdfHr.format(sesionMBean.getDisponibilidad().getHoraInicio()));
        pdfContent.endText();

        //Dibujo tercer lnea
        line.drawLine(pdfWriter.getDirectContent(), 10, 200, 45);

        String ticketEtiqUno = sesionMBean.getRecurso().getTextoRecurso().getTicketEtiquetaUno();
        String ticketEtiqDos = sesionMBean.getRecurso().getTextoRecurso().getTicketEtiquetaDos();
        int largoEtiqUno = 0;
        int largoEtiqDos = 0;
        int xValores = 0;

        if (ticketEtiqUno != null) {
            largoEtiqUno = ticketEtiqUno.length();
        }

        if (ticketEtiqDos != null) {
            largoEtiqDos = ticketEtiqDos.length();
        }

        if (largoEtiqUno > largoEtiqDos) {
            xValores = 8 * (largoEtiqUno + 1);
        } else {
            xValores = 8 * (largoEtiqDos + 1);
        }

        //Etiqueta uno
        if (ticketEtiqUno != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(helveticaBold, 10);
            pdfContent.setTextMatrix(10, 30);
            pdfContent.showText(ticketEtiqUno + ":");
            pdfContent.endText();
        }

        //Valor etiqueta uno
        String valorEtiqUno = sesionMBean.getRecurso().getTextoRecurso().getValorEtiquetaUno();
        if (valorEtiqUno != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(times, 10);
            pdfContent.setTextMatrix(xValores, 30);
            pdfContent.showText(valorEtiqUno);
            pdfContent.endText();
        }

        //Etiqueta dos
        if (ticketEtiqDos != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(helveticaBold, 10);
            pdfContent.setTextMatrix(10, 15);
            pdfContent.showText(ticketEtiqDos + ":");
            pdfContent.endText();
        }

        //Valor etiqueta dos
        String valorEtiqDos = sesionMBean.getRecurso().getTextoRecurso().getValorEtiquetaDos();
        if (valorEtiqDos != null) {
            pdfContent.beginText();
            pdfContent.setFontAndSize(times, 10);
            pdfContent.setTextMatrix(xValores, 15);
            pdfContent.showText(valorEtiqDos);
            pdfContent.endText();
        }

        document.close();

        FacesContext facesContext = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "attachment; filename=" + "Ticket de confirmacin.pdf");

        os.writeTo(response.getOutputStream());

        response.getOutputStream().flush();
        response.getOutputStream().close();
        facesContext.responseComplete();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}

From source file:windows.wzListWindow.java

private void printDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printDocActionPerformed
    Document document = new Document();
    Footer ft = new Footer();
    companyAdress comp = new companyAdress();

    try {//from   w w w.jav  a 2  s .  c  o m
        BaseFont ft1 = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        Font ffont = new Font(ft1, 12);

        BaseFont ft3 = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        Font bold = new Font(ft1, 12, Font.BOLD);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
        document.open();
        Paragraph pr = new Paragraph();
        pr.setFont(ffont);
        writer.setPageEvent(ft);
        ContractorEntity contractor = wz
                .getContractor(Integer.valueOf(WZTable.getValueAt(WZTable.getSelectedRow(), 2).toString()));
        pr.add(WZTable.getValueAt(WZTable.getSelectedRow(), 4).toString());
        pr.setAlignment(Element.ALIGN_RIGHT);
        document.add(pr);
        pr.clear();
        if ("SPRZT WYDANY".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 11).toString())) {
            Paragraph nr = new Paragraph("WYADNIE SPRZTU NR ", ffont);
            String yearSlashnr = WZTable.getValueAt(WZTable.getSelectedRow(), 1).toString();
            nr.add(new Chunk(yearSlashnr, bold));
            nr.setAlignment(Element.ALIGN_LEFT);
            document.add(nr);
            if ("WS".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 12).toString())) {
                pr.setAlignment(Element.ALIGN_LEFT);
                DocEntity docPS = wz.getDocument(wz.getPSForWs(
                        Integer.valueOf(WZTable.getValueAt(WZTable.getSelectedRow(), 0).toString())));
                pr.add("DOTYCZY: PS NR " + docPS.getDocNumber());
                document.add(pr);
                pr.clear();
                pr.setAlignment(Element.ALIGN_RIGHT);
            }
        }

        if ("SPRZT PRZYJTY".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 11).toString())) {
            int rok = Timestamp.valueOf(WZTable.getValueAt(WZTable.getSelectedRow(), 4).toString()).getYear()
                    + 1900;
            Paragraph nr = new Paragraph("PRZYJCIE SPRZTU NR ", ffont);
            String yearSlashnr = rok + "/" + WZTable.getValueAt(WZTable.getSelectedRow(), 1).toString();
            nr.add(new Chunk(yearSlashnr, bold));
            nr.setAlignment(Element.ALIGN_LEFT);
            document.add(nr);
        }
        pr.clear();
        pr.add(Chunk.NEWLINE);
        pr.add(Chunk.NEWLINE);
        document.add(pr);
        pr.clear();
        pr.setAlignment(Element.ALIGN_LEFT);
        pr.add(comp.getName());
        pr.add(Chunk.NEWLINE);
        pr.add("ul. " + comp.getStreet());
        pr.add(Chunk.NEWLINE);
        pr.add(comp.getPostal() + " " + comp.getCity());
        pr.add(Chunk.NEWLINE);
        pr.add("NIP: " + comp.getNip());
        pr.add(Chunk.NEWLINE);
        pr.add("Tel: " + comp.getPhone());
        pr.add(Chunk.NEWLINE);
        pr.add("Fax: " + comp.getFax());
        pr.add(Chunk.NEWLINE);
        pr.add("E-mail: " + comp.getEmail());
        pr.add(Chunk.NEWLINE);
        pr.add(Chunk.NEWLINE);
        pr.add("KLIENT:");
        pr.add(Chunk.NEWLINE);
        pr.add(contractor.getName());
        pr.add(Chunk.NEWLINE);
        pr.add("ul. " + contractor.getStreet());
        pr.add(Chunk.NEWLINE);
        pr.add(contractor.getPostalCode() + " " + contractor.getCity());
        pr.add(Chunk.NEWLINE);
        pr.add("NIP: " + contractor.getNip());
        pr.add(Chunk.NEWLINE);
        pr.add("Tel: " + contractor.getPhone());
        pr.add(Chunk.NEWLINE);
        pr.add("E-mail: " + contractor.getEmail());
        document.add(pr);

        pr.clear();
        pr.add(Chunk.NEWLINE);
        pr.add(Chunk.NEWLINE);
        pr.add("PRZYJTE URZDZENIA:");
        document.add(pr);

        //PUT IMAGE FROM DRIVE
        java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage("C:/GIT/support/logo.jpg");
        Image img = com.itextpdf.text.Image.getInstance(awtImage, null);
        int indentation = 0;
        float scaler = ((document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin()
                - indentation) / img.getWidth()) * 20;
        img.scalePercent(scaler);
        img.setAbsolutePosition(document.right() - 90, document.top() - 150);
        document.add(new Paragraph());
        document.add(img);

        //ADD TABLE

        PdfPTable table = new PdfPTable(7); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table
        //Set Column widths
        float[] columnWidths = { 1f, 4f, 3f, 2f, 2f, 6f, 6f };
        table.setWidths(columnWidths);
        BaseFont ft2 = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
        Font headerFont = new Font(ft2, 9);
        Paragraph pos1 = new Paragraph("", headerFont);
        Paragraph pos2 = new Paragraph("", headerFont);
        Paragraph pos3 = new Paragraph("", headerFont);
        Paragraph pos4 = new Paragraph("", headerFont);
        Paragraph pos5 = new Paragraph("", headerFont);
        Paragraph pos6 = new Paragraph("", headerFont);
        Paragraph pos7 = new Paragraph("", headerFont);

        //FORMATING TABLE
        pos1.clear();
        pos1.add("LP");
        PdfPCell cell1 = new PdfPCell(pos1);
        cell1.setBorderColor(BaseColor.BLACK);
        cell1.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell1);
        pos2.clear();
        pos2.add("NAZWA");
        PdfPCell cell2 = new PdfPCell(pos2);
        cell2.setBorderColor(BaseColor.BLACK);
        cell2.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell2);
        pos3.clear();
        pos3.add("NR SERYJNY");
        PdfPCell cell3 = new PdfPCell(pos3);
        cell3.setBorderColor(BaseColor.BLACK);
        cell3.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell3);
        pos4.clear();
        pos4.add("CENA NETTO");
        PdfPCell cell4 = new PdfPCell(pos4);
        cell4.setBorderColor(BaseColor.BLACK);
        cell4.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell4);
        pos5.clear();
        pos5.add("CENA BRUTTO");
        PdfPCell cell5 = new PdfPCell(pos5);
        cell5.setBorderColor(BaseColor.BLACK);
        cell5.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell5);
        pos6.clear();
        pos6.add("PROBLEM");
        PdfPCell cell6 = new PdfPCell(pos6);
        cell6.setBorderColor(BaseColor.BLACK);
        cell6.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell6);
        pos7.clear();
        pos7.add("NAPRAWA");
        PdfPCell cell7 = new PdfPCell(pos7);
        cell7.setBorderColor(BaseColor.BLACK);
        cell7.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell7);

        cell2.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell3.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell4.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell5.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell6.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell7.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell1.setBackgroundColor(BaseColor.WHITE);
        cell2.setBackgroundColor(BaseColor.WHITE);
        cell3.setBackgroundColor(BaseColor.WHITE);
        cell4.setBackgroundColor(BaseColor.WHITE);
        cell5.setBackgroundColor(BaseColor.WHITE);
        cell6.setBackgroundColor(BaseColor.WHITE);
        cell7.setBackgroundColor(BaseColor.WHITE);
        int counter = 1;
        for (DocProductEntity prod : productToShow) {
            //col 1 (LP)
            table.addCell(createCell("" + counter, Element.ALIGN_CENTER));
            counter++;
            //col 2 (NAME)
            table.addCell(createCell(prod.getName(), Element.ALIGN_LEFT));
            //col 3 (NR SER)
            table.addCell(createCell(prod.getSerial(), Element.ALIGN_CENTER));
            //col 4 (NETTO)
            table.addCell(createCell(String.valueOf(prod.getPrice()), Element.ALIGN_RIGHT));
            //col 5 (BRUTTO)
            table.addCell(createCell(String.valueOf(prod.getPrice() + (prod.getPrice() * 0.23)),
                    Element.ALIGN_RIGHT));
            //col 6 (PROBLEM)
            table.addCell(createCell(prod.getProblem(), Element.ALIGN_LEFT));
            //col 7 (REPAIRS)
            table.addCell(createCell(prod.getRepair(), Element.ALIGN_LEFT));
        }
        document.add(table);
        pr.setAlignment(Element.ALIGN_RIGHT);
        pr.clear();
        pr.add("PRZEWIDYWANIY KOSZT NAPRAWY:");
        document.add(pr);
        pr.clear();
        pr.add("Razem netto: " + nettoLabel.getText() + " Razem brutto: " + bruttoLabel.getText());
        document.add(pr);
        pr.clear();
        pr.add("Sownie: " + amountInWords(Float.valueOf(bruttoLabel.getText().replace(",", "."))));
        document.add(pr);
        pr.clear();
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);
        pr.add(".................................................");
        document.add(pr);
        pr.clear();
        pr.add("Podpis i piecztka pracownika");
        document.add(pr);
        if ("SPRZT WYDANY".equals(WZTable.getValueAt(WZTable.getSelectedRow(), 11).toString())) {
            pr.clear();
            pr.add(Chunk.NEWLINE);
            pr.add(Chunk.NEWLINE);
            pr.add(".................................................");
            document.add(pr);
            pr.clear();
            pr.add("Sprzt odebraem (Podpis klienta)");
            document.add(pr);
        }
        //CLOSING DOCUMENT
        document.close();
        writer.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        StampPageXofY numeration = new StampPageXofY();
        tempName = nowTimestamp();
        numeration.manipulatePdf("test.pdf", tempName + ".pdf");
    } catch (IOException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }
    //OPEN READY DOCUMENT
    try {
        Desktop.getDesktop().open(new File(tempName + ".pdf"));
    } catch (IOException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
    }
}