Example usage for com.lowagie.text Table setPadding

List of usage examples for com.lowagie.text Table setPadding

Introduction

In this page you can find the example usage for com.lowagie.text Table setPadding.

Prototype

public void setPadding(float value) 

Source Link

Document

Sets the cellpadding.

Usage

From source file:net.bull.javamelody.swing.print.MPdfWriter.java

License:Apache License

/**
 * Ecrit le pdf./*from w w w . ja  v  a  2  s .  co  m*/
 *
 * @param table
 *           MBasicTable
 * @param out
 *           OutputStream
 * @throws IOException
 *            e
 */
protected void writePdf(final MBasicTable table, final OutputStream out) throws IOException {
    try {
        // step 1: creation of a document-object
        final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4;
        final Document document = new Document(pageSize, 50, 50, 50, 50);
        // step 2: we create a writer that listens to the document and directs a PDF-stream to out
        createWriter(table, document, out);

        // we add some meta information to the document, and we open it
        document.addAuthor(System.getProperty("user.name"));
        document.addCreator("JavaMelody");
        final String title = buildTitle(table);
        if (title != null) {
            document.addTitle(title);
        }
        document.open();

        // ouvre la bote de dialogue Imprimer de Adobe Reader
        // if (writer instanceof PdfWriter) {
        // ((PdfWriter) writer).addJavaScript("this.print(true);", false);
        // }

        // table
        final Table datatable = new Table(table.getColumnCount());
        datatable.setCellsFitPage(true);
        datatable.setPadding(4);
        datatable.setSpacing(0);

        // headers
        renderHeaders(table, datatable);

        // data rows
        renderList(table, datatable);

        document.add(datatable);

        // we close the document
        document.close();
    } catch (final DocumentException e) {
        // on ne peut dclarer d'exception autre que IOException en throws
        throw new IOException(e);
    }
}

From source file:open.dolphin.client.AuditController.java

License:Open Source License

