Example usage for com.itextpdf.text Element ALIGN_CENTER

List of usage examples for com.itextpdf.text Element ALIGN_CENTER

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_CENTER.

Prototype

int ALIGN_CENTER

To view the source code for com.itextpdf.text Element ALIGN_CENTER.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) {

    if (text == null) {
        text = "";
    }//from w ww .  j  a  v  a2 s .c o m

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
    // set the cell alignment
    // in case there is no text and you wan to create an empty row
    if (text.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(colSpan);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    cell.setBorderWidth(2);
    cell.setPadding(3f);

    // add the call to the table
    table.addCell(cell);
}

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private Paragraph createHeader() {
    Paragraph anexo = new Paragraph("ANEXO VI" + SEPARATOR + "COMUNICADO DE ALTERAO CADASTRAL",
            FONT_BIG_HEADER_BOLD);/*from   w w  w .j av  a2 s  .c o  m*/
    anexo.setAlignment(Element.ALIGN_CENTER);

    Paragraph law = new Paragraph("( Lei n 10.357, de 27 de dezembro de 2001)" + SEPARATOR_DOUBLE,
            FONT_BIG_HEADER);
    law.setAlignment(Element.ALIGN_CENTER);

    Paragraph full = new Paragraph();
    full.add(anexo);
    full.add(law);

    return full;
}

From source file:com.systemevent.jsfclass.util.PdfEvento.java

public void imprimirPdf(Evento events) {
    Evento event = events;//from  ww  w .j  a  v a2  s  . c  o m

    //buscarPDF(n);
    try {
        //Generamos el archivo PDF
        String directorioArchivos;
        ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
                .getContext();
        directorioArchivos = ctx.getRealPath("\'") + "reports";
        String name = directorioArchivos + "\'document-report.pdf";
        //String name="C:\\Users\\Jose_Gascon\\Documents\\NetBeansProjects\\SystemEvent\\target\\SystemEvent-1.0-SNAPSHOT\\reports\\document-report.pdf";
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(name));
        FormatoPDF encabezado = new FormatoPDF("");
        Paragraph parrafo, datos, datos1;
        int i;

        // indicamos que objecto manejara los eventos al escribir el Pdf
        writer.setPageEvent(encabezado);

        document.open();
        document.addAuthor("Erick Ramirez");
        document.addTitle("Reporte");

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

        //for (i = 0; i < 4; i++) {
        parrafo = new Paragraph("Presupuesto de Evento");
        parrafo.setAlignment(Element.ALIGN_CENTER);

        document.add(parrafo);
        //  document.newPage();
        //}

        datos = new Paragraph("Ubicacion: " + event.getUbicacion());
        datos1 = new Paragraph("Pais: " + event.getCodigoPais().getNombre());
        datos.setAlignment(Element.ALIGN_RIGHT);
        datos1.setAlignment(Element.ALIGN_RIGHT);
        document.add(datos1);
        document.add(datos);
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        //              PdfPTable table = new PdfPTable(2);
        //              
        //              table.addCell("Cliente: ");
        //              table.addCell(event.getIdCliente().getNombre());
        //              
        //              table.addCell("Descripcion del Evento: ");
        //              table.addCell(event.getDescripcion());
        //              
        //              document.add(table);

        document.add(Tabla_compleja());

        document.close();
        //----------------------------
        //Abrimos el archivo PDF
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "inline=filename=" + name);
        try {
            response.getOutputStream().write(Util.getBytesFromFile(new File(name)));
            response.getOutputStream().flush();
            response.getOutputStream().close();
            context.responseComplete();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.systemevent.jsfclass.util.PdfEvento.java

public PdfPTable Tabla_compleja() {
    //creamos una tabla con 3 columnas
    PdfPTable mitablacompleja = new PdfPTable(3);
    //aadimos texto con formato a la primera celda
    PdfPCell celda = new PdfPCell(new Paragraph("Historial de Observaciones", FontFactory.getFont("arial", // fuente
            22, // tamao
            Font.BOLD, // estilo
            BaseColor.RED))); // color
    //unimos esta celda con otras 2
    celda.setColspan(3);/*from   ww  w  .  ja  va  2  s . c o  m*/
    //alineamos el contenido al centro
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    // aadimos un espaciado
    celda.setPadding(12.0f);
    //colocamos un color de fondo
    celda.setBackgroundColor(BaseColor.GRAY);
    //se aade a la tabla
    mitablacompleja.addCell(celda);

    //fila 2
    celda = new PdfPCell(new Paragraph("AUDITORIA DE SISTEMAS"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.GREEN);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Aprobado"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 3        
    celda = new PdfPCell(new Paragraph("COMPILADORES"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.YELLOW);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Reprobado"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 4        
    celda = new PdfPCell(new Paragraph("Prog. Bajo Nivel"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.CYAN);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Eximido"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 5
    mitablacompleja.addCell("Conclusion");
    celda = new PdfPCell(new Paragraph("GET A LIFE!!!"));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.ORANGE);
    mitablacompleja.addCell(celda);
    // se retorna la tabla

    return mitablacompleja;
}

From source file:com.thelinh.gui.PreviewExam.java

private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
    if (this.txtExamCode.getText().equals("")) {
        JOptionPane.showMessageDialog(this, "Hy nhp m ?");
    } else {// w  ww .  j  ava2 s.co  m
        JFileChooser fc = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("PDF files (*.pdf)", "pdf");
        fc.setFileFilter(filter);
        int rt = fc.showSaveDialog(this);
        if (rt == JFileChooser.APPROVE_OPTION) {
            String filepath = fc.getSelectedFile().getPath();
            if (filepath.indexOf(".") == -1) {
                filepath = filepath + ".pdf";
            }
            String dafilepath = (new StringBuffer(filepath)).insert(filepath.length() - 4, ".da").toString();
            try {
                Document document = new Document();
                PdfWriter.getInstance(document, new FileOutputStream(filepath));
                document.open();

                // Add title
                Paragraph p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25);
                p.setAlignment(Element.ALIGN_CENTER);
                p.setSpacingAfter(5);
                document.add(p);

                p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25);
                p.setAlignment(Element.ALIGN_CENTER);
                p.setSpacingAfter(25);
                document.add(p);

                p = new Paragraph(
                        "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName()
                                + ", Ngy ra ?: "
                                + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())),
                        times_15);
                p.setAlignment(Element.ALIGN_LEFT);
                p.setSpacingAfter(5);
                document.add(p);

                p = new Paragraph("M ?: " + this.txtExamCode.getText() + "    Th?i gian lm bi: "
                        + spTime.getValue().toString() + " pht", timesBold_15);
                p.setSpacingAfter(25);
                document.add(p);

                for (int i = 0; i < this.questionList.size(); i++) {
                    Question question = this.questionList.get(i);
                    ArrayList<Answer> answerList = AnswerSql
                            .getAnswersByQuestionId(question.getQuestionId().trim());
                    Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15);
                    Phrase questionContent = new Phrase(question.getQuestion(), times_15);

                    Paragraph questionTitle = new Paragraph();
                    questionTitle.add(questionNumber);
                    questionTitle.add(questionContent);

                    document.add(questionTitle);
                    PdfPTable table = new PdfPTable(2);

                    for (int j = 0; j < answerList.size(); j++) {
                        Answer ans = answerList.get(j);
                        Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15);
                        Phrase answerContent = new Phrase(ans.getAnswer(), times_15);
                        Phrase elem = new Phrase();
                        elem.add(cap);
                        elem.add(answerContent);
                        PdfPCell cell = new PdfPCell();

                        cell.setBorder(Rectangle.NO_BORDER);
                        cell.setPhrase(elem);
                        cell.setFixedHeight(25);
                        table.addCell(cell);
                    }
                    document.add(table);
                }
                document.close();
                //                    if (Desktop.isDesktopSupported()) {
                //                        try {
                //                            File myFile = new File(filepath);
                //                            Desktop.getDesktop().open(myFile);
                //                        } catch (IOException ex) {
                //                            // no application registered for PDFs
                //                            System.out.println(ex.toString());
                //                        }
                //                    }

                document = new Document();
                PdfWriter.getInstance(document, new FileOutputStream(dafilepath));
                document.open();

                // Add title
                p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25);
                p.setAlignment(Element.ALIGN_CENTER);
                p.setSpacingAfter(5);
                document.add(p);

                p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25);
                p.setAlignment(Element.ALIGN_CENTER);
                p.setSpacingAfter(25);
                document.add(p);

                p = new Paragraph(
                        "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName()
                                + ", Ngy ra ?: "
                                + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())),
                        times_15);
                p.setAlignment(Element.ALIGN_LEFT);
                p.setSpacingAfter(5);
                document.add(p);

                p = new Paragraph("M ?: " + this.txtExamCode.getText() + "    Th?i gian lm bi: "
                        + spTime.getValue().toString() + " pht", timesBold_15);
                p.setSpacingAfter(25);
                document.add(p);

                for (int i = 0; i < this.questionList.size(); i++) {
                    Question question = this.questionList.get(i);
                    ArrayList<Answer> answerList = AnswerSql
                            .getAnswersByQuestionId(question.getQuestionId().trim());
                    Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15);
                    Phrase questionContent = new Phrase(question.getQuestion(), times_15);

                    Paragraph questionTitle = new Paragraph();
                    questionTitle.add(questionNumber);
                    questionTitle.add(questionContent);

                    document.add(questionTitle);
                    PdfPTable table = new PdfPTable(2);

                    for (int j = 0; j < answerList.size(); j++) {
                        Answer ans = answerList.get(j);
                        Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15);
                        Phrase answerContent = null;
                        if (ans.getYesNo()) {
                            answerContent = new Phrase(ans.getAnswer(), timesBold_15);
                        } else {
                            answerContent = new Phrase(ans.getAnswer(), times_15);
                        }
                        Phrase elem = new Phrase();
                        elem.add(cap);
                        elem.add(answerContent);
                        PdfPCell cell = new PdfPCell();

                        cell.setBorder(Rectangle.NO_BORDER);
                        cell.setPhrase(elem);
                        cell.setFixedHeight(25);
                        table.addCell(cell);
                    }
                    document.add(table);
                }
                document.close();

            } catch (FileNotFoundException | DocumentException ex) {
                Logger.getLogger(PreviewExam.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}

From source file:com.thomasmore.service.PdfCreateServiceImpl.java

public void readPdf() {
    try {//  ww w  .  j ava  2 s .  c  o m
        OutputStream file = new FileOutputStream(new File("D:\\SamplePDFje.pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        document.add(new Paragraph("First iText PDF"));
        document.add(new Paragraph(new Date().toString()));

        document.addAuthor("Krishna Sfsfsfsn");
        document.addCreationDate();
        document.addCreator("JavaBeat");
        document.addTitle("Sample PDF");

        //Create Paragraph
        Paragraph paragraph = new Paragraph("Title 1", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));

        //New line
        paragraph.add(new Paragraph(" "));
        paragraph.add("Test Paragraph");
        paragraph.add(new Paragraph(" "));
        document.add(paragraph);

        //Create a table in PDF
        PdfPTable pdfTable = new PdfPTable(3);
        PdfPCell cell1 = new PdfPCell(new Phrase("Table Header 1"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 2"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);

        cell1 = new PdfPCell(new Phrase("Table Header 3"));
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        pdfTable.addCell(cell1);
        pdfTable.setHeaderRows(1);

        pdfTable.addCell("Row 1 Col 1");
        pdfTable.addCell("Row 1 Col 2");
        pdfTable.addCell("Row 1 Col 3");

        pdfTable.addCell("Row 2 Col 1");
        pdfTable.addCell("Row 2 Col 2");
        pdfTable.addCell("Row 2 Col 3");

        document.add(pdfTable);

        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:com.tomasz.drag.triballocommanderro.controller.MakerPDF.java

public static void printToPDFBoss(ArrayList<Person> workers, EventGig event)
        throws IOException, DocumentException {
    String filename = event.getName() + " Boss" + ".pdf";
    String path = event.getData() + " " + event.getName() + "//";
    //Rectangle rect = new Rectangle(0, 595, 8, 0);
    Document document = new Document(PageSize.A4.rotate(), 0, 0, 0, 0);
    //Document document = new Document(rect);
    //document.setMargins(0, 0, 0, 0);
    BaseFont bf;/*from ww  w  . ja va 2  s  . c om*/
    //BaseFont bf2;
    // bf = BaseFont.createFont("arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    bf = BaseFont.createFont("src\\main\\resources\\font\\arialuni.ttf", BaseFont.IDENTITY_H,
            BaseFont.EMBEDDED);
    //bf2 = BaseFont.createFont("src\\main\\resources\\font\\arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    com.itextpdf.text.Font ft = new com.itextpdf.text.Font(bf, 9);
    //com.itextpdf.text.Font ft2 = new com.itextpdf.text.Font(bf2,9);

    PdfWriter.getInstance(document, new FileOutputStream(path + filename));

    document.open();
    Paragraph p = new Paragraph(event.getName() + " " + event.getData(), ft);
    p.setAlignment(Element.ALIGN_CENTER);
    document.add(p);
    document.add(new Paragraph(" "));
    PdfPTable table = new PdfPTable(workers.size() + 1);
    table.setWidthPercentage(98);
    PdfPCell cell = new PdfPCell(new Phrase("    "));
    table.addCell(cell);
    for (Person tempPerson : workers) {
        cell = new PdfPCell(new Paragraph(tempPerson.getName(), ft));
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        table.addCell(cell);

    }
    if (event.isZaladunekScenaDach()) {
        cell = new PdfPCell(new Paragraph("Za. Sc./Dach", ft));
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getZaladunekScenaDachWyplata() > 0) {
                cell = new PdfPCell(
                        new Paragraph(String.format("%.2f", tempPerson.getZaladunekScenaDachWyplata()), ft));
                cell.setVerticalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }
    if (event.isZaladunekTechniki()) {
        cell = new PdfPCell(new Phrase("Za. Tech.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getZaladunekTechnikiWyplata() > 0) {
                cell = new PdfPCell(
                        new Paragraph(String.format("%.2f", tempPerson.getZaladunekTechnikiWyplata()), ft));
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isRozladunekScenaDach()) {
        cell = new PdfPCell(new Phrase("Roz Sc/Dach", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getRozladunekScenaDachWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getRozladunekScenaDachWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }
    if (event.isRozladunekTechniki()) {
        cell = new PdfPCell(new Phrase("Roz. Tech.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getRozladunekTechnikiWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getRozladunekTechnikiWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isMontazDachu()) {
        cell = new PdfPCell(new Phrase("Mon. Dach", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getMontazDachuWyplata() > 0) {
                cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getMontazDachuWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isMontazDzwieku()) {
        cell = new PdfPCell(new Phrase("Mon. Dw.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getMontazDzwiekuWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getMontazDzwiekuWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isMontazSceny()) {
        cell = new PdfPCell(new Phrase("Mon. Sc.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getMontazScenyWyplata() > 0) {
                cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getMontazScenyWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isMontazSwiatla()) {
        cell = new PdfPCell(new Phrase("Mon. w.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getMontazSwiatlaWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getMontazSwiatlaWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isMontazTechniki()) {
        cell = new PdfPCell(new Phrase("Mon. Tech.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getMontazTechnikiWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getMontazTechnikiWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isDemontazDachu()) {
        cell = new PdfPCell(new Phrase("Dem. Dach", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getDemontazDachuWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getDemontazDachuWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isDemontazDzwieku()) {
        cell = new PdfPCell(new Phrase("Dem. Dw.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getDemontazDzwiekuWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getDemontazDzwiekuWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isDemontazSceny()) {
        cell = new PdfPCell(new Phrase("Dem. Sc.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getDemontazScenyWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getDemontazScenyWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isDemontazSwiatla()) {
        cell = new PdfPCell(new Phrase("Dem. w.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getDemontazSwiatlaWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getDemontazSwiatlaWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase("   "));
                table.addCell(cell);
            }
        }
    }

    if (event.isDemontazTechniki()) {
        cell = new PdfPCell(new Phrase("Dem. Tech.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getDemontazTechnikiWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getDemontazTechnikiWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isDyzur()) {
        cell = new PdfPCell(new Phrase("Dyur", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getDyzurWyplata() > 0) {
                cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getDyzurWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(""));
                table.addCell(cell);
            }
        }
    }

    if (event.isTechnikSceny()) {
        cell = new PdfPCell(new Phrase("Technik Sc.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getTechnikScenyWyplata() > 0) {
                cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getTechnikScenyWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isRealizacjaFOH()) {
        cell = new PdfPCell(new Phrase("Real. FOH", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getRealizacjaFOHWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getRealizacjaFOHWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isRealizacjaMON()) {
        cell = new PdfPCell(new Phrase("Real. MON", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getRealizacjaMONWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getRealizacjaMONWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (event.isRealizacjaSwiatla()) {
        cell = new PdfPCell(new Phrase("Real. w.", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getRealizacjaSwiatlaWyplata() > 0) {
                cell = new PdfPCell(
                        new Phrase(String.format("%.2f", tempPerson.getRealizacjaSwiatlaWyplata()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    if (true) {
        cell = new PdfPCell(new Phrase("Premia", ft));
        table.addCell(cell);
        for (Person tempPerson : workers) {
            if (tempPerson.getPremia() > 0) {
                cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getPremia()), ft));
                table.addCell(cell);
            } else {
                cell = new PdfPCell(new Phrase(" "));
                table.addCell(cell);
            }
        }
    }

    Paragraph ph = new Paragraph("Razem", ft);

    //cell = new PdfPCell(new Phrase(ph));
    cell.addElement(ph);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);
    for (Person tempPerson : workers) {
        if (tempPerson.getSumaWyplata() >= 0) {
            cell = new PdfPCell(new Phrase(String.format("%.2f", tempPerson.getSumaWyplata()) + " z", ft));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
        } else {
            cell = new PdfPCell(new Phrase(" "));
            table.addCell(cell);
        }
    }
    //        for (Object obj : table.getChunks()) {
    //            if (obj instanceof PdfPCell) {
    //                System.out.println("jest PdfCell");
    //                PdfPCell tempCell = (PdfPCell) obj;
    //                tempCell.setVerticalAlignment(Element.ALIGN_CENTER);
    //                //tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    //            }
    //            
    //        }
    table.setHorizontalAlignment(Element.ALIGN_CENTER);
    document.add(table);
    document.close();

}

From source file:com.wabacus.system.component.application.report.abstractreport.AbsListReportType.java

License:Open Source License

protected void showDataHeaderOnPdf() {
    SqlBean sbean = rbean.getSbean();//from   w w w  .java 2  s  .  co  m
    if (sbean.isHorizontalDataset()
            && this.cacheDataBean.getColDisplayModeAfterAuthorize(sbean.getHdsTitleLabelCbean(), false) <= 0) {
        return;
    }
    if (sbean.isHorizontalDataset() && isShouldDisplayHdsLabelCol()) {
        addDataHeaderCell(sbean.getHdsTitleLabelCbean(), sbean.getHdsTitleLabelCbean().getLabel(rrequest), 1, 1,
                getPdfCellAlign(sbean.getHdsTitleLabelCbean().getLabelalign(), Element.ALIGN_CENTER));
    }
    List<ColBean> lstColBeans = this.getLstDisplayColBeans();
    ColDisplayData colDisplayData;
    String labelTmp;
    for (ColBean cbean : lstColBeans) {
        if (cacheDataBean.getColDisplayModeAfterAuthorize(cbean, false) <= 0)
            continue;
        labelTmp = cbean.getLabel(rrequest);
        colDisplayData = ColDisplayData.getColDataFromInterceptor(this, cbean, null, -1, null, labelTmp);
        addDataHeaderCell(cbean, colDisplayData.getValue(), 1, 1,
                getPdfCellAlign(cbean.getLabelalign(), Element.ALIGN_CENTER));
    }
}

From source file:com.wabacus.system.component.application.report.abstractreport.AbsReportType.java

License:Open Source License

protected void showTitleOnPdf() throws Exception {
    PdfPTable tableTitle = new PdfPTable(1);
    tableTitle.setTotalWidth(pdfwidth);/* ww w  . j  av  a 2 s .  com*/
    tableTitle.setLockedWidth(true);//
    int titlefontsize = 0;
    if (this.pdfbean != null)
        titlefontsize = this.pdfbean.getTitlefontsize();
    if (titlefontsize <= 0)
        titlefontsize = 10;
    Font headFont = new Font(PdfAssistant.getInstance().getBfChinese(), titlefontsize, Font.BOLD);
    PdfPCell cell = new PdfPCell(
            new Paragraph(rbean.getTitle(rrequest) + "  " + rbean.getSubtitle(rrequest), headFont));
    cell.setColspan(1);
    cell.setBorder(0);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    tableTitle.addCell(cell);
    document.add(tableTitle);
}

From source file:com.wabacus.system.component.application.report.abstractreport.AbsReportType.java

License:Open Source License

protected int getPdfCellAlign(String configalign, int defaultalign) {
    if (configalign == null || configalign.trim().equals(""))
        return defaultalign;
    configalign = configalign == null ? "" : configalign.toLowerCase().trim();
    if (configalign.equals("left"))
        return Element.ALIGN_LEFT;
    if (configalign.equals("center"))
        return Element.ALIGN_CENTER;
    if (configalign.equals("right"))
        return Element.ALIGN_RIGHT;
    return defaultalign;
}