Example usage for com.itextpdf.text.pdf PdfPTable setSpacingBefore

List of usage examples for com.itextpdf.text.pdf PdfPTable setSpacingBefore

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setSpacingBefore.

Prototype

public void setSpacingBefore(final float spacing) 

Source Link

Document

Sets the spacing before this table.

Usage

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

private void addLanguage(List<Language> languageList) throws DocumentException {
    Paragraph paragraph;/*ww w. j  av  a  2 s .  c  o  m*/
    PdfPCell cell;
    PdfPTable table;

    for (int i = 0; i < languageList.size(); i++) {

        table = new PdfPTable(new float[] { 1f, 2.25f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        if (i == 0) {
            paragraph = new Paragraph("IDIOMAS", font1);
            cell.setBorder(PdfPCell.RIGHT);
        } else {
            paragraph = new Paragraph("");
        }
        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("");
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nombre", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(languageList.get(i).language, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.RIGHT);
        paragraph = new Paragraph("Nivel", font2);
        cell.setBorder(PdfPCell.RIGHT);

        paragraph.setAlignment(Paragraph.ALIGN_RIGHT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //Second column
        cell = new PdfPCell();
        cell.setPaddingLeft(10);
        cell.setPaddingTop(0);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(languageList.get(i).level, font2);
        cell.addElement(paragraph);
        table.addCell(cell);

        document.add(table);
    }
}

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

private void addSkills(User user, List<String> personalCharacteristics, List<Skill> skills)
        throws DocumentException {
    Paragraph paragraph;/*from  ww  w  . j  a  v a 2 s . c o m*/
    PdfPCell cell;
    PdfPTable table;

    List<String> rankedSkills = selectSkills(skills);
    if (personalCharacteristics.size() != 0 && rankedSkills.size() != 0) {
        table = new PdfPTable(new float[] { 1f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(5);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("HABILIDADES PERSONALES", font1);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(
                "Me defino como una persona de carcter " + personalCharacteristics.get(1).toLowerCase()
                        + " y " + personalCharacteristics.get(0).toLowerCase() + ".",
                font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("Entre mis puntos fuertes destacan las " + rankedSkills.get(0).toLowerCase()
                + " y las " + rankedSkills.get(1).toLowerCase() + ".", font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph(
                "Considero que soy una persona activa que presenta " + rankedSkills.get(2).toLowerCase() + ".",
                font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        //First column
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph = new Paragraph("Adems, una de las caractersticas que me define es que soy "
                + personalCharacteristics.get(2).toLowerCase() + ".", font2);
        cell.setBorder(PdfPCell.NO_BORDER);
        paragraph.setAlignment(Paragraph.ALIGN_LEFT);
        cell.setPaddingRight(10);
        cell.addElement(paragraph);
        table.addCell(cell);

        if (!user.drivingLicense.equals("No tengo carnet")) {
            //First column
            cell = new PdfPCell();
            cell.setBorder(PdfPCell.NO_BORDER);
            paragraph = new Paragraph("Permiso de conducir: " + user.drivingLicense + ".", font2);
            cell.setBorder(PdfPCell.NO_BORDER);
            paragraph.setAlignment(Paragraph.ALIGN_LEFT);
            cell.setPaddingRight(10);
            cell.addElement(paragraph);
            table.addCell(cell);
        }

        document.add(table);

    }
}

From source file:validator.Invoice.java

public static boolean printInvoice(HttpServletResponse response)
        throws DocumentException, FileNotFoundException {
    Document document = new Document();
    java.net.URL path = LogData.class.getResource("/");
    String destinationDir;/*from   w w w  .jav a2 s . c  o m*/
    destinationDir = path.toString();
    destinationDir = destinationDir.substring(destinationDir.lastIndexOf(":") + 1,
            destinationDir.indexOf("WEB-INF"));
    String filePath = destinationDir + "invoice" + "/";
    ;
    File fileName = new File(filePath);
    if (!fileName.exists()) {
        fileName.mkdir();
    }

    filePath = filePath + "invoice" + ".pdf";
    PdfWriter.getInstance(document, new FileOutputStream(filePath));
    document.open();
    Paragraph paragraph1 = new Paragraph("Invoice");
    paragraph1.setAlignment(Element.ALIGN_CENTER);

    paragraph1.setFont(FontFactory.getFont(FontFactory.COURIER, 18, Font.BOLD, new CMYKColor(0, 255, 0, 0)));
    Paragraph datePara = new Paragraph("Date :" + new Date());
    datePara.setAlignment(Element.ALIGN_RIGHT);

    File file = new File(filePath);
    PdfPTable table = new PdfPTable(2);
    table.setSpacingBefore(25);
    table.setWidthPercentage(100);
    table.setSpacingAfter(25);

    PdfPCell c1 = new PdfPCell(new Phrase("Description"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase(" Amount "));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);
    table.addCell("         " + "   ");
    table.addCell("         " + "  ");
    table.addCell("          Total Balance amount :");
    table.addCell("         " + "   ");
    Paragraph amountPara = new Paragraph("\nPaid Amount:  ");
    Paragraph forCom = new Paragraph("\n For Company: ");
    document.open();
    document.add(paragraph1);
    document.add(datePara);
    document.add(table);
    document.add(amountPara);
    document.add(forCom);
    document.close();
    streamImageFile(file, response);

    return true;
}

From source file:WeeklyReport.Sections.Commodities.java

public PdfPTable commoditySectionIntroduction() {
    PdfPTable table = new PdfPTable(1);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);/*from   w  w w .  j  a va2s  .  c o m*/
    table.setSpacingBefore(10f);

    cell = new PdfPCell(new Phrase("COMMODITIES", SECTION_HEADING));
    cell.setColspan(1);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    // Get the top two commodities from the HashMap
    Map<String, String> m = new CargoTypeData().topTwoCommodities();
    //ArrayList to add the commodities to
    ArrayList<String> commodities = new ArrayList<>();
    m.entrySet().stream().forEach((entry) -> {
        commodities.add(entry.getKey());
    });

    cell = new PdfPCell(new Phrase("During week " + new ReportingDates().reportPeriod() + " a total of "
            + new CustomerQuoteData().totalQuotes()
            + " were generated through RQS. Of these quotes the top two commodity classes quoted were "
            + commodities.get(0) + " and " + commodities.get(1)
            + ". The below table depicts the top ten commodities quoted during week "
            + new ReportingDates().reportPeriod() + ".", TEXT_FONT));
    cell.setColspan(1);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    return table;
}

From source file:WeeklyReport.Sections.Commodities.java

public PdfPTable byCommodityTable() {
    PdfPTable table = new PdfPTable(2);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);//from  www  .  java 2  s .c  o m
    table.setSpacingBefore(10f);

    cell = new PdfPCell(new Phrase("Quotes by Commodity", SUBHEADING_FONT));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(2);
    cell.setPaddingBottom(10f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    Map<String, String> m = new CargoTypeData().quotesByCommodity();
    m.entrySet().stream().forEach((entry) -> {
        cell = new PdfPCell(new Phrase(entry.getKey(), TEXT_FONT));
        cell.setColspan(1);
        cell.setBorder(Rectangle.BOTTOM);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(entry.getValue(), TEXT_FONT));
        cell.setColspan(1);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cell.setBorder(Rectangle.BOTTOM);
        table.addCell(cell);
    });
    return table;
}

From source file:WeeklyReport.Sections.RegionalQuoteData.java

public PdfPTable regionalAnalysis() {
    PdfPTable table = new PdfPTable(1);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);//ww  w . j  a  v  a  2 s  . c o m
    table.setSpacingBefore(10f);

    cell = new PdfPCell(new Phrase("Regional Quote Data", SECTION_HEADING));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    cell.setPaddingBottom(10f);
    table.addCell(cell);

    String pending = null;

    if (PENDING_RESPONSE == 1) {
        pending = PENDING_RESPONSE + " is pending further action.";
    } else {
        pending = PENDING_RESPONSE + " are pending further action.";
    }

    cell = new PdfPCell(new Phrase("In week " + new ReportingDates().reportPeriod() + " a total of "
            + new CustomerQuoteData().totalNAQuotes()
            + " quotes were generated through RQS to North American customers (not including Canada). Of these quotes there were "
            + DECLINES + " declines, " + BOOKINGS + " bookings, and " + FEEDBACK
            + " received customer feedback, and " + pending, TEXT_FONT));
    cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    return table;

}

From source file:WeeklyReport.Sections.RegionalQuoteData.java

public PdfPTable northEastTable() {
    PdfPTable table = new PdfPTable(4);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);// ww w  .ja  v a  2  s .  co m
    table.setSpacingBefore(10f);

    cell = new PdfPCell(new Phrase("North East", SUBHEADING_FONT));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(4);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Company Name", COLUMN_HEADER));
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Trade Lane", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Unit Count", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Cubic Meters", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    Map<Map<String, String>, Map<String, String>> m = NORTH_EAST_QUOTES;
    m.entrySet().stream().map((entry) -> {
        Map<String, String> m1 = entry.getKey();
        m1.entrySet().stream().map((pair) -> {
            companyCell = new PdfPCell(new Phrase(String.valueOf(pair.getValue()), TEXT_FONT));
            return pair;
        }).forEach((pair) -> {
            tradeCell = new PdfPCell(new Phrase(String.valueOf(pair.getKey()), TEXT_FONT));
        });
        return entry;
    }).map((entry) -> {
        companyCell.setColspan(1);
        tradeCell.setColspan(1);
        return entry;
    }).map((entry) -> {
        companyCell.setBorder(Rectangle.BOTTOM);
        tradeCell.setBorder(Rectangle.BOTTOM);
        return entry;
    }).map((entry) -> {
        table.addCell(companyCell);
        table.addCell(tradeCell);
        Map<String, String> m1 = entry.getValue();
        m1.entrySet().stream().map((pair) -> {
            unitCell = new PdfPCell(new Phrase(String.valueOf(pair.getKey()), TEXT_FONT));
            return pair;
        }).forEach((pair) -> {
            cubicMetersCell = new PdfPCell(new Phrase(String.valueOf(pair.getValue()), TEXT_FONT));
        });
        return entry;
    }).map((_item) -> {
        unitCell.setColspan(1);
        cubicMetersCell.setColspan(1);
        return _item;
    }).map((_item) -> {
        unitCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cubicMetersCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        return _item;
    }).map((_item) -> {
        unitCell.setBorder(Rectangle.BOTTOM);
        cubicMetersCell.setBorder(Rectangle.BOTTOM);
        return _item;
    }).forEach((_item) -> {
        table.addCell(unitCell);
        table.addCell(cubicMetersCell);
    });
    return table;
}

From source file:WeeklyReport.Sections.RegionalQuoteData.java

public PdfPTable midWestTable() {
    PdfPTable table = new PdfPTable(4);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);//w ww .ja v a2 s  .  com
    table.setSpacingBefore(10f);

    cell = new PdfPCell(new Phrase("Mid West", SUBHEADING_FONT));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(4);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Company Name", COLUMN_HEADER));
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Trade Lane", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Unit Count", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Cubic Meters", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    Map<Map<String, String>, Map<String, String>> m = MID_WEST_QUOTES;
    m.entrySet().stream().map((entry) -> {
        Map<String, String> m1 = entry.getKey();
        m1.entrySet().stream().map((pair) -> {
            companyCell = new PdfPCell(new Phrase(String.valueOf(pair.getValue()), TEXT_FONT));
            return pair;
        }).forEach((pair) -> {
            tradeCell = new PdfPCell(new Phrase(String.valueOf(pair.getKey()), TEXT_FONT));
        });
        return entry;
    }).map((entry) -> {
        companyCell.setColspan(1);
        tradeCell.setColspan(1);
        return entry;
    }).map((entry) -> {
        companyCell.setBorder(Rectangle.BOTTOM);
        tradeCell.setBorder(Rectangle.BOTTOM);
        return entry;
    }).map((entry) -> {
        table.addCell(companyCell);
        table.addCell(tradeCell);
        Map<String, String> m1 = entry.getValue();
        m1.entrySet().stream().map((pair) -> {
            unitCell = new PdfPCell(new Phrase(String.valueOf(pair.getKey()), TEXT_FONT));
            return pair;
        }).forEach((pair) -> {
            cubicMetersCell = new PdfPCell(new Phrase(String.valueOf(pair.getValue()), TEXT_FONT));
        });
        return entry;
    }).map((_item) -> {
        unitCell.setColspan(1);
        cubicMetersCell.setColspan(1);
        return _item;
    }).map((_item) -> {
        unitCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cubicMetersCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        return _item;
    }).map((_item) -> {
        unitCell.setBorder(Rectangle.BOTTOM);
        cubicMetersCell.setBorder(Rectangle.BOTTOM);
        return _item;
    }).forEach((_item) -> {
        table.addCell(unitCell);
        table.addCell(cubicMetersCell);
    });
    return table;
}

From source file:WeeklyReport.Sections.RegionalQuoteData.java

public PdfPTable westCoastTable() {
    PdfPTable table = new PdfPTable(4);
    table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.setWidthPercentage(100f);// w ww . ja va2  s .c  o  m
    table.setSpacingBefore(10f);

    cell = new PdfPCell(new Phrase("West Coast", SUBHEADING_FONT));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(4);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Company Name", COLUMN_HEADER));
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Trade Lane", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Unit Count", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase("Cubic Meters", COLUMN_HEADER));
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5f);
    cell.setBorder(Rectangle.BOTTOM);
    cell.setBorderWidthBottom(2f);
    table.addCell(cell);

    Map<Map<String, String>, Map<String, String>> m = WEST_COAST_QUOTES;
    m.entrySet().stream().map((entry) -> {
        Map<String, String> m1 = entry.getKey();
        m1.entrySet().stream().map((pair) -> {
            companyCell = new PdfPCell(new Phrase(String.valueOf(pair.getValue()), TEXT_FONT));
            return pair;
        }).forEach((pair) -> {
            tradeCell = new PdfPCell(new Phrase(String.valueOf(pair.getKey()), TEXT_FONT));
        });
        return entry;
    }).map((entry) -> {
        companyCell.setColspan(1);
        tradeCell.setColspan(1);
        return entry;
    }).map((entry) -> {
        companyCell.setBorder(Rectangle.BOTTOM);
        tradeCell.setBorder(Rectangle.BOTTOM);
        return entry;
    }).map((entry) -> {
        table.addCell(companyCell);
        table.addCell(tradeCell);
        Map<String, String> m1 = entry.getValue();
        m1.entrySet().stream().map((pair) -> {
            unitCell = new PdfPCell(new Phrase(String.valueOf(pair.getKey()), TEXT_FONT));
            return pair;
        }).forEach((pair) -> {
            cubicMetersCell = new PdfPCell(new Phrase(String.valueOf(pair.getValue()), TEXT_FONT));
        });
        return entry;
    }).map((_item) -> {
        unitCell.setColspan(1);
        cubicMetersCell.setColspan(1);
        return _item;
    }).map((_item) -> {
        unitCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cubicMetersCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        return _item;
    }).map((_item) -> {
        unitCell.setBorder(Rectangle.BOTTOM);
        cubicMetersCell.setBorder(Rectangle.BOTTOM);
        return _item;
    }).forEach((_item) -> {
        table.addCell(unitCell);
        table.addCell(cubicMetersCell);
    });
    return table;
}

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.j a  v a  2s  .com
        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);
    }
}