private void makePDF() {

    //- ?/*from   w  ww  .j  a  v a2s.  co m*/
    Document doc = new Document(PageSize.A4, 20.0F, 20.0F, 40.0F, 40.0F);

    try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String fileName = "_" + sdf.format(new java.util.Date()) + ".pdf";

        //()??
        FileOutputStream fos = new FileOutputStream(outputDir.getText() + fileName);
        PdfWriter pdfwriter = PdfWriter.getInstance(doc, fos);
        Font font_header = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 15.0F, 1);
        Font font_g11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F);
        Font font_g10 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 10.0F);
        //- ?
        Font font_m8 = new Font(BaseFont.createFont("HeiseiMin-W3", "UniJIS-UCS2-HW-H", false), 8.0F);
        Font font_underline_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F,
                4);
        Font font_red_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F);
        font_red_11.setColor(new Color(255, 0, 0));
        Font font_empty = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 9.0F);
        font_empty.setColor(new Color(255, 255, 255));

        Paragraph para_NF = new Paragraph(5, "\r\n",
                new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 13, Font.NORMAL));
        para_NF.setAlignment(Element.ALIGN_CENTER);

        // ??
        String author = Project.getProjectStub().getUserModel().getCommonName();
        doc.addAuthor(author);
        doc.addSubject("");

        HeaderFooter header = new HeaderFooter(new Phrase("", font_header),
                false);
        header.setAlignment(1);
        doc.setHeader(header);

        HeaderFooter footer = new HeaderFooter(new Phrase("--"), new Phrase("--"));
        footer.setAlignment(1);
        footer.setBorder(0);
        doc.setFooter(footer);

        doc.open();

        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy''MM''dd'' HH''mm''");
        String today = sdf1.format(new java.util.Date());
        Paragraph para_0 = new Paragraph("?" + today, font_g11);
        para_0.setAlignment(2);
        doc.add(para_0);
        Paragraph para_1 = new Paragraph("?" + author, font_g11);
        para_1.setAlignment(2);
        doc.add(para_1);
        doc.add(new Paragraph(""));
        // 
        doc.add(para_NF);
        doc.add(para_NF);

        for (int cnt = 0; cnt < outputList.size(); cnt++) {

            InnerBean bean = outputList.get(cnt);
            Person person = bean.getPerson();

            Paragraph para_2 = new Paragraph("ID" + person.idProperty().get(), font_underline_11);
            para_2.setAlignment(0);
            doc.add(para_2);
            Paragraph para_3 = new Paragraph("???" + person.nameProperty().get(),
                    font_underline_11);
            para_3.setAlignment(0);
            doc.add(para_3);
            Paragraph para_4 = new Paragraph("" + person.nameKanaProperty().get(),
                    font_underline_11);
            para_4.setAlignment(0);
            doc.add(para_4);
            Paragraph para_5 = new Paragraph("" + person.sexProperty().get(), font_underline_11);
            para_5.setAlignment(0);
            doc.add(para_5);
            Paragraph para_6 = new Paragraph("" + person.birthdayProperty().get(),
                    font_underline_11);
            para_6.setAlignment(0);
            doc.add(para_6);

            Table karteHistoryTable = new Table(5);
            karteHistoryTable.setWidth(100.0F);
            int[] uriage_table_width = { 25, 20, 30, 20, 25 };
            karteHistoryTable.setWidths(uriage_table_width);
            //karteHistoryTable.setDefaultHorizontalAlignment(1);
            //karteHistoryTable.setDefaultVerticalAlignment(5);
            karteHistoryTable.setPadding(3.0F);
            karteHistoryTable.setSpacing(0.0F);
            karteHistoryTable.setBorderColor(new Color(0, 0, 0));

            Cell cell_01 = new Cell(new Phrase("?", font_g10));
            cell_01.setGrayFill(0.8F);
            cell_01.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_11 = new Cell(new Phrase("?", font_g10));
            cell_11.setGrayFill(0.8F);
            cell_11.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_21 = new Cell(new Phrase("", font_g10));
            cell_21.setGrayFill(0.8F);
            cell_21.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_31 = new Cell(new Phrase("", font_g10));
            cell_31.setGrayFill(0.8F);
            cell_31.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_41 = new Cell(new Phrase("", font_g10));
            cell_41.setGrayFill(0.8F);
            cell_41.setHorizontalAlignment(Element.ALIGN_CENTER);

            karteHistoryTable.addCell(cell_01);
            karteHistoryTable.addCell(cell_11);
            karteHistoryTable.addCell(cell_21);
            karteHistoryTable.addCell(cell_31);
            karteHistoryTable.addCell(cell_41);

            List<KarteBean> list = bean.getResult();
            KarteBean karteInfo = list.get(0);
            List<DocInfoModel> docInfoList = karteInfo.getDocInfoList();

            //- ???
            int stepCount = 22;
            int tempCount = 0;
            int pageCount = 0;

            String firstKarteMaker = null;
            String karteMakeDate = null;
            if (docInfoList != null) {
                for (int i = 0; i < docInfoList.size(); ++i) {
                    DocInfoModel docInfo = docInfoList.get(i);
                    Cell cell = new Cell(new Phrase(docInfo.getFirstConfirmDateTime(), font_m8));
                    if (karteMakeDate == null || !karteMakeDate.equals(docInfo.getFirstConfirmDateTime())) {
                        karteMakeDate = docInfo.getFirstConfirmDateTime();
                        firstKarteMaker = docInfo.getPurpose();
                    }
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);
                    cell = new Cell(new Phrase(firstKarteMaker, font_m8));
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);
                    //- 
                    String addTitle = docInfo.getTitle();
                    addTitle = addTitle.replace("\r\n", "");
                    addTitle = addTitle.replace("\n", "");
                    cell = new Cell(new Phrase(addTitle, font_m8));
                    cell.setHorizontalAlignment(0);
                    karteHistoryTable.addCell(cell);
                    cell = new Cell(new Phrase(docInfo.getPurpose(), font_m8));
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);
                    cell = new Cell(new Phrase(docInfo.getConfirmDateTime(), font_m8));
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);

                    if (stepCount == tempCount) {
                        if (pageCount == 0) {
                            stepCount += 5;
                            pageCount++;
                        }
                        tempCount = 0;
                        doc.add(karteHistoryTable);
                        doc.newPage();
                        karteHistoryTable.deleteAllRows();
                        karteHistoryTable.addCell(cell_01);
                        karteHistoryTable.addCell(cell_11);
                        karteHistoryTable.addCell(cell_21);
                        karteHistoryTable.addCell(cell_31);
                        karteHistoryTable.addCell(cell_41);
                    } else {
                        tempCount++;
                    }
                }

                //                    Cell Empty_Cell = new Cell(new Phrase("empty", font_empty));
                //                    for (int i = docInfoList.size(); i < docInfoList.size() + 4; ++i) {
                //                        for (int j = 0; j < 4; ++j) {
                //                            karteHistoryTable.addCell(Empty_Cell);
                //                        }
                //                    }
                //
                //            Cell cell_goukei = new Cell(new Phrase("?", font_g10));
                //            cell_goukei.setGrayFill(0.8F);
                //            cell_goukei.setColspan(3);
                //            karteHistoryTable.addCell(cell_goukei);
                //            Cell cell_sum = new Cell(new Phrase("136,900", font_m10));
                //            cell_sum.setHorizontalAlignment(2);
                //            karteHistoryTable.addCell(cell_sum);
                doc.add(karteHistoryTable);
                doc.newPage();

            } else {
                // 
                doc.add(para_NF);

                Paragraph noData = new Paragraph("??", font_m8);
                noData.setAlignment(0);
                doc.add(noData);
                doc.newPage();
            }
        }
    } catch (DocumentException | IOException e) {
        Logger.getLogger(AuditController.class.getName()).log(Level.SEVERE, null, e);
    } finally {
        doc.close();
    }
}

