Example usage for com.itextpdf.text.pdf PdfPCell setBorder

List of usage examples for com.itextpdf.text.pdf PdfPCell setBorder

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setBorder.

Prototype

public void setBorder(final int border) 

Source Link

Document

Enables/Disables the border on the specified sides.

Usage

From source file:reporteFertilizacion.ReporteResultadoLaboratorio.java

public PdfPCell getCell(String text, int alignment, Font fuente) {
    PdfPCell cell = new PdfPCell(new Phrase(text, fuente));
    cell.setPadding(1f);/*w  ww. j a v  a2  s.co m*/
    cell.setHorizontalAlignment(alignment);
    cell.setBorder(PdfPCell.NO_BORDER);

    return cell;
}

From source file:reporteFertilizacion.ReporteResultadoLaboratorio.java

public PdfPCell getCellFooter(String text, int alignment, Font fuente) {
    PdfPCell cell = new PdfPCell(new Phrase(text, fuente));
    cell.setPadding(2f);/*  w  w w  . j a v  a2 s .  c o  m*/
    cell.setHorizontalAlignment(alignment);
    cell.setBorder(PdfPCell.NO_BORDER);

    return cell;
}

From source file:reportes.ServletIntegral.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession();
    ServletConfig config = getServletConfig();
    ServletContext context = config.getServletContext();
    String path = context.getContextPath();
    String realPath = context.getRealPath("/");
    response.setContentType("application/pdf");
    //Para descargar el PDF
    response.setHeader("Content-Disposition", "attachment; filename=\"ResultadoIntegral.pdf\"");
    // step 1: creation of a document-object
    try {/*from   w  w  w .  j a  v a2  s.  co m*/
        Document document = new Document(PageSize.LETTER);
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a temporary buffer
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, buffer);
        // step 3: we open the document
        document.open();
        // step 4: we add  content to the document
        Paragraph title = new Paragraph(
                (session.getAttribute("nEmpresa") != null) ? session.getAttribute("nEmpresa").toString()
                        : "Empresa");
        title.setAlignment(Element.ALIGN_CENTER);
        title.setFont(NORMAL);
        document.add(title);
        title = new Paragraph("Estado de resultado integral del 01 de Enero al 31 de Diciembre del "
                + (new Date().getYear() + 1900));
        title.setAlignment(Element.ALIGN_CENTER);
        title.setFont(NORMAL);
        document.add(title);
        title = new Paragraph("Cifras en miles de pesos");
        title.setAlignment(Element.ALIGN_CENTER);
        title.setFont(NORMAL);
        document.add(title);
        for (int i = 0; i < 2; i++) {
            document.add(new Paragraph(" "));
        }
        PdfPTable table = new PdfPTable(2);
        //Obtenemos los datos de la clase ResultadoIntegral
        ResultadoIntegral r = new ResultadoIntegral();
        r.calculaResultado(Integer.parseInt(session.getAttribute("Empresa").toString()));
        for (int i = 0; i < r.getSaldos().size(); i++) {
            PdfPCell dato = new PdfPCell();
            if (i == 2 || i == 7 || i == 12 || i == 14 || i == 16 || i == 18 || i == 19 || i == 17) {
                Chunk ch = new Chunk(descripciones[i]);
                ch.setFont(BOLD_Tot);
                Phrase ph = new Phrase(ch);
                dato.setPhrase(ph);
            } else {
                Phrase ph = new Phrase(descripciones[i]);
                dato.setPhrase(ph);
            }
            dato.setBorder(Rectangle.NO_BORDER);
            dato.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(dato);
            if (r.getValores().size() > 0) {
                Chunk ch = new Chunk();
                if (r.getSaldos().get(i) < 0) {
                    String valor = "(" + (r.getSaldos().get(i) * (-1)) + ")";
                    ch.append(valor);
                    ch.setFont(NORMAL_Negative);
                } else {
                    dato.setPhrase(new Phrase("" + r.getSaldos().get(i)));
                }
            } else {
                dato.setPhrase(new Phrase("0.0"));
            }
            if (i == 1 || i == 6 || i == 11 || i == 13 || i == 15 || i == 17 || i == 18) {
                dato.setBorder(Rectangle.BOTTOM);
            } else {
                dato.setBorder(Rectangle.NO_BORDER);
            }
            dato.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(dato);
        }
        document.add(table);
        document.add(new Paragraph(""));
        // step 5: we close the document
        document.close();
        // step 6: we output the writer as bytes to the response output
        DataOutputStream output = new DataOutputStream(response.getOutputStream());
        byte[] bytes = buffer.toByteArray();
        response.setContentLength(bytes.length);
        for (int i = 0; i < bytes.length; i++) {
            output.writeByte(bytes[i]);
        }
        output.close();
        response.getOutputStream();
        //session.removeAttribute("bean");
        //session.removeAttribute("producto");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:rs.marko.helper.Kreiranje.java

