Example usage for com.itextpdf.text Element ALIGN_MIDDLE

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

Introduction

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

Prototype

int ALIGN_MIDDLE

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

Click Source Link

Document

A possible value for vertical alignment.

Usage

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

License:Open Source License

protected void addDataCell(Object configbean, String value, int rowspan, int colspan, int align) {
    if (dataFont == null) {
        int datafontsize = 0;
        if (this.pdfbean != null)
            datafontsize = this.pdfbean.getDatafontsize();
        if (datafontsize <= 0)
            datafontsize = 6;/*from www.  j  ava2s .c o m*/
        dataFont = new Font(PdfAssistant.getInstance().getBfChinese(), datafontsize, Font.NORMAL);
    }
    PdfPCell cell = new PdfPCell(new Paragraph(value, dataFont));
    cell.setColspan(colspan);//??
    cell.setRowspan(rowspan);
    //        }catch(Exception e)
    cell.setHorizontalAlignment(align);//??
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    if (pdfbean != null && pdfbean.getInterceptorObj() != null) {
        pdfbean.getInterceptorObj().displayPerColDataWithoutTemplate(this, configbean, rowspan, value, cell);
    }
    pdfDataTable.addCell(cell);
}

From source file:controller.CCInstance.java

License:Open Source License

public final boolean signPdf(final String pdfPath, final String destination, final CCSignatureSettings settings,
        final SignatureListener sl) throws CertificateException, IOException, DocumentException,
        KeyStoreException, SignatureFailedException, FileNotFoundException, NoSuchAlgorithmException,
        InvalidAlgorithmParameterException {
    PrivateKey pk;/*  w  ww.  ja  va2  s . c o  m*/

    final PdfReader reader = new PdfReader(pdfPath);
    pk = getPrivateKeyFromAlias(settings.getCcAlias().getAlias());

    if (getCertificationLevel(pdfPath) == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) {
        String message = Bundle.getBundle().getString("fileDoesNotAllowChanges");
        if (sl != null) {
            sl.onSignatureComplete(pdfPath, false, message);
        }
        throw new SignatureFailedException(message);
    }

    if (reader.getNumberOfPages() - 1 < settings.getPageNumber()) {
        settings.setPageNumber(reader.getNumberOfPages() - 1);
    }

    if (null == pk) {
        String message = Bundle.getBundle().getString("noSmartcardFound");
        if (sl != null) {
            sl.onSignatureComplete(pdfPath, false, message);
        }
        throw new CertificateException(message);
    }

    if (null == pkcs11ks.getCertificateChain(settings.getCcAlias().getAlias())) {
        String message = Bundle.getBundle().getString("certificateNullChain");
        if (sl != null) {
            sl.onSignatureComplete(pdfPath, false, message);
        }
        throw new CertificateException(message);
    }
    final ArrayList<Certificate> embeddedCertificateChain = settings.getCcAlias().getCertificateChain();
    final Certificate owner = embeddedCertificateChain.get(0);
    final Certificate lastCert = embeddedCertificateChain.get(embeddedCertificateChain.size() - 1);

    if (null == owner) {
        String message = Bundle.getBundle().getString("certificateNameUnknown");
        if (sl != null) {
            sl.onSignatureComplete(pdfPath, false, message);
        }
        throw new CertificateException(message);
    }

    final X509Certificate X509C = ((X509Certificate) lastCert);
    final Calendar now = Calendar.getInstance();
    final Certificate[] filledMissingCertsFromChainInTrustedKeystore = getCompleteTrustedCertificateChain(
            X509C);

    final Certificate[] fullCertificateChain;
    if (filledMissingCertsFromChainInTrustedKeystore.length < 2) {
        fullCertificateChain = new Certificate[embeddedCertificateChain.size()];
        for (int i = 0; i < embeddedCertificateChain.size(); i++) {
            fullCertificateChain[i] = embeddedCertificateChain.get(i);
        }
    } else {
        fullCertificateChain = new Certificate[embeddedCertificateChain.size()
                + filledMissingCertsFromChainInTrustedKeystore.length - 1];
        int i = 0;
        for (i = 0; i < embeddedCertificateChain.size(); i++) {
            fullCertificateChain[i] = embeddedCertificateChain.get(i);
        }
        for (int f = 1; f < filledMissingCertsFromChainInTrustedKeystore.length; f++, i++) {
            fullCertificateChain[i] = filledMissingCertsFromChainInTrustedKeystore[f];
        }
    }

    // Leitor e Stamper
    FileOutputStream os = null;
    try {
        os = new FileOutputStream(destination);
    } catch (FileNotFoundException e) {
        String message = Bundle.getBundle().getString("outputFileError");
        if (sl != null) {
            sl.onSignatureComplete(pdfPath, false, message);
        }
        throw new IOException(message);
    }

    // Aparncia da Assinatura
    final char pdfVersion;
    switch (Settings.getSettings().getPdfVersion()) {
    case "/1.2":
        pdfVersion = PdfWriter.VERSION_1_2;
        break;
    case "/1.3":
        pdfVersion = PdfWriter.VERSION_1_3;
        break;
    case "/1.4":
        pdfVersion = PdfWriter.VERSION_1_4;
        break;
    case "/1.5":
        pdfVersion = PdfWriter.VERSION_1_5;
        break;
    case "/1.6":
        pdfVersion = PdfWriter.VERSION_1_6;
        break;
    case "/1.7":
        pdfVersion = PdfWriter.VERSION_1_7;
        break;
    default:
        pdfVersion = PdfWriter.VERSION_1_7;
    }

    final PdfStamper stamper = (getNumberOfSignatures(pdfPath) == 0
            ? PdfStamper.createSignature(reader, os, pdfVersion)
            : PdfStamper.createSignature(reader, os, pdfVersion, null, true));

    final PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
    appearance.setSignDate(now);
    appearance.setReason(settings.getReason());
    appearance.setLocation(settings.getLocation());
    appearance.setCertificationLevel(settings.getCertificationLevel());
    appearance.setSignatureCreator(SIGNATURE_CREATOR);
    appearance.setCertificate(owner);

    final String fieldName = settings.getPrefix() + " " + (1 + getNumberOfSignatures(pdfPath));
    if (settings.isVisibleSignature()) {
        appearance.setVisibleSignature(settings.getPositionOnDocument(), settings.getPageNumber() + 1,
                fieldName);
        appearance.setRenderingMode(PdfSignatureAppearance.RenderingMode.DESCRIPTION);
        if (null != settings.getAppearance().getImageLocation()) {
            appearance.setImage(Image.getInstance(settings.getAppearance().getImageLocation()));
        }

        com.itextpdf.text.Font font = new com.itextpdf.text.Font(FontFactory
                .getFont(settings.getAppearance().getFontLocation(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0)
                .getBaseFont());

        font.setColor(new BaseColor(settings.getAppearance().getFontColor().getRGB()));
        if (settings.getAppearance().isBold() && settings.getAppearance().isItalic()) {
            font.setStyle(Font.BOLD + Font.ITALIC);
        } else if (settings.getAppearance().isBold()) {
            font.setStyle(Font.BOLD);
        } else if (settings.getAppearance().isItalic()) {
            font.setStyle(Font.ITALIC);
        } else {
            font.setStyle(Font.PLAIN);
        }

        appearance.setLayer2Font(font);
        String text = "";
        if (settings.getAppearance().isShowName()) {
            if (!settings.getCcAlias().getName().isEmpty()) {
                text += settings.getCcAlias().getName() + "\n";
            }
        }
        if (settings.getAppearance().isShowReason()) {
            if (!settings.getReason().isEmpty()) {
                text += settings.getReason() + "\n";
            }
        }
        if (settings.getAppearance().isShowLocation()) {
            if (!settings.getLocation().isEmpty()) {
                text += settings.getLocation() + "\n";
            }
        }
        if (settings.getAppearance().isShowDate()) {
            DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            SimpleDateFormat sdf = new SimpleDateFormat("Z");
            text += df.format(now.getTime()) + " " + sdf.format(now.getTime()) + "\n";
        }
        if (!settings.getText().isEmpty()) {
            text += settings.getText();
        }

        PdfTemplate layer2 = appearance.getLayer(2);
        Rectangle rect = settings.getPositionOnDocument();
        Rectangle sr = new Rectangle(rect.getWidth(), rect.getHeight());
        float size = ColumnText.fitText(font, text, sr, 1024, PdfWriter.RUN_DIRECTION_DEFAULT);
        ColumnText ct = new ColumnText(layer2);
        ct.setRunDirection(PdfWriter.RUN_DIRECTION_DEFAULT);
        ct.setAlignment(Element.ALIGN_MIDDLE);
        int align;
        switch (settings.getAppearance().getAlign()) {
        case 0:
            align = Element.ALIGN_LEFT;
            break;
        case 1:
            align = Element.ALIGN_CENTER;
            break;
        case 2:
            align = Element.ALIGN_RIGHT;
            break;
        default:
            align = Element.ALIGN_LEFT;
        }

        ct.setSimpleColumn(new Phrase(text, font), sr.getLeft(), sr.getBottom(), sr.getRight(), sr.getTop(),
                size, align);
        ct.go();
    } else {
        appearance.setVisibleSignature(new Rectangle(0, 0, 0, 0), 1, fieldName);
    }

    // CRL <- Pesado!
    final ArrayList<CrlClient> crlList = null;

    // OCSP
    OcspClient ocspClient = new OcspClientBouncyCastle();

    // TimeStamp
    TSAClient tsaClient = null;
    if (settings.isTimestamp()) {
        tsaClient = new TSAClientBouncyCastle(settings.getTimestampServer(), null, null);
    }

    final String hashAlg = getHashAlgorithm(X509C.getSigAlgName());

    final ExternalSignature es = new PrivateKeySignature(pk, hashAlg, pkcs11Provider.getName());
    final ExternalDigest digest = new ProviderDigest(pkcs11Provider.getName());

    try {
        MakeSignature.signDetached(appearance, digest, es, fullCertificateChain, crlList, ocspClient, tsaClient,
                0, MakeSignature.CryptoStandard.CMS);
        if (sl != null) {
            sl.onSignatureComplete(pdfPath, true, "");
        }
        return true;
    } catch (Exception e) {
        os.flush();
        os.close();
        new File(destination).delete();
        if ("sun.security.pkcs11.wrapper.PKCS11Exception: CKR_FUNCTION_CANCELED".equals(e.getMessage())) {
            throw new SignatureFailedException(Bundle.getBundle().getString("userCanceled"));
        } else if ("sun.security.pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR".equals(e.getMessage())) {
            throw new SignatureFailedException(Bundle.getBundle().getString("noPermissions"));
        } else if (e instanceof ExceptionConverter) {
            String message = Bundle.getBundle().getString("timestampFailed");
            if (sl != null) {
                sl.onSignatureComplete(pdfPath, false, message);
            }
            throw new SignatureFailedException(message);
        } else {
            if (sl != null) {
                sl.onSignatureComplete(pdfPath, false, Bundle.getBundle().getString("unknownErrorLog"));
            }
            controller.Logger.getLogger().addEntry(e);
        }
        return false;
    }
}

From source file:controller.CreateTranscript.java

private void CreateTranscript(MyPerson p) {//,PrintWriter out){
    Document document = new Document();

    String name = p.getFName() + p.getLName();

    try {/*w w  w  .j a va 2s . c o m*/
        if (p.getUserType() == 6) {

            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("D:\\" + name + ".pdf"));
            document.open();

            PdfPTable table = new PdfPTable(8); // 8 columns.
            table.setWidthPercentage(100); //Width 100%
            table.setSpacingBefore(10f); //Space before table
            table.setSpacingAfter(10f); //Space after table

            //Set Column widths
            float[] columnWidths = { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
            table.setWidths(columnWidths);
            PdfPCell cell1 = new PdfPCell(new Paragraph("Subject Name"));
            cell1.setBorderColor(BaseColor.BLUE);
            cell1.setPaddingLeft(10);
            cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell2 = new PdfPCell(new Paragraph("Subject Code"));
            cell2.setBorderColor(BaseColor.BLUE);
            cell2.setPaddingLeft(10);
            cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell3 = new PdfPCell(new Paragraph("Written Grade"));
            cell3.setBorderColor(BaseColor.BLUE);
            cell3.setPaddingLeft(10);
            cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell4 = new PdfPCell(new Paragraph("Midterm Grade"));
            cell4.setBorderColor(BaseColor.BLUE);
            cell4.setPaddingLeft(10);
            cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell5 = new PdfPCell(new Paragraph("Final Exam Grade"));
            cell5.setBorderColor(BaseColor.BLUE);
            cell5.setPaddingLeft(10);
            cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell6 = new PdfPCell(new Paragraph("Final Grade"));
            cell6.setBorderColor(BaseColor.BLUE);
            cell6.setPaddingLeft(10);
            cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell7 = new PdfPCell(new Paragraph("Term"));
            cell7.setBorderColor(BaseColor.BLUE);
            cell7.setPaddingLeft(10);
            cell7.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
            PdfPCell cell8 = new PdfPCell(new Paragraph("Registration Date"));
            cell8.setBorderColor(BaseColor.BLUE);
            cell8.setPaddingLeft(10);
            cell8.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell8.setVerticalAlignment(Element.ALIGN_MIDDLE);

            table.addCell(cell1);
            table.addCell(cell2);
            table.addCell(cell3);
            table.addCell(cell4);
            table.addCell(cell5);
            table.addCell(cell6);
            table.addCell(cell7);
            table.addCell(cell8);

            ModelOfStudent modelOfStudent = new ModelOfStudent();
            ResultSet rs = modelOfStudent.ViewMyCourses(p.getCode());

            //    if(!rs.next()){out.println("<font color='blue'>There is no Courses Untill Now ^_^ </font>");}
            while (rs.next()) {

                table.addCell(rs.getString("SubjectName"));
                table.addCell(rs.getString("ID"));
                table.addCell(rs.getString("WritenGrade"));
                table.addCell(rs.getString("MidtermGrade"));
                table.addCell(rs.getString("FinalExamGrade"));
                table.addCell(rs.getString("FinalGrade"));
                table.addCell(rs.getString("Term"));
                table.addCell(rs.getString("StudentRegisterSubjectDate"));

                /* String SubjectRegisterDate=String.valueOf(rs.getDate("SubjectRegisterDate"));
                 table.addCell(SubjectRegisterDate);
                 */
            }

            //To avoid having the cell border and the content overlap, if you are having thick cell borders
            //cell1.setUserBorderPadding(true);
            //cell2.setUserBorderPadding(true);
            //cell3.setUserBorderPadding(true);
            document.add(new Paragraph("University: " + MyPerson.ReturnUniversityName(p.getCode())));
            document.add(new Paragraph("Faculity: " + MyPerson.ReturnFaculityName(p.getCode())));
            document.add(
                    new Paragraph("Student Name: " + p.getFName() + " " + p.getMName() + " " + p.getLName()));
            document.add(new Paragraph("Level: " + MyPerson.ReturnLevelName(p.getCode())));
            document.add(new Paragraph("Department: " + MyPerson.ReturnDepartmentName(p.getCode())));

            document.add(table);
            System.out.println(
                    "<script type='text/javascript' > alert('Successfull Creating Transcript ^_^ ');history.back();</script>");

            //out.println("Successfull Creating Transcript ^_^");
            document.close();
            writer.close();
        } //end of if student
    } catch (Exception e) {
        System.out.println("<script type='text/javascript' > alert('Failed Creating Transcript ^_^ Error:"
                + e.getMessage() + "  ');history.back();</script>");

        // out.println(""+e.getMessage());
        e.printStackTrace();
    }
}

From source file:Documentos.ReportesPDF.java

public void agregarTabla(Paragraph parrafo) {
    //Anchos de las columnas
    PdfPTable tabla = new PdfPTable(anchosFilas);
    // Porcentaje que ocupa a lo ancho de la pagina del PDF
    tabla.setWidthPercentage(90);/* www .  ja  v  a 2  s .co  m*/
    //Alineacion horizontal centrada
    tabla.setHorizontalAlignment(Element.ALIGN_CENTER);
    //agregar celda que ocupa las  columnas de los rotulos
    PdfPCell cell0 = new PdfPCell(new Paragraph("Repostera AnaIs"));
    cell0.setColspan(anchosFilas.length);
    cell0.setBackgroundColor(new BaseColor(66, 139, 202));
    //Centrar contenido de celda
    cell0.setHorizontalAlignment(Element.ALIGN_CENTER);
    PdfPCell cell = new PdfPCell(new Paragraph(tituloReporte()));
    cell.setColspan(anchosFilas.length);
    cell.setBackgroundColor(new BaseColor(49, 176, 213));
    //Centrar contenido de celda
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    //Color de fondo de la celda     
    tabla.addCell(cell0);
    tabla.addCell(cell);
    // Mostrar los rotulos de las columnas
    for (int i = 0; i < rotulosColumnas.length; i++) {
        cell = new PdfPCell(new Paragraph(rotulosColumnas[i]));
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(new BaseColor(248, 248, 248));
        tabla.addCell(cell);
    }
    switch (numReport) {
    case 1:
        DataBase.DataBasePDF.pdfVendedores(cell, tabla);
        break;
    case 2:
        DataBase.DataBasePDF.pdfProveedores(cell, tabla);
        break;
    case 3:
        DataBase.DataBasePDF.pdfClientes(cell, tabla);
        break;
    case 4:
        DataBase.DataBasePDF.pdfVentas(cell, tabla);
        break;
    case 5:
        DataBase.DataBasePDF.pdfProductos(cell, tabla);
        break;
    case 6:
        DataBase.DataBasePDF.pdfPedidos(cell, tabla);
        break;
    }

    //Agregar la tabla con los datos al parrafo que nos llego como entrada
    parrafo.add(tabla);
}

From source file:es.baudlord.pcpartpicker.controller.BuildViewController.java

License:Open Source License

@FXML
public void onBillAction(ActionEvent event) {
    if (build.isComplete()) {
        try {/*  ww  w. jav  a2 s.c om*/
            FileChooser chooser = new FileChooser();
            chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PDF", "*.pdf"));
            File file = chooser.showSaveDialog(((Node) event.getSource()).getScene().getWindow());
            if (file == null)
                return;
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream(file));
            document.open();
            // Begin header generation
            PdfPTable table = new PdfPTable(2);
            table.setWidths(new int[] { 3, 7 });
            com.itextpdf.text.Image image = com.itextpdf.text.Image
                    .getInstance(App.class.getResource("img/logo.png"));
            image.scaleToFit(100f, 100f);
            PdfPCell cell = new PdfPCell(image);
            cell.setBorder(0);
            PdfPCell cell2 = new PdfPCell(
                    new Paragraph("Hipster PC Store", new Font(Font.FontFamily.HELVETICA, 30)));
            cell2.setBorder(0);
            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
            table.addCell(cell);
            table.addCell(cell2);
            document.add(table);
            // End header generation
            document.add(build.createPdfPTable(new Font(Font.FontFamily.COURIER, 7)));
            // Begin generate date warning
            Calendar cal = Calendar.getInstance();
            Instant now = cal.toInstant();
            cal.add(Calendar.DAY_OF_MONTH, 7);
            Instant end = cal.toInstant();
            DateTimeFormatter localFormat = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
                    .withZone(ZoneId.systemDefault());
            Paragraph p1 = new Paragraph(GENERAL_BUNDLE.getString("bill.date.warning"),
                    new Font(Font.FontFamily.COURIER, 10, Font.BOLD));
            Paragraph p2 = new Paragraph(
                    GENERAL_BUNDLE.getString("bill.date.emitted") + " " + localFormat.format(now) + "\n"
                            + GENERAL_BUNDLE.getString("bill.date.valid") + " " + localFormat.format(end),
                    new Font(Font.FontFamily.COURIER, 10));
            p1.setAlignment(Element.ALIGN_CENTER);
            p2.setAlignment(Element.ALIGN_CENTER);
            document.add(p1);
            document.add(p2);
            // End generate date warning
            document.close();
            Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
            dialog.setTitle(GENERAL_BUNDLE.getString("bill.generated")); // TODO: translate
            dialog.setHeaderText(GENERAL_BUNDLE.getString("bill.validity"));
            dialog.getButtonTypes().setAll(ButtonType.CLOSE,
                    new ButtonType(GENERAL_BUNDLE.getString("button.Print"), ButtonBar.ButtonData.FINISH),
                    new ButtonType(GENERAL_BUNDLE.getString("button.ShowPDF"), ButtonBar.ButtonData.OK_DONE));
            dialog.showAndWait();
            if (dialog.getResult() != null) {
                ButtonBar.ButtonData result = dialog.getResult().getButtonData();
                if (result.equals(ButtonBar.ButtonData.FINISH)) {
                    Desktop.getDesktop().print(file);
                } else if (result.equals(ButtonBar.ButtonData.OK_DONE)) {
                    Desktop.getDesktop().open(file);
                }
            }
        } catch (DocumentException | IOException e) {
            e.printStackTrace();
        }
    } else {
        Alert dialog = new Alert(Alert.AlertType.WARNING);
        dialog.getButtonTypes().setAll(
                new ButtonType(GENERAL_BUNDLE.getString("button.tryAgain"), ButtonBar.ButtonData.OK_DONE),
                ButtonType.CANCEL);
        dialog.setTitle(GENERAL_BUNDLE.getString("dialog.build.incomplete"));
        List<Product.Category> missing = build.getMissingMandatoryParts();
        dialog.setHeaderText(GENERAL_BUNDLE.getString("dialog.build.needed"));
        final HBox content = new HBox(10);
        missing.forEach(category -> {
            Button button = new Button(App.PART_NAMES_BUNDLE.getString(category.toString()));
            button.setGraphic(Category.getGraphic(category, 30));
            button.setContentDisplay(ContentDisplay.TOP);
            button.setId(category.toString());
            button.setOnAction(actionEvent -> {
                try {
                    Part part = pickNewPart(category);
                    if (part != null) {
                        saved.set(false);
                        build.add(part);
                        displayBuild();
                        if (Category.isStorage(category)) {
                            content.getChildren()
                                    .removeIf(node -> node.getId().equals(Product.Category.HDD_SSD.toString())
                                            || node.getId().equals(Product.Category.HDD.toString()));
                            content.autosize();
                        } else {
                            content.getChildren().remove(button);
                        }
                        dialog.getDialogPane().getScene().getWindow().sizeToScene();
                        if (content.getChildren().isEmpty()) {
                            buttonBill.fire();
                            dialog.close();
                        }
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });
            content.getChildren().add(button);
        });
        dialog.getDialogPane().setContent(content);
        dialog.showAndWait();
        ButtonType result = dialog.getResult();
        if (result != null && result.getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) {
            dialog.hide();
            onBillAction(event);
        }
    }
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java

License:Open Source License

protected PdfPCell getContentCell() {

    PdfPCell cell = new PdfPCell();
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setPaddingBottom(5);// w w  w .ja  va  2  s .  c  o  m
    cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP);
    return cell;
}

From source file:eu.geopaparazzi.plugins.pdfexport.PdfExportDialogFragment.java

License:Open Source License

public void processNote(Document document, Note note, int count) throws Exception {
    String name = Utilities.makeXmlSafe(note.getName());
    String form = note.getForm();

    DaoImages daoImages = new DaoImages();
    if (form != null && form.length() > 0) {
        JSONObject sectionObject = new JSONObject(form);
        if (!sectionObject.has(FormUtilities.ATTR_SECTIONNAME)) {
            return;
        }/*from  ww w. ja  v  a 2s.  c o  m*/
        String sectionName = sectionObject.getString(FormUtilities.ATTR_SECTIONNAME);
        Anchor anchor = new Anchor(sectionName);
        anchor.setName(sectionName);
        Chapter currentChapter = new Chapter(new Paragraph(anchor), count);
        addEmptyLine(currentChapter, 3);

        PdfPTable infoTable = new PdfPTable(2);
        infoTable.setHeaderRows(0);
        infoTable.setWidthPercentage(90);
        currentChapter.add(infoTable);

        addKeyValueToTableRow(infoTable, "Timestamp", new Date(note.getTimeStamp()).toString());
        addKeyValueToTableRow(infoTable, "Latitude", note.getLat() + "");
        addKeyValueToTableRow(infoTable, "Longitude", note.getLon() + "");

        addEmptyLine(currentChapter, 3);

        List<String> formsNames = TagsManager.getFormNames4Section(sectionObject);
        for (String formName : formsNames) {
            Paragraph section = new Paragraph(formName);
            currentChapter.addSection(section);
            addEmptyLine(currentChapter, 3);

            PdfPTable currentTable = new PdfPTable(2);
            currentTable.setHeaderRows(1);
            currentTable.setWidthPercentage(90);
            currentChapter.add(currentTable);

            JSONObject form4Name = TagsManager.getForm4Name(formName, sectionObject);
            JSONArray formItems = TagsManager.getFormItems(form4Name);
            for (int i = 0; i < formItems.length(); i++) {
                JSONObject formItem = formItems.getJSONObject(i);
                if (!formItem.has(FormUtilities.TAG_KEY)) {
                    continue;
                }

                String type = formItem.getString(FormUtilities.TAG_TYPE);
                String key = formItem.getString(FormUtilities.TAG_KEY);
                String value = formItem.getString(FormUtilities.TAG_VALUE);

                String label = key;
                if (formItem.has(FormUtilities.TAG_LABEL)) {
                    label = formItem.getString(FormUtilities.TAG_LABEL);
                }

                if (type.equals(FormUtilities.TYPE_PICTURES)) {
                    if (value.trim().length() == 0) {
                        continue;
                    }
                    String[] imageIdsSplit = value.split(Note.IMAGES_SEPARATOR);
                    for (String imageId : imageIdsSplit) {
                        Image image = daoImages.getImage(Long.parseLong(imageId));
                        String imgName = image.getName();
                        byte[] imageData = daoImages.getImageData(Long.parseLong(imageId));
                        com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData);
                        Paragraph caption = new Paragraph(imgName);
                        caption.setAlignment(Element.ALIGN_CENTER);

                        PdfPCell keyCell = new PdfPCell(new Phrase(label));
                        keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        keyCell.setPadding(10);
                        currentTable.addCell(keyCell);
                        PdfPCell valueCell = new PdfPCell();
                        valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        valueCell.setPadding(10);
                        valueCell.addElement(itextImage);
                        valueCell.addElement(caption);
                        currentTable.addCell(valueCell);
                    }
                } else if (type.equals(FormUtilities.TYPE_MAP)) {
                    if (value.trim().length() == 0) {
                        continue;
                    }
                    String imageId = value.trim();
                    Image image = daoImages.getImage(Long.parseLong(imageId));
                    String imgName = image.getName();
                    byte[] imageData = daoImages.getImageData(Long.parseLong(imageId));
                    com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData);
                    Paragraph caption = new Paragraph(imgName);
                    caption.setAlignment(Element.ALIGN_CENTER);

                    PdfPCell keyCell = new PdfPCell(new Phrase(label));
                    keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    keyCell.setPadding(10);
                    currentTable.addCell(keyCell);
                    PdfPCell valueCell = new PdfPCell();
                    valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    valueCell.setPadding(10);
                    valueCell.addElement(itextImage);
                    valueCell.addElement(caption);
                    currentTable.addCell(valueCell);
                } else if (type.equals(FormUtilities.TYPE_SKETCH)) {
                    if (value.trim().length() == 0) {
                        continue;
                    }
                    String[] imageIdsSplit = value.split(Note.IMAGES_SEPARATOR);
                    for (String imageId : imageIdsSplit) {
                        Image image = daoImages.getImage(Long.parseLong(imageId));
                        String imgName = image.getName();
                        byte[] imageData = daoImages.getImageData(Long.parseLong(imageId));
                        com.itextpdf.text.Image itextImage = com.itextpdf.text.Image.getInstance(imageData);
                        Paragraph caption = new Paragraph(imgName);
                        caption.setAlignment(Element.ALIGN_CENTER);

                        PdfPCell keyCell = new PdfPCell(new Phrase(label));
                        keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        keyCell.setPadding(10);
                        currentTable.addCell(keyCell);
                        PdfPCell valueCell = new PdfPCell();
                        valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        valueCell.setPadding(10);
                        valueCell.addElement(itextImage);
                        valueCell.addElement(caption);
                        currentTable.addCell(valueCell);
                    }
                } else {
                    addKeyValueToTableRow(currentTable, label, value);
                }
            }
        }

        document.add(currentChapter);
        document.newPage();

    }

}