From source file:opisiame.controller.gestion_resultat.Choix_exportController.java

@FXML
public void pdf_export() {
    File pdf_file = choix_chemin_enregistrement("PDF files (*.pdf)", "*.pdf");

    if (onglet_actif.equals("questions")) {

        if (pdf_file != null) {
            Document document = new Document(PageSize.A4);
            try {
                PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
                document.open();/*from w  ww .  j av  a 2  s . c om*/
                document.add(new Paragraph("Rsultat Quiz"));

                Table tableau = new Table(6, reponse_questions.size());
                tableau.setAutoFillEmptyCells(true);
                tableau.setPadding(2);

                Cell cell = new Cell("Question");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse A");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse B");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse C");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage reponse D");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage bonne rponse");
                cell.setHeader(true);
                tableau.addCell(cell);

                tableau.endHeaders();
                tableau.setWidth(100);
                fill_data_pdf(tableau);
                document.add(tableau);
            } catch (DocumentException | IOException de) {
                de.printStackTrace();
            }
            document.close();
        }

    } else if (onglet_actif.equals("eleves")) {

        if (pdf_file != null) {
            Document document = new Document(PageSize.A4);
            try {
                PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
                document.open();
                document.add(new Paragraph("Rsultats des tudiants"));

                Table tableau = new Table(5, resultats_eleves.size());
                tableau.setAutoFillEmptyCells(true);
                tableau.setPadding(2);

                Cell cell = new Cell("Nom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Prnom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("N tudiant");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Note");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage");
                cell.setHeader(true);
                tableau.addCell(cell);

                tableau.endHeaders();
                tableau.setWidth(100);
                fill_data_pdf(tableau);
                document.add(tableau);
            } catch (DocumentException | IOException de) {
                de.printStackTrace();
            }
            document.close();
        }
    } else if (onglet_actif.equals("eleves_pas_num")) {

        if (pdf_file != null) {
            Document document = new Document(PageSize.A4);
            try {
                PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
                document.open();
                document.add(new Paragraph("Rsultats des tudiants"));

                Table tableau = new Table(4, resultats_eleves.size());
                tableau.setAutoFillEmptyCells(true);
                tableau.setPadding(2);

                Cell cell = new Cell("Nom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Prnom");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Note");
                cell.setHeader(true);
                tableau.addCell(cell);

                cell = new Cell("Pourcentage");
                cell.setHeader(true);
                tableau.addCell(cell);

                tableau.endHeaders();
                tableau.setWidth(100);
                fill_data_pdf(tableau);
                document.add(tableau);
            } catch (DocumentException | IOException de) {
                de.printStackTrace();
            }
            document.close();
        }
    }

    close_window();
}