public static File createPdfObracuni(List<Stavkadnevneberbe> stavke, Date pocetak, Date kraj) {
    Document document = new Document();
    //        document.setPageSize(PageSize.A4.rotate());
    File yourFile = null;//from  w  w w. j a  v a2s  . co m
    try {
        yourFile = new File(System.getProperty("user.home") + "/Desktop/" + pocetak + "_" + kraj + ".pdf");
        if (!yourFile.exists()) {
            yourFile.createNewFile();
        }
        FileOutputStream oFile = new FileOutputStream(yourFile, false);
        PdfWriter.getInstance(document, oFile);
        document.open();
        //                        String text = "";
        //                        for (int i = 0; i < 10000; i++) {
        //                                text += "test";
        //              ,          }
        //            String jmbg = stavke.get(0).getDobavljac().getJmbg();

        List<String> jmbgovi = new ArrayList<>();
        Map<Double, Double> kt = new HashMap<>();
        Map<Double, Double> k1 = new HashMap<>();
        Map<Double, Double> k2 = new HashMap<>();
        Map<Double, Double> k3 = new HashMap<>();

        for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) {
            if (!jmbgovi.contains(stavkaDnevneBerbe.getStavkadnevneberbePK().getJmbg())) {
                jmbgovi.add(stavkaDnevneBerbe.getStavkadnevneberbePK().getJmbg());
            }
        }
        Map<Double, Double> ukupnoTacne = new HashMap<>();
        Map<Double, Double> ukupnoPrvaKlasa = new HashMap<>();
        Map<Double, Double> ukupnoDrugaKlasa = new HashMap<>();
        Map<Double, Double> ukupnoTrecaKlasa = new HashMap<>();
        for (String j : jmbgovi) {
            String imeDobavljaca = null;
            for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) {
                if (stavkaDnevneBerbe.getStavkadnevneberbePK().getJmbg().equals(j)) {
                    if (imeDobavljaca == null) {
                        imeDobavljaca = stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getIme() + " "
                                + stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getPrezime();

                    }
                    if (!kt.containsKey(stavkaDnevneBerbe.getCenatacne())
                            && stavkaDnevneBerbe.getTacne() != 0) {
                        kt.put(stavkaDnevneBerbe.getCenatacne(), new Double(0));
                    }
                    if (!k1.containsKey(stavkaDnevneBerbe.getCenaprvaklasa())
                            && stavkaDnevneBerbe.getCenaprvaklasa() != 0) {
                        k1.put(stavkaDnevneBerbe.getCenaprvaklasa(), new Double(0));
                    }
                    if (!k2.containsKey(stavkaDnevneBerbe.getCenadrugaklasa())
                            && stavkaDnevneBerbe.getCenadrugaklasa() != 0) {
                        k2.put(stavkaDnevneBerbe.getCenadrugaklasa(), new Double(0));
                    }
                    if (!k3.containsKey(stavkaDnevneBerbe.getCenatrecaklasa())
                            && stavkaDnevneBerbe.getCenatrecaklasa() != 0) {
                        k3.put(stavkaDnevneBerbe.getCenatrecaklasa(), new Double(0));
                    }
                }
            }
            for (Stavkadnevneberbe s : stavke) {
                if (s.getDnevnaberba().getDobavljac().getJmbg().equals(j)) {
                    if (kt.containsKey(s.getCenatacne())) {
                        kt.put(s.getCenatacne(), kt.get(s.getCenatacne()) + s.getTacne());
                    }
                    if (k1.containsKey(s.getCenaprvaklasa())) {
                        k1.put(s.getCenaprvaklasa(), k1.get(s.getCenaprvaklasa()) + s.getPrvaklasa());
                    }
                    if (k2.containsKey(s.getCenadrugaklasa())) {
                        k2.put(s.getCenadrugaklasa(), k2.get(s.getCenadrugaklasa()) + s.getDrugaklasa());
                    }
                    if (k3.containsKey(s.getCenatrecaklasa())) {
                        k3.put(s.getCenatrecaklasa(), k3.get(s.getCenatrecaklasa()) + s.getTrecaklasa());
                    }
                }
            }
            PdfPTable table = new PdfPTable(4);
            Paragraph p = new Paragraph(imeDobavljaca);
            document.add(p);
            p = new Paragraph("Od: " + pocetak + " do: " + kraj);
            p.add(new Paragraph(" "));
            document.add(p);
            PdfPCell c = new PdfPCell(new Phrase(""));
            PdfPCell c1 = new PdfPCell(new Phrase("Naziv"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Kolicina"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Cena"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase("Ukupno"));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(c1);
            //                table.setHeaderRows(1);
            Iterator it = kt.entrySet().iterator();
            Double ukupnoKolicinaT = 0.0;
            Double ukupnoCenaT = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                table.addCell("Tacne");
                table.addCell(round((Double) pair.getValue(), 2) + "");
                table.addCell(round((Double) pair.getKey(), 2) + "");
                ukupnoKolicinaT += (Double) pair.getValue();
                ukupnoCenaT += ((Double) pair.getKey() * (Double) pair.getValue());
                table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
                if (!ukupnoTacne.containsKey((Double) pair.getKey())) {
                    ukupnoTacne.put((Double) pair.getKey(), (Double) pair.getValue());
                } else {
                    ukupnoTacne.put((Double) pair.getKey(),
                            ukupnoTacne.get((Double) pair.getKey()) + (Double) pair.getValue());
                }
            }
            if (ukupnoKolicinaT != 0) {
                c.setBorder(0);
                table.addCell(c);
                table.addCell(round(ukupnoKolicinaT, 2) + "");
                table.addCell(c);
                table.addCell(round(ukupnoCenaT, 2) + "");
            }

            it = k1.entrySet().iterator();
            Double ukupnoKolicinaP = 0.0;
            Double ukupnoCenaP = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                table.addCell("Prva klasa");
                table.addCell(round((Double) pair.getValue(), 2) + "");
                table.addCell(round((Double) pair.getKey(), 2) + "");
                ukupnoKolicinaP += (Double) pair.getValue();
                ukupnoCenaP += ((Double) pair.getKey() * (Double) pair.getValue());
                table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
                if (!ukupnoPrvaKlasa.containsKey((Double) pair.getKey())) {
                    ukupnoPrvaKlasa.put((Double) pair.getKey(), (Double) pair.getValue());
                } else {
                    ukupnoPrvaKlasa.put((Double) pair.getKey(),
                            ukupnoPrvaKlasa.get((Double) pair.getKey()) + (Double) pair.getValue());
                }
            }
            if (ukupnoKolicinaP != 0) {
                table.addCell(c);
                table.addCell(round(ukupnoKolicinaP, 2) + "");
                table.addCell(c);
                table.addCell(round(ukupnoCenaP, 2) + "");
            }

            it = k2.entrySet().iterator();
            Double ukupnoKolicinaD = 0.0;
            Double ukupnoCenaD = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                table.addCell("Druga klasa");
                table.addCell(round((Double) pair.getValue(), 2) + "");
                table.addCell(round((Double) pair.getKey(), 2) + "");
                ukupnoKolicinaD += (Double) pair.getValue();
                ukupnoCenaD += ((Double) pair.getKey() * (Double) pair.getValue());
                table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
                if (!ukupnoDrugaKlasa.containsKey((Double) pair.getKey())) {
                    ukupnoDrugaKlasa.put((Double) pair.getKey(), (Double) pair.getValue());
                } else {
                    ukupnoDrugaKlasa.put((Double) pair.getKey(),
                            ukupnoDrugaKlasa.get((Double) pair.getKey()) + (Double) pair.getValue());
                }
            }
            if (ukupnoKolicinaD != 0) {
                table.addCell(c);
                table.addCell(round(ukupnoKolicinaD, 2) + "");
                table.addCell(c);
                table.addCell(round(ukupnoCenaD, 2) + "");
            }

            it = k3.entrySet().iterator();
            Double ukupnoKolicinaTr = 0.0;
            Double ukupnoCenaTr = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                table.addCell("Treca klasa");
                table.addCell(round((Double) pair.getValue(), 2) + "");
                table.addCell(round((Double) pair.getKey(), 2) + "");
                ukupnoKolicinaTr += (Double) pair.getValue();
                ukupnoCenaTr += ((Double) pair.getKey() * (Double) pair.getValue());
                table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
                if (!ukupnoTrecaKlasa.containsKey((Double) pair.getKey())) {
                    ukupnoTrecaKlasa.put((Double) pair.getKey(), (Double) pair.getValue());
                } else {
                    ukupnoTrecaKlasa.put((Double) pair.getKey(),
                            ukupnoTrecaKlasa.get((Double) pair.getKey()) + (Double) pair.getValue());
                }
            }
            if (ukupnoKolicinaTr != 0) {
                table.addCell(c);
                table.addCell(round(ukupnoKolicinaTr, 2) + "");
                table.addCell(c);
                table.addCell(round(ukupnoCenaTr, 2) + "");
            }

            Double ukupnoCena = ukupnoCenaD + ukupnoCenaP + ukupnoCenaT + ukupnoCenaTr;
            Double ukupnoKolicina = ukupnoKolicinaD + ukupnoKolicinaP + ukupnoKolicinaT + ukupnoKolicinaTr;

            table.addCell("UKUPNO:");
            table.addCell(round(ukupnoKolicina, 2) + "");
            table.addCell(c);
            table.addCell(round(ukupnoCena, 2) + "");

            document.add(table);
            document.add(new Paragraph(" "));
            kt.clear();
            k1.clear();
            k2.clear();
            k3.clear();
            //dodavanje u pdf
            //ciscenje lista
        }
        PdfPTable table = new PdfPTable(4);
        Paragraph p = new Paragraph("SVE UKUPNO");
        p.add(new Paragraph(" "));
        document.add(p);

        PdfPCell c = new PdfPCell(new Phrase(""));

        Double ukupnoKolicinaT = 0.0;
        Double ukupnoVrednostT = 0.0;
        Iterator it = ukupnoTacne.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            table.addCell("Tacne");
            if ((Double) pair.getKey() == 110) {
                table.addCell(round((Double) pair.getValue(), 2) + "");
                table.addCell(round(106.0, 2) + "");
                ukupnoKolicinaT += (Double) pair.getValue();
                ukupnoVrednostT += (106 * (Double) pair.getValue());
                table.addCell(round(106 * (Double) pair.getValue(), 2) + "");
            } else {
                table.addCell(round((Double) pair.getValue(), 2) + "");
                table.addCell(round((Double) pair.getKey(), 2) + "");
                ukupnoKolicinaT += (Double) pair.getValue();
                ukupnoVrednostT += ((Double) pair.getKey() * (Double) pair.getValue());
                table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
            }
        }
        if (ukupnoKolicinaT != 0) {
            c.setBorder(0);
            table.addCell(c);
            table.addCell(round(ukupnoKolicinaT, 2) + "");
            table.addCell(c);
            table.addCell(round(ukupnoVrednostT, 2) + "");
        }

        it = ukupnoPrvaKlasa.entrySet().iterator();
        Double ukupnoKolicinaP = 0.0;
        Double ukupnoVrednostP = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            table.addCell("Prva klasa");
            table.addCell(round((Double) pair.getValue(), 2) + "");
            table.addCell(round((Double) pair.getKey(), 2) + "");
            ukupnoKolicinaP += (Double) pair.getValue();
            ukupnoVrednostP += ((Double) pair.getKey() * (Double) pair.getValue());
            table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
        }
        if (ukupnoKolicinaP != 0) {
            table.addCell(c);
            table.addCell(round(ukupnoKolicinaP, 2) + "");
            table.addCell(c);
            table.addCell(round(ukupnoVrednostP, 2) + "");
        }

        it = ukupnoDrugaKlasa.entrySet().iterator();
        Double ukupnoKolicinaD = 0.0;
        Double ukupnoVrednostD = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            table.addCell("Druga klasa");
            table.addCell(round((Double) pair.getValue(), 2) + "");
            table.addCell(round((Double) pair.getKey(), 2) + "");
            ukupnoKolicinaD += (Double) pair.getValue();
            ukupnoVrednostD += ((Double) pair.getKey() * (Double) pair.getValue());
            table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
        }
        if (ukupnoKolicinaD != 0) {
            table.addCell(c);
            table.addCell(round(ukupnoKolicinaD, 2) + "");
            table.addCell(c);
            table.addCell(round(ukupnoVrednostD, 2) + "");
        }

        it = ukupnoTrecaKlasa.entrySet().iterator();
        Double ukupnoKolicinaTr = 0.0;
        Double ukupnoVrednostTr = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            table.addCell("Treca klasa");
            table.addCell(round((Double) pair.getValue(), 2) + "");
            table.addCell(round((Double) pair.getKey(), 2) + "");
            ukupnoKolicinaTr += (Double) pair.getValue();
            ukupnoVrednostTr += ((Double) pair.getKey() * (Double) pair.getValue());
            table.addCell(round((Double) pair.getKey() * (Double) pair.getValue(), 2) + "");
        }
        if (ukupnoKolicinaTr != 0) {
            table.addCell(c);
            table.addCell(round(ukupnoKolicinaTr, 2) + "");
            table.addCell(c);
            table.addCell(round(ukupnoVrednostTr, 2) + "");
        }

        Double ukupnoVrednostSve = ukupnoVrednostT + ukupnoVrednostP + ukupnoVrednostD + ukupnoVrednostTr;
        Double ukupnoKolicina = ukupnoKolicinaD + ukupnoKolicinaP + ukupnoKolicinaT + ukupnoKolicinaTr;

        table.addCell("UKUPNO:");
        table.addCell(round(ukupnoKolicina, 2) + "");
        table.addCell(c);
        table.addCell(round(ukupnoVrednostSve, 2) + "");

        document.add(table);
        //            String text = "Marko";
        //
        //            // t.setBorderColor(BaseColor.GRAY);
        //            // t.setPadding(4);
        //            // t.setSpacing(4);
        //            // t.setBorderWidth(1);
        //            PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1"));
        //            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            table.addCell(c1);
        //
        //            c1 = new PdfPCell(new Phrase("Table Header 2"));
        //            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            table.addCell(c1);
        //
        //            c1 = new PdfPCell(new Phrase("Table Header 3"));
        //            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            table.addCell(c1);
        //            table.setHeaderRows(1);
        //
        //            table.addCell("1.0");
        //            table.addCell("1.1");
        //            table.addCell("1.2");
        //            table.addCell("2.1");
        //            table.addCell("2.2");
        //            table.addCell("2.3");
        //            Paragraph p = new Paragraph(text);
        //            p.add(new Paragraph(" "));
        //            document.add(p);
        //            document.add(table);
    } catch (DocumentException e) {
        System.err.println(e.getMessage());
    } catch (IOException ex) {
        System.err.println(ex.getMessage());
    }
    document.close();
    return yourFile;
}