From source file:eu.geopaparazzi.plugins.pdfexport.PdfExportDialogFragment.java

License:Open Source License

private void addKeyValueToTableRow(PdfPTable table, String key, String value) {
    PdfPCell keyCell = new PdfPCell(new Phrase(key));
    keyCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    keyCell.setPadding(10);/*ww  w . ja  v  a  2  s.  c o m*/
    table.addCell(keyCell);
    PdfPCell valueCell = new PdfPCell(new Phrase(value));
    valueCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    valueCell.setPadding(10);
    table.addCell(valueCell);
}

From source file:Export.FuncPagamento.java

private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) {
    OutputStream outputStraem;//www .jav a  2  s  .  co  m
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy - dd", new Locale("pt", "BR"));
        SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat sdf2 = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                14f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
        Font fontCorpoU = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        //            Font fontCorpoP= FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,8f );
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                8.5f);
        //            Font fontCorpoNGT= FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED , 13f ,Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 10f, 5f);
        String Ddata = sdf1.format(new Date());

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);
        int total = mapList.size();

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");
        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);
        MyFooterA5 event = new MyFooterA5();
        writer.setPageEvent(event);

        documento.open();

        PdfPTable pTableTitile = new PdfPTable(new float[] { 100 });
        pTableTitile.setWidthPercentage(95f);
        PdfPCell cellTitile = new PdfPCell();
        cellTitile.setBorder(0);

        Paragraph pTitile = new Paragraph();

        pTitile.add(new Phrase(ConfigDoc.Empresa.NOME.toUpperCase(), fontCabecalhoNG));
        pTitile.setAlignment(Element.ALIGN_CENTER);

        PdfPTable pTableSubTitile = new PdfPTable(new float[] { 80, 20 });
        pTableSubTitile.setWidthPercentage(101f);

        PdfPCell cellSubTitile = new PdfPCell(
                new Phrase("Petty cash voucher no.".toUpperCase(), fontCabecalhoN));
        cellSubTitile.setBorder(0);
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingRight(67);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);

        cellSubTitile = new PdfPCell(
                new Phrase(toData((mapList.size() > 0) ? mapList.get(0).get(REGISTRO) : " ", i).toUpperCase(),
                        fontCabecalhoN));
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellSubTitile.setBorder(0);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);
        //            pTitile.add(cellSubTitile);

        pTitile.add(pTableSubTitile);

        cellTitile.addElement(pTitile);
        pTableTitile.addCell(cellTitile);

        documento.add(pTableTitile);

        PdfPTable pTableDados = new PdfPTable(new float[] { 5.6f, 6.05f, 53.5f, 17.95f, 19f });
        pTableDados.setWidthPercentage(95f);

        PdfPCell cellDados = new PdfPCell(new Phrase("S/N", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Qty", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Detail Description", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Unit price", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("AMT (STD)", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        Double toPa = 0.0;
        for (int j = 0; j < total; j++) {
            int tLinha = toString(mapList.get(j).get(DESCRICAOPAGAMENTO)).split("\n").length;

            float pad = setPadding(total, tLinha);

            cellDados = new PdfPCell(new Phrase((j + 1) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toInt(mapList.get(j).get(QUANTIDADE)) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toString(mapList.get(j).get(DESCRICAOPAGAMENTO)), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toMoeda(
                    (toDouble(mapList.get(j).get(VALORPAGAMENTO))
                            / (float) toInt(mapList.get(j).get(QUANTIDADE))),
                    toString(mapList.get(j).get(SIGLA))), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(
                    toMoeda(toDouble(mapList.get(j).get(VALORPAGAMENTO)), toString(mapList.get(j).get(SIGLA))),
                    fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            toPa += toDouble(mapList.get(j).get(VALORPAGAMENTO));
        }
        //            5.6f,5.6f,53.5f,17.95f,19.45f
        PdfPTable pTableRodape = new PdfPTable(new float[] { 5.6f, 6.05f, 19.795f, 33.705f, 17.95f, 19f });
        pTableRodape.setWidthPercentage(95f);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("CODE", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DOCFORMAPAGAMENTO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DESCRICAOCONTABANCO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toMoeda(toPa, toString(mapList.get(0).get(SIGLA))), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        documento.add(pTableDados);
        documento.add(pTableRodape);

        PdfPTable pTableAssiEstenso = new PdfPTable(new float[] { 100f });

        pTableAssiEstenso.setWidthPercentage(95f);

        PdfPCell cellAssiEstenso = new PdfPCell();
        Paragraph pAssiEstenso = new Paragraph();

        PdfPTable pTableResposavel = new PdfPTable(new float[] { 70, 30 });
        pTableResposavel.setWidthPercentage(100f);

        PdfPCell cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Requested by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" HOD:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Approveds by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" Date:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        pAssiEstenso.add(pTableResposavel);
        cellAssiEstenso.addElement(pAssiEstenso);

        PdfPTable pTableExteso = new PdfPTable(new float[] { 25f, 75f });
        pTableExteso.setWidthPercentage(100f);

        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(toPa, jtp, ((mapList.size() > 0) ? toString(mapList.get(0).get(MOEDA)) : ""));

        PdfPCell cellExteso = new PdfPCell(new Phrase("Recived the sum of", fontCorpoN));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);
        cellExteso = new PdfPCell(new Phrase(jtp.getText().toUpperCase().trim(), fontCorpoU));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);

        pAssiEstenso.add(pTableExteso);

        PdfPTable pTableAss = new PdfPTable(new float[] { 45f, 55f });
        pTableAss.setWidthPercentage(100f);

        PdfPCell cellAss = new PdfPCell(new Phrase(" ______________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        cellAss.setPaddingBottom(0f);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase(" ____________________________________________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setPaddingBottom(0f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Date", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Receiver name & signature", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);
        pTableAss.setHorizontalAlignment(Element.ALIGN_CENTER);

        pAssiEstenso.add(pTableAss);
        pAssiEstenso.setAlignment(Element.ALIGN_CENTER);
        pAssiEstenso.add(new Phrase(
                "NOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo.\n\n",
                fontCorpoN));
        cellAssiEstenso = new PdfPCell();
        cellAssiEstenso.addElement(pAssiEstenso);

        pTableAssiEstenso.addCell(cellAssiEstenso);

        documento.add(pTableAssiEstenso);

        documento.close();
        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (FileNotFoundException | DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.ReciboPagamento.java

public PdfPTable detaDoc(HashMap<String, Object> map, Font fontTitile, Font fontRecibo, Font fontTitileShort,
        Font fontReciboTxt, Font fontConteudo, Font fontConteudoTxt, Font fontConteudoTxtUl)
        throws DocumentException {
    PdfPTable pTablePrincipal = new PdfPTable(new float[] { 100 });
    try {//from   w w  w . j  ava  2  s .  c om
        pTablePrincipal.setWidthPercentage(100f);

        PdfPTable pTableTitulo = new PdfPTable(new float[] { 60, 40 });
        pTableTitulo.setWidthPercentage(100);

        PdfPTable pTableTituloImage = new PdfPTable(new float[] { 20, 80 });
        pTableTituloImage.setWidthPercentage(100);

        PdfPCell cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontTitile));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingTop(20f);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase("Recibo N ".toUpperCase() + map.get(IDAMORTIZACAO), fontRecibo));
        cellTitulo.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO + ", " + ConfigDoc.Empresa.CAIXAPOSTAL
                + ", " + ConfigDoc.Empresa.TELEFAX, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setPaddingLeft(70f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.REPUBLICA, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.EMAIL, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase("Ordem de receita / recibo".toUpperCase(), fontRecibo));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setVerticalAlignment(Element.ALIGN_TOP);
        cellTitulo.setPaddingBottom(30f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 85f);
        imageEmpresa.setAlignment(Image.ALIGN_CENTER);

        PdfPCell cellImagem = new PdfPCell(imageEmpresa);
        cellImagem.setBorder(PdfPCell.NO_BORDER);
        cellImagem.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cellImagem.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

        PdfPCell cellpTableTitulo = new PdfPCell(pTableTitulo);
        cellpTableTitulo.setBorder(PdfPCell.NO_BORDER);
        cellpTableTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        pTableTituloImage.addCell(cellImagem);
        pTableTituloImage.addCell(cellpTableTitulo);

        PdfPCell cellpTableTituloPrincipal = new PdfPCell(pTableTituloImage);
        cellpTableTituloPrincipal.setBorder(PdfPCell.NO_BORDER);

        pTablePrincipal.addCell(cellpTableTituloPrincipal);

        PdfPTable pTableDataCaixaMontante = new PdfPTable(new float[] { 35f, 5f, 60f });
        pTableDataCaixaMontante.setWidthPercentage(100f);

        PdfPCell cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo));
        cellDataCaixaMontante.setBorder(0);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);
        cellDataCaixaMontante = new PdfPCell();
        cellDataCaixaMontante.setBorder(0);
        Paragraph p = new Paragraph();
        p.add(new Phrase("Data: ".toUpperCase(), fontRecibo));

        p.add(new Phrase(converterData(map.get(REGISTROAMORTIZACAO), 1), fontReciboTxt));
        p.setAlignment(Element.ALIGN_RIGHT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingBottom(5f);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell();
        p = new Paragraph();
        p.add(new Phrase("Caixa de: ".toUpperCase(), fontRecibo));
        p.add(new Phrase("So Tom", fontReciboTxt));
        p.setAlignment(Element.ALIGN_LEFT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingTop(-2f);
        cellDataCaixaMontante.setPaddingBottom(5f);
        cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo));
        cellDataCaixaMontante.setBorder(0);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell();
        p = new Paragraph();
        p.add(new Phrase("Montante: ".toUpperCase(), fontRecibo));

        Double montade = Moeda.arrendodamento(toString(map.get(VALORAMORTIZADO)));

        //            SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:");
        Object dRegistro = map.get(DATAREGAPOLICE);
        montade *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro);

        p.add(new Phrase(converterMoeda(montade, "STD") + "", fontReciboTxt));
        p.setAlignment(Element.ALIGN_LEFT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingTop(-2f);
        cellDataCaixaMontante.setPaddingBottom(5f);
        cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        PdfPCell cellDataCaixaMontantePrincipal = new PdfPCell(pTableDataCaixaMontante);
        cellDataCaixaMontantePrincipal.setBorder(PdfPCell.NO_BORDER);

        pTablePrincipal.addCell(cellDataCaixaMontantePrincipal);

        PdfPTable pTableConteudo = new PdfPTable(new float[] { 40, 60 });
        pTableConteudo.setWidthPercentage(100f);
        PdfPCell cellConteudo = new PdfPCell();
        cellConteudo.setBorder(0);

        Paragraph pConteudo = new Paragraph();
        pConteudo.add(new Phrase("N Assegurado: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(map.get(NUMREGISTRO) + "\n", fontConteudoTxt));

        /**
         * For alter
         */
        pConteudo.add(new Phrase("Prmio Liquido: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterMoeda(map.get(TOTALBRUTO), map.get(SIGLAMOEDA) + "") + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("Impostos: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOCONSUMO)),
                map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Impostos Selo: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(
                converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOSELO)), map.get(SIGLAMOEDA) + "")
                        + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("FGA: ", fontConteudo));
        pConteudo.add(new Phrase(
                converterMoeda(impostosCalculo(map.get(TOTAl), map.get(MOTORFOUND)), map.get(SIGLAMOEDA) + "")
                        + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("Total: ".toUpperCase(), fontConteudo));
        pConteudo.add(
                new Phrase(converterMoeda(map.get(TOTAl), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Efeito: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterData(map.get(EFEITO), 1) + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Vencimento: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterData(map.get(VENCIMENTO), 1) + "\n", fontConteudoTxt));

        cellConteudo.addElement(pConteudo);
        pTableConteudo.addCell(cellConteudo);

        cellConteudo = new PdfPCell();
        cellConteudo.setBorder(0);

        pConteudo = new Paragraph();
        pConteudo.add(new Phrase("Recebido do Sr: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(map.get(CLIENTE) + "\n", fontConteudoTxt));

        PdfPTable pTableNomeCod = new PdfPTable(new float[] { 70, 30 });
        pTableNomeCod.setWidthPercentage(100);

        Paragraph pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Nome do Assegurado/Pagador: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(map.get(CLIENTE) + "", fontConteudoTxt));
        PdfPCell cellNomeCod = new PdfPCell();
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        cellNomeCod = new PdfPCell();
        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Nome do Intermedirio: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod = new PdfPCell();
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        cellNomeCod = new PdfPCell();
        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        pConteudo.add(pTableNomeCod);

        JTextPane jtp = new JTextPane();
        Double valor = Moeda.arrendodamento((map.get(VALORPRESTACAO) + ""));
        valor *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro);
        Moeda.EscreverEstenso(valor, jtp, "Dobras");

        pConteudo.add(new Phrase("A soma (por extenso) ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(jtp.getText().trim() + "\n", fontConteudoTxt));

        PdfPTable pTableApoliceDatasP = new PdfPTable(new float[] { 20, 80 });
        pTableApoliceDatasP.setWidthPercentage(100);
        PdfPTable pTableApoliceDatas = new PdfPTable(new float[] { 60, 40 });
        pTableApoliceDatas.setWidthPercentage(100);

        for (int i = 0; i < 1; i++) {
            PdfPCell cellApolice = new PdfPCell();
            Paragraph pApolice = new Paragraph();
            pApolice.add(new Phrase("N ", fontConteudo));
            pApolice.add(new Phrase(map.get(APOLICA) + "", fontConteudoTxt));
            cellApolice.addElement(pApolice);
            cellApolice.setPaddingTop(-2f);
            cellApolice.setPaddingBottom(2f);
            cellApolice.setBorder(0);
            pTableApoliceDatas.addCell(cellApolice);

            PdfPCell cellDatas = new PdfPCell();
            Paragraph pDatas = new Paragraph();
            pDatas.add(new Phrase("Data: ".toUpperCase(), fontConteudo));
            pDatas.add(new Phrase(converterData(map.get(DATAREGAPOLICE), 2) + "", fontConteudoTxt));
            cellDatas.addElement(pDatas);
            cellDatas.setBorder(0);
            cellDatas.setPaddingTop(-2f);
            cellDatas.setPaddingBottom(2f);
            pTableApoliceDatas.addCell(cellDatas);
        }
        PdfPCell cellApoliceP = new PdfPCell(new Phrase("Apolices".toUpperCase(), fontConteudo));
        cellApoliceP.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellApoliceP.setBorder(0);
        pTableApoliceDatasP.addCell(cellApoliceP);
        cellApoliceP = new PdfPCell(pTableApoliceDatas);
        cellApoliceP.setBorder(0);
        pTableApoliceDatasP.addCell(cellApoliceP);

        pConteudo.add(pTableApoliceDatasP);
        //            
        PdfPTable pTableTipoPagemento = new PdfPTable(new float[] { 70f, 30f });
        pTableTipoPagemento.setWidthPercentage(100f);

        PdfPCell cellTipoPageme = new PdfPCell();
        Paragraph pDatas = new Paragraph();
        pDatas.add(new Phrase("Pagamento: ".toUpperCase(), fontConteudo));
        pDatas.add(new Phrase(map.get(TIPOPAGAMENTO) + " ", fontConteudoTxt));
        cellTipoPageme.addElement(pDatas);
        cellTipoPageme.setBorder(0);
        cellTipoPageme.setPaddingTop(-2f);
        cellTipoPageme.setPaddingBottom(2f);
        //           cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        //           cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f);
        //           cellTipoPageme.setBorderWidthBottom(0.5f);
        pTableTipoPagemento.addCell(cellTipoPageme);

        cellTipoPageme = new PdfPCell();
        pDatas = new Paragraph();
        pDatas.add(new Phrase("N ".toUpperCase(), fontConteudo));
        pDatas.add(new Phrase(toString(map.get(DOCUMENTOAMORTIZACAO)) + " ", fontConteudoTxt));
        cellTipoPageme.addElement(pDatas);
        cellTipoPageme.setBorder(0);
        cellTipoPageme.setPaddingTop(-2f);
        cellTipoPageme.setPaddingBottom(2f);
        //                cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        //                cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f);
        //                cellTipoPageme.setBorderWidthBottom(0.5f);
        pTableTipoPagemento.addCell(cellTipoPageme);

        pConteudo.add(pTableTipoPagemento);

        cellConteudo.addElement(pConteudo);
        pTableConteudo.addCell(cellConteudo);

        PdfPCell cellConteudoPrincipal = new PdfPCell(new PdfPTable(pTableConteudo));
        cellConteudoPrincipal.setBorder(PdfPCell.NO_BORDER);
        pTablePrincipal.addCell(cellConteudoPrincipal);

        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });
        pTableAssinatura.setWidthPercentage(100f);

        Font fontConteudoTxt_acess = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI,
                BaseFont.EMBEDDED, 5f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker());
        Font fontConteudo_acess = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI,
                BaseFont.EMBEDDED, 5f, Font.NORMAL, BaseColor.BLUE.darker().darker());

        PdfPCell cellAcessorio = new PdfPCell();
        Paragraph pAcessorio = new Paragraph();
        pAcessorio.add(new Phrase("Acessrios: ".toUpperCase(), fontConteudo_acess));
        pAcessorio.add(new Phrase(
                (map.get(ACCESSORIO) == null) ? " " : (map.get(ACCESSORIO) + "").replaceAll("\n", " "),
                fontConteudoTxt_acess));
        cellAcessorio.addElement(pAcessorio);
        cellAcessorio.setColspan(2);
        cellAcessorio.setBorder(0);
        cellAcessorio.setPaddingBottom(4f);
        cellAcessorio.setPaddingTop(-2f);
        pTableAssinatura.addCell(cellAcessorio);

        PdfPCell cellLinhaAssina = new PdfPCell();
        Paragraph pAssinatura = new Paragraph();
        pAssinatura.add(new Paragraph("_________________________________", fontConteudo));
        pAssinatura.add(new Paragraph("                Carimbo e Assinatura", fontConteudo));
        pAssinatura.setAlignment(Element.ALIGN_CENTER);
        cellLinhaAssina.addElement(pAssinatura);
        cellLinhaAssina.setPaddingBottom(2f);
        cellLinhaAssina.setBorder(0);
        cellLinhaAssina.setPaddingTop(25f);
        pTableAssinatura.addCell(cellLinhaAssina);

        PdfPCell cellCambio = new PdfPCell();
        Paragraph pCombio = new Paragraph();
        pCombio.add(new Phrase("Cambio (USD): ".toUpperCase(), fontConteudo));
        pCombio.add(new Phrase(converterMoeda(valorCompra("USD", dRegistro), "") + "\n", fontConteudoTxt));
        pCombio.add(new Phrase("Cambio (EUR): ".toUpperCase(), fontConteudo));
        pCombio.add(new Phrase(converterMoeda(valorCompra("EUR", dRegistro), "") + "\n", fontConteudoTxt));
        cellCambio.addElement(pCombio);
        cellCambio.setBorder(0);
        cellCambio.setPaddingTop(-2f);
        cellCambio.setPaddingBottom(2f);
        pTableAssinatura.addCell(cellCambio);

        PdfPCell cellpTableAssinaturaPrincipal = new PdfPCell(pTableAssinatura);
        cellpTableAssinaturaPrincipal.setBorder(PdfPCell.NO_BORDER);
        pTablePrincipal.addCell(new PdfPCell(cellpTableAssinaturaPrincipal));

        //            pTableAssinatura.writeSelectedRows(-1, 2, 10, 70, writer.getDirectContent());
        //            pTableImagem.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent());
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return pTablePrincipal;
}