From source file:org.activityinfo.server.report.renderer.itext.ItextMapRenderer.java

License:Open Source License

private void renderLegend(MapReportElement element, Document doc) throws DocumentException, IOException {

    Table table = new Table(2);
    table.setBorderWidth(1);/*from  w w w  .j a  v a2  s  .com*/
    table.setWidth(100f);
    table.setBorderColor(new Color(100, 100, 100));
    table.setPadding(5);
    table.setSpacing(0);
    table.setCellsFitPage(true);
    table.setTableFitsPage(true);
    table.setWidths(new int[] { 1, 3 });

    Cell cell = new Cell(I18N.CONSTANTS.legend());
    cell.setHeader(true);
    cell.setColspan(2);
    table.addCell(cell);
    table.endHeaders();

    for (MapLayerLegend legend : element.getContent().getLegends()) {

        Cell symbolCell = new Cell();
        symbolCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        symbolCell.setVerticalAlignment(Element.ALIGN_MIDDLE);

        Image symbol = createLegendSymbol(legend, imageCreator);
        symbolCell.addElement(symbol);

        Cell descriptionCell = new Cell();
        addLegendDescription(element, legend.getDefinition(), descriptionCell);

        table.addCell(symbolCell);
        table.addCell(descriptionCell);
    }
    doc.add(table);
}

From source file:org.bambrikii.photobank.web.documents.paymentcertificates.impl.PaymentCertificateBuilderRU.java