From source file:se.billes.pdf.renderer.model.text.TableParagraph.java

License:Open Source License

@Override
public void onRender(PdfPCell cell) throws PdfRenderException {

    PdfPTable table = new PdfPTable(widths.length);

    try {//from www .ja v  a  2 s.c  o  m
        table.setTotalWidth(getTotalWidthsAsPs());
        table.setLockedWidth(true);
        table.setSpacingAfter(0f);

        for (AbstractParagraph tableCell : cells) {

            PdfPCell c = new PdfPCell();
            float[] padding = new float[] { 0f, 0f, 0f, 0f };
            if (tableCell instanceof TableCell) {
                padding = ((TableCell) tableCell).getPadding();
            }
            c.setBorderWidth(0f);
            c.setLeft(0);
            c.setTop(0);
            c.setRight(0);
            c.setBottom(0);
            c.setUseAscender(true);
            c.setIndent(0);
            c.setHorizontalAlignment(Element.ALIGN_LEFT);
            c.setVerticalAlignment(Element.ALIGN_TOP);
            c.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(padding[0]));
            c.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(padding[3]));
            c.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(padding[2]));
            c.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(padding[1]));
            c.setBorder(0);
            tableCell.onRender(c);

            table.addCell(c);

        }
        cell.addElement(table);
    } catch (Exception e) {
        throw new PdfRenderException(e);
    }
}