public void build(OutputStream outputStream) throws DocumentGenerationException {
    Document doc = new Document(PageSize.A4);
    PdfWriter writer;/*from  w w w .  j  ava2 s. c  o m*/
    BaseFont baseFont = null;
    try {
        writer = PdfWriter.getInstance(doc, outputStream);

        writer.setEncryption(null, "qweasdzxc".getBytes(), PdfWriter.ALLOW_PRINTING,
                PdfWriter.ENCRYPTION_AES_128);

        doc.open();

        String baseFontPath = getResourcesPath() + "org/bambrikii/photobank/web/documents/ARIAL.TTF";
        final String stampImagePath = getResourcesPath()
                + "org/bambrikii/photobank/web/documents/paymentcertificates/PersonaStarsStamp.png";
        baseFont = BaseFont.createFont(baseFontPath, "Cp1251", true);

        Font baseTextStyle = new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.NORMAL,
                new Color(0, 0, 0));
        Font baseBoldTextStyle = new com.lowagie.text.Font(baseFont, 10, com.lowagie.text.Font.BOLD,
                new Color(0, 0, 0));

        Calendar cal = Calendar.getInstance(getLocale());
        cal.setTime(getData().getDate());

        // Act number
        String actNumber = MessageFormat.format(
                "\u0410\u043a\u0442 \u2116 {0} \u043e\u0442 \u00ab{1}\u00bb {2} {3} \u0433\u043e\u0434\u0430",
                String.valueOf(getData().getNumber()), cal.get(Calendar.DAY_OF_MONTH),
                monthsGenitiveCase.get(cal.get(Calendar.MONTH)).toLowerCase(),
                String.valueOf(cal.get(Calendar.YEAR)));
        Paragraph actNumberParagraph = new Paragraph(actNumber,
                new com.lowagie.text.Font(baseFont, 12, com.lowagie.text.Font.BOLD, new Color(0, 0, 0)));
        actNumberParagraph.setSpacingAfter(19);

        Paragraph cityParagraph = new Paragraph("\u0433. \u041c\u043e\u0441\u043a\u0432\u0430", baseTextStyle);
        cityParagraph.setSpacingAfter(15);

        // Licensor
        Paragraph licensorParagraph = new Paragraph();
        licensorParagraph
                .add(new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440: ", baseBoldTextStyle));
        licensorParagraph.add(new Chunk(MessageFormat.format("{0}",
                "\u0418\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c \u041b\u0438\u043f\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0415\u0432\u0433\u0435\u043d\u0438\u0439 \u0410\u0440\u043a\u0430\u0434\u044c\u0435\u0432\u0438\u0447, \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u041e\u0413\u0420\u041d \u2116 305501025600011 \u043e\u0442 13.09.2005\u0433."),
                baseTextStyle));
        licensorParagraph.setSpacingAfter(15);

        // Licensee
        Paragraph licenseeParagraph = new Paragraph();
        licenseeParagraph
                .add(new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442: ", baseBoldTextStyle));
        licenseeParagraph.add(new Chunk(getData().getLicensee(), baseTextStyle));
        licenseeParagraph.setSpacingAfter(15);

        // Pre text
        Paragraph pretextParagraph = new Paragraph();
        pretextParagraph.add(new Chunk(
                "\u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0414\u043e\u0433\u043e\u0432\u043e\u0440\u043e\u043c \u041e\u0444\u0435\u0440\u0442\u044b \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u043a\u043e\u043f\u0438\u0438) \u0438 \u043d\u0435\u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (\u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f): ",
                baseTextStyle));
        pretextParagraph.setSpacingAfter(15);

        int defaultLeading = 9;
        // Files table
        Table filesTbl = new Table(5);
        filesTbl.setWidths(new int[] { 5, 35, 35, 10, 15 });
        filesTbl.setBorder(Table.RECTANGLE);
        filesTbl.setBorderWidth(1);
        filesTbl.setSpacing(0);
        filesTbl.setPadding(2);
        filesTbl.setCellsFitPage(false);
        filesTbl.setUseVariableBorders(true);
        filesTbl.setAlignment(Element.ALIGN_LEFT);
        filesTbl.setWidth(100);

        Cell cellheader1 = new Cell(new Phrase(new Chunk("\u2116", baseBoldTextStyle)));
        cellheader1.setHeader(true);
        cellheader1.setLeading(defaultLeading);
        cellheader1.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader1);

        Cell cellheader2 = new Cell(new Phrase(
                new Chunk("\u041d\u043e\u043c\u0435\u0440 \u0444\u043e\u0442\u043e", baseBoldTextStyle)));
        cellheader2.setHeader(true);
        cellheader2.setLeading(defaultLeading);
        cellheader2.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader2);

        Cell cellheader3 = new Cell(
                new Phrase(new Chunk("\u041f\u0435\u0440\u0441\u043e\u043d\u0430", baseBoldTextStyle)));
        cellheader3.setHeader(true);
        cellheader3.setLeading(defaultLeading);
        cellheader3.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader3);

        Cell cellheader4 = new Cell(
                new Phrase(new Chunk("\u0420\u0430\u0437\u043c\u0435\u0440", baseBoldTextStyle)));
        cellheader4.setHeader(true);
        cellheader4.setLeading(defaultLeading);
        cellheader4.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader4);

        Cell cellheader5 = new Cell(
                new Phrase(new Chunk("\u0426\u0435\u043d\u0430 \u0440\u0443\u0431.", baseBoldTextStyle)));
        cellheader5.setHeader(true);
        cellheader5.setLeading(defaultLeading);
        cellheader5.setHorizontalAlignment(Cell.ALIGN_CENTER);
        filesTbl.addCell(cellheader5);
        filesTbl.endHeaders();

        Integer i = 0;
        for (PaymentCertificateDataItem item : getData().getItems()) {
            i++;
            Cell cell1 = new Cell(new Phrase(new Chunk(Integer.toString(i), baseTextStyle)));
            cell1.setLeading(defaultLeading);
            cell1.setHorizontalAlignment(Cell.ALIGN_CENTER);
            cell1.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell1);

            Cell cell2 = new Cell(new Phrase(new Chunk(item.getFilename(), baseTextStyle)));
            cell2.setLeading(defaultLeading);
            cell2.setHorizontalAlignment(Cell.ALIGN_LEFT);
            cell2.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell2);

            Cell cell3 = new Cell(new Phrase(new Chunk(item.getName(), baseTextStyle)));
            cell3.setLeading(defaultLeading);
            cell3.setHorizontalAlignment(Cell.ALIGN_LEFT);
            cell3.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell3);

            Cell cell4 = new Cell(new Phrase(new Chunk(item.getSizeName(), baseTextStyle)));
            cell4.setLeading(defaultLeading);
            cell4.setHorizontalAlignment(Cell.ALIGN_CENTER);
            cell4.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell4);

            Cell cell5 = new Cell(new Phrase(new Chunk(Double.toString(item.getPrice()), baseTextStyle)));
            cell5.setLeading(defaultLeading);
            cell5.setHorizontalAlignment(Cell.ALIGN_CENTER);
            cell5.setBorder(Cell.NO_BORDER);
            filesTbl.addCell(cell5);
        }
        filesTbl.complete();

        // filesTbl.normalize();

        String totalPrice = MessageFormat.format("{0} {1}", String.valueOf(getData().getTotal()),
                getData().getCurrency());

        Paragraph totalParagraph = new Paragraph();
        totalParagraph.setAlignment(Paragraph.ALIGN_RIGHT);

        totalParagraph.add(new Chunk("\u0418\u0442\u043e\u0433\u043e: ", baseTextStyle));
        totalParagraph.add(new Chunk(totalPrice, baseBoldTextStyle));
        totalParagraph.setSpacingAfter(25);

        Paragraph posttext1Paragraph = new Paragraph();
        posttext1Paragraph.add(new Chunk(
                "\u0412\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442: ",
                baseTextStyle));
        posttext1Paragraph.add(new Chunk(totalPrice, baseBoldTextStyle));
        // posttext1Paragraph.setSpacingAfter(15);

        Paragraph posttext2Paragraph = new Paragraph(
                "\u041d\u0414\u0421 \u043d\u0435 \u043e\u0431\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0443\u043d\u043a\u0442\u0430\u043c\u0438 2, 3 \u0438 5 \u0441\u0442\u0430\u0442\u044c\u0438 346.11 \u041d\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0435\u043a\u0441\u0430 \u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0439 \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u0438.",
                baseTextStyle);
        posttext2Paragraph.setSpacingAfter(15);

        Paragraph posttext3Paragraph = new Paragraph(
                "\u041f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u043e\u043a\u043e\u043c \u043d\u0430 1 (\u043e\u0434\u0438\u043d) \u0433\u043e\u0434 \u0441 \u0434\u0430\u0442\u044b \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u0410\u043a\u0442\u0435.",
                baseTextStyle);
        posttext3Paragraph.setSpacingAfter(15);

        Paragraph posttext4Paragraph = new Paragraph();
        posttext4Paragraph.add(new Chunk(
                "\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442 \u043d\u0435 \u0432\u043f\u0440\u0430\u0432\u0435 ",
                baseTextStyle));
        posttext4Paragraph.add(new Chunk("(\u0437\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u0442\u0441\u044f)",
                baseBoldTextStyle));
        posttext4Paragraph.add(new Chunk(
                ": \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438; \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u0442\u044c, \u0441\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u043a\u0430\u0442, \u0430\u0440\u0435\u043d\u0434\u0443, \u043b\u0438\u0437\u0438\u043d\u0433, \u043a\u0430\u043a \u0441\u0430\u043c\u0438 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u0438 \u0444\u0430\u0439\u043b\u044b \u0441 \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435\u0439, \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0445 \u043a\u0430\u0440\u0442\u043e\u0447\u0435\u043a \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043a, \u043f\u043e\u0441\u0442\u0435\u0440\u043e\u0432 \u0438 \u043e\u0431\u0440\u0430\u043c\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0439 \u0432 \u0446\u0435\u043b\u044f\u0445 \u043f\u0440\u043e\u0434\u0430\u0436\u0438; \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u0444\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0442\u044c \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0442\u0440\u0435\u0442\u044c\u0438\u043c\u0438 \u043b\u0438\u0446\u0430\u043c\u0438, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438.",
                baseTextStyle));
        posttext4Paragraph.setSpacingAfter(15);

        Paragraph posttext5Paragraph = new Paragraph(
                "\u0421\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e\u0442, \u0447\u0442\u043e \u0443\u0441\u043b\u0443\u0433\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043f\u0440\u0430\u0432 \u043d\u0430 \u0424\u043e\u0442\u043e\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043c\u0435. \u0421\u0442\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u0435\u0442\u0435\u043d\u0437\u0438\u0439 \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442.",
                baseTextStyle);
        posttext5Paragraph.setSpacingAfter(15);

        // Signatures
        Table signaturesTable = new Table(4);
        signaturesTable.setWidths(new int[] { 10, 40, 10, 40 });
        signaturesTable.setWidth(100);
        signaturesTable.setSpacing(0);
        signaturesTable.setPadding(5);
        signaturesTable.setBorder(Table.NO_BORDER);

        Cell licensorSignature1Cell = new Cell(new Phrase(
                new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0440:", baseBoldTextStyle)));
        licensorSignature1Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licensorSignature1Cell.setBorder(Cell.NO_BORDER);

        Cell licensorSignature2Cell = new Cell(new Phrase(new Chunk(
                "______________/ \u041b\u0438\u043f\u0430\u0442\u043d\u0438\u043a\u043e\u0432 \u0415.\u0410. /",
                baseTextStyle)));
        licensorSignature2Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licensorSignature2Cell.setBorder(Cell.NO_BORDER);
        licensorSignature2Cell.addElement(new Paragraph("\n\n\n\n"));
        licensorSignature2Cell.add(
                // Stamp
                Image.getInstance(stampImagePath));

        Cell licenseeSignature1Cell = new Cell(new Phrase(
                new Chunk("\u041b\u0438\u0446\u0435\u043d\u0437\u0438\u0430\u0442:", baseBoldTextStyle)));
        licenseeSignature1Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licenseeSignature1Cell.setBorder(Cell.NO_BORDER);

        Cell licenseeSignature2Cell = new Cell(new Phrase(new Chunk(
                MessageFormat.format("______________/ {0} /", getData().getLicensee()), baseTextStyle)));
        licenseeSignature2Cell.setHorizontalAlignment(Cell.ALIGN_LEFT);
        licenseeSignature2Cell.setBorder(Cell.NO_BORDER);

        signaturesTable.addCell(new Cell() {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licensorSignature1Cell);
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licenseeSignature1Cell);
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licensorSignature2Cell);
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(licenseeSignature2Cell);

        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });
        signaturesTable.addCell(new Cell(true) {
            {
                setBorder(Cell.NO_BORDER);
            }
        });

        signaturesTable.complete();
        // PdfPTable signaturePdPfTable = signaturesTable.createPdfPTable();

        // Document items
        doc.add(actNumberParagraph);
        doc.add(cityParagraph);
        doc.add(licensorParagraph);
        doc.add(licenseeParagraph);
        doc.add(pretextParagraph);
        doc.add(filesTbl);
        doc.add(totalParagraph);
        doc.add(posttext1Paragraph);
        doc.add(posttext2Paragraph);
        doc.add(posttext3Paragraph);
        doc.add(posttext4Paragraph);
        doc.add(posttext5Paragraph);
        doc.add(signaturesTable);

        doc.close();
    } catch (DocumentException ex) {
        throw new DocumentGenerationException("Exception creating document.", ex);
    } catch (IOException ex) {
        throw new DocumentGenerationException(
                "Exception creating document, required font file may not be found.", ex);
    }
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

private static Table newTable() throws BadElementException {
    Table table = new Table(1);

    table.setBorderWidthTop(1);//from   w w w.  ja  va 2s  .com
    table.setBorderWidthLeft(1);
    table.setBorderWidthRight(1);
    table.setBorderWidthBottom(0);
    table.setWidth(100);
    table.setPadding(3);
    table.setAlignment(Table.ALIGN_LEFT);

    return table;
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private Table create2columnTable() throws BadElementException {
    // Print the metadata information
    Table table = new Table(2);
    table.setBorderColor(Color.GRAY);
    table.setPadding(2);
    table.setSpacing(2);//from   www  .j a v  a2  s  . c  om
    table.setBorderWidth(1);
    table.setTableFitsPage(true);

    return table;
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method adds the log lines into the report
 * //from   ww  w  .  j a  va 2 s  . c  o m
 * @param reportLog
 */
private void generateReportLogBody(List<String[]> reportLog) {
    try {
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);
        int columnwidths[];
        columnwidths = new int[] { 40, 15 };

        Table aTable = new Table(2, linesPerPage);
        int rowsWritten = 0;
        for (String[] columns : reportLog) {
            if (pageNumber == 0 || line >= linesPerPage) {
                if (pageNumber > 0) {
                    this.document.add(aTable);
                }
                int elementsLeft = reportLog.size() - rowsWritten;
                int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft);
                this.document.newPage();

                this.generateColumnHeaders();

                aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows.

                aTable.setAutoFillEmptyCells(true);
                aTable.setPadding(3);
                aTable.setWidths(columnwidths);
                aTable.setWidth(100);
                aTable.setBorder(Rectangle.NO_BORDER);

                line = 0;
                pageNumber++;
            }
            rowsWritten++;

            Cell cell;
            cell = new Cell(new Phrase(columns[0], font));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);

            cell = new Cell(new Phrase(columns[1], font));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);
            line++;
        }
        this.document.add(aTable);
    } catch (DocumentException de) {
        throw new RuntimeException(
                "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: "
                        + de.getMessage());
    }
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method creates a report group for the error message on the report
 * /* w  w w. j  a va 2 s .  c  o  m*/
 * @throws DocumentException
 */
private void generateErrorColumnHeaders() throws DocumentException {
    try {
        int headerwidths[] = { 60 };

        Table aTable = new Table(1, 1); // 2 columns, 1 rows.

        aTable.setAutoFillEmptyCells(true);
        aTable.setPadding(3);
        aTable.setWidths(headerwidths);
        aTable.setWidth(100);

        Cell cell;

        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);

        cell = new Cell(new Phrase("Error(s)", font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);

        this.document.add(aTable);

    } catch (Exception e) {
        throw new RuntimeException(
                "DepreciationReport.generateErrorColumnHeaders() - Error: " + e.getMessage());
    }
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method creates the headers for the report statistics
 *///from ww w  .  j a  v  a  2 s . co  m
private void generateColumnHeaders() {
    try {
        int headerwidths[] = { 40, 15 };

        Table aTable = new Table(2, 1); // 2 columns, 1 rows.

        aTable.setAutoFillEmptyCells(true);
        aTable.setPadding(3);
        aTable.setWidths(headerwidths);
        aTable.setWidth(100);

        Cell cell;

        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);

        cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
                CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING1), font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);

        cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(
                CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING2), font));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setGrayFill(0.9f);
        aTable.addCell(cell);
        this.document.add(aTable);

    } catch (Exception e) {
        throw new RuntimeException("DepreciationReport.generateColumnHeaders() - Error: " + e.getMessage());
    }
}