From source file:se.billes.pdf.renderer.request.factory.CellFactory.java

License:Open Source License

public PdfPCell createCell(Block block) {
    float[] margins = block.getMargins();
    PdfPCell cell = new PdfPCell();
    cell.setBorderWidth(0);//from w  w w.  j a  v a  2 s  .  c  o  m
    cell.setVerticalAlignment(VerticalAlign.getByName(block.getVerticalAlign()).getAlignment());
    cell.setLeft(0);
    cell.setTop(0);
    cell.setRight(0);
    cell.setBottom(0);
    cell.setUseAscender(block.isUseAscender());
    cell.setIndent(0);
    cell.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(margins[0]));
    cell.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(margins[3]));
    cell.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(margins[1]));
    cell.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(margins[2]));
    cell.setFixedHeight(SizeFactory.millimetersToPostscriptPoints(block.getPosition()[3]));
    cell.setBorder(0);
    cell.setCellEvent(new CellBlockEvent().createEvent(block));
    cell.setRotation(block.getRotation());
    return cell;
}

From source file:se.billes.pdf.renderer.request.factory.CellFactory.java

License:Open Source License

public PdfPCell getFillCell() {
    PdfPCell fillCell = new PdfPCell();
    fillCell.setBorderWidth(0f);//from  ww  w.j  ava 2s  .co  m
    fillCell.setLeft(0);
    fillCell.setTop(0);
    fillCell.setRight(0);
    fillCell.setBottom(0);
    fillCell.setUseAscender(true);
    fillCell.setIndent(0);
    fillCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    fillCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    fillCell.setPaddingLeft(0f);
    fillCell.setPaddingBottom(0f);
    fillCell.setPaddingRight(0f);
    fillCell.setPaddingTop(0f);
    fillCell.setBorder(0);
    renderEmptyCell(fillCell);

    return fillCell;
}

From source file:se.inera.intyg.rehabstod.service.export.pdf.HeaderEventHandler.java

License:Open Source License

private PdfPCell getLogoCell() {
    float scalePercentage = LOGO_SCALE_FACTOR;
    logo.scalePercent(scalePercentage);//from w ww.  j  av  a 2  s  .  c o m
    PdfPCell imageCell = new PdfPCell(logo, false);
    imageCell.setBorder(Rectangle.NO_BORDER);
    return imageCell;
}

From source file:se.inera.intyg.rehabstod.service.export.pdf.HeaderEventHandler.java

License:Open Source License

private PdfPCell printedBy(String userName, String enhetsNamn) {
    LocalDateTime now = LocalDateTime.now();

    Phrase printedBy = new Phrase("", PdfExportConstants.TABLE_CELL_NORMAL);
    printedBy.add(new Chunk("Utskrift av " + userName));
    printedBy.add(Chunk.NEWLINE);/*from   w  w  w . j a  v  a 2s .c  o m*/
    printedBy.add(new Chunk(enhetsNamn));
    printedBy.add(Chunk.NEWLINE);
    printedBy.add(new Chunk(YearMonthDateFormatter.print(now)));
    printedBy.add(new Chunk(" - "));
    printedBy.add(new Chunk(HourMinuteFormatter.print(now)));

    PdfPCell cell = new PdfPCell(printedBy);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(Rectangle.NO_BORDER);

    return cell;
}

From source file:se.inera.intyg.rehabstod.service.export.pdf.PageNumberingEventHandler.java

License:Open Source License

/**
 * Adds a header to every page.//from ww  w. j  ava  2s. c  o  m
 *
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter,
 *      com.itextpdf.text.Document)
 */
@Override
public void onEndPage(PdfWriter writer, Document document) {

    try {
        PdfPTable table = new PdfPTable(2);

        table.setTotalWidth(document.getPageSize().getWidth());

        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        table.addCell(new Phrase(String.valueOf(writer.getPageNumber()), PdfExportConstants.TABLE_CELL_NORMAL));
        PdfPCell cell = new PdfPCell(Image.getInstance(total));
        cell.setBorder(Rectangle.NO_BORDER);
        table.addCell(cell);
        table.writeSelectedRows(0, -1, document.left(), document.bottom(), writer.getDirectContent());

    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}