Example usage for com.itextpdf.text Font BOLD

List of usage examples for com.itextpdf.text Font BOLD

Introduction

In this page you can find the example usage for com.itextpdf.text Font BOLD.

Prototype

int BOLD

To view the source code for com.itextpdf.text Font BOLD.

Click Source Link

Document

this is a possible style.

Usage

From source file:es.sm2.openppm.front.utils.DocumentUtils.java

License:Open Source License

/**
 * Create PDF for Control Change//from  w  w  w . j a  va  2 s.  c o m
 * @param idioma
 * @param project
 * @param change
 * @param preparedBy
 * @return
 * @throws DocumentException
 * @throws LogicException
 */
public static byte[] toPdf(ResourceBundle idioma, Project project, Changecontrol change, Employee preparedBy,
        final Image headerImg, final Image footerImg) throws DocumentException, LogicException {

    if (change == null) {
        throw new DocumentException("No change control found.");
    }

    if (preparedBy == null || preparedBy.getContact() == null) {
        throw new UserSendingException();
    }

    Document document = new Document(PageSize.A4);
    document.setMargins(70F, 70F, 38F, 38F); // Total Height: 842pt, Total Width: 595pt
    byte[] file = null;

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    @SuppressWarnings("unused")
    PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream);

    document.open();

    Font fontHeader = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD);
    Font fontCell = new Font(FontFamily.TIMES_ROMAN, 9);
    Font tituloFont = new Font(FontFamily.TIMES_ROMAN, 16, Font.BOLD);

    document.add(new Paragraph(" ", tituloFont));
    document.add(new Paragraph(" ", tituloFont));
    document.add(new Paragraph(" ", fontHeader));
    Paragraph title = new Paragraph(idioma.getString("change_request").toUpperCase(), tituloFont);
    title.setAlignment(Paragraph.ALIGN_CENTER);
    document.add(title);

    // Header Table
    // Project info
    PdfPTable tableHeader = new PdfPTable(3);
    tableHeader.setWidthPercentage(100);
    tableHeader.setSpacingBefore(10);
    tableHeader.setSpacingAfter(15);

    int[] colWidth = new int[3];
    colWidth[0] = 40;
    colWidth[1] = 30;
    colWidth[2] = 30;
    tableHeader.setWidths(colWidth);

    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.project_name"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.prepared_by"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(prepareHeaderCell(idioma.getString("change_request.date"), fontHeader, 1F, 1F, 0F, 1F));

    tableHeader.addCell(prepareCell(project.getProjectName() + " / " + project.getAccountingCode(), fontCell,
            0F, 0F, 0F, 1F));
    tableHeader.addCell(prepareCell(preparedBy.getContact().getFullName(), fontCell, 0F, 0F, 0F, 1F));
    tableHeader.addCell(prepareCell(DateUtil.format(idioma, new Date()), fontCell, 0F, 1F, 0F, 1F));

    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.customer"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.contact_name"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.customer_type"), fontHeader, 1F, 1F, 0F, 1F));

    tableHeader.addCell(prepareCell(project.getCustomer() != null ? project.getCustomer().getName() : "",
            fontCell, 0F, 0F, 0F, 1F));
    tableHeader.addCell(prepareCell((project.getCustomer() != null ? project.getCustomer().getName() : "-"),
            fontCell, 0F, 0F, 0F, 1F));

    Customertype cusType = (project.getCustomer() != null ? project.getCustomer().getCustomertype() : null);
    tableHeader.addCell(prepareCell(cusType == null ? "" : cusType.getName(), fontCell, 0F, 1F, 0F, 1F));

    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.business_manager"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.project_manager"), fontHeader, 1F, 0F, 0F, 1F));
    tableHeader.addCell(
            prepareHeaderCell(idioma.getString("change_request.originator"), fontHeader, 1F, 1F, 0F, 1F));

    Employee bm = project.getEmployeeByFunctionalManager();
    Employee pm = project.getEmployeeByProjectManager();

    tableHeader.addCell(prepareCell(bm == null ? "" : bm.getContact().getFullName(), fontCell, 0F, 0F, 1F, 1F));
    tableHeader.addCell(prepareCell(pm == null ? "" : pm.getContact().getFullName(), fontCell, 0F, 0F, 1F, 1F));
    tableHeader.addCell(prepareCell(change.getOriginator(), fontCell, 0F, 1F, 1F, 1F));

    document.add(tableHeader);

    // Change Information
    document.add(new Paragraph(idioma.getString("change_information")));

    PdfPTable tableInfo = new PdfPTable(1);
    tableInfo.setWidthPercentage(100);
    tableInfo.setSpacingBefore(10);
    tableInfo.setSpacingAfter(15);

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.change_type"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getChangetype().getDescription(), fontCell, 0F, 1F, 0F, 1F));

    String priorityDesc = "";
    if (change.getPriority().equals('H'))
        priorityDesc = idioma.getString("change.priority.high");
    if (change.getPriority().equals('N'))
        priorityDesc = idioma.getString("change.priority.normal");
    if (change.getPriority().equals('L'))
        priorityDesc = idioma.getString("change.priority.low");

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.priority"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(priorityDesc, fontCell, 0F, 1F, 0F, 1F));

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.desc"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getDescription(), fontCell, 0F, 1F, 0F, 1F));

    tableInfo.addCell(
            prepareHeaderCell(idioma.getString("change.recommended_solution"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getRecommendedSolution(), fontCell, 0F, 1F, 1F, 1F));

    PdfPTable tableSubInfo = new PdfPTable(3);
    tableSubInfo.setWidthPercentage(100);

    //TODO MIGRACION
    tableSubInfo.addCell(prepareSubCell(idioma.getString("change.wbs_node"), fontHeader));
    tableSubInfo.addCell(prepareSubCell(idioma.getString("change.estimated_effort"), fontHeader));
    tableSubInfo.addCell(prepareSubCell(idioma.getString("change.estimated_cost"), fontHeader));

    tableSubInfo.addCell(
            prepareSubCell((change.getWbsnode() != null ? change.getWbsnode().getName() : ""), fontCell));
    tableSubInfo.addCell(prepareSubCell(
            (change.getEstimatedEffort() != null ? String.valueOf(change.getEstimatedEffort()) : ""),
            fontCell));
    tableSubInfo.addCell(prepareSubCell(
            (change.getEstimatedCost() != null ? ValidateUtil.toCurrency(change.getEstimatedCost()) : ""),
            fontCell));

    PdfPCell subTable = new PdfPCell(tableSubInfo);
    subTable.setBorderWidth(1F);

    tableInfo.addCell(subTable);

    tableInfo.addCell(prepareHeaderCell(idioma.getString("change.impact_desc"), fontHeader, 1F, 1F, 0F, 1F));
    tableInfo.addCell(prepareCell(change.getImpactDescription(), fontCell, 0F, 1F, 1F, 1F));

    document.add(tableInfo);

    document.add(new Paragraph(idioma.getString("change.resolution")));

    PdfPTable tableResolution = new PdfPTable(1);
    tableResolution.setWidthPercentage(100);
    tableResolution.setSpacingBefore(10);
    tableResolution.setSpacingAfter(15);

    tableResolution
            .addCell(prepareHeaderCell(idioma.getString("change.resolution"), fontHeader, 1F, 1F, 0F, 1F));
    tableResolution.addCell(
            prepareCell((change.getResolution() != null && change.getResolution() ? idioma.getString("yes")
                    : idioma.getString("no")), fontCell, 0F, 1F, 0F, 1F));

    tableResolution
            .addCell(prepareHeaderCell(idioma.getString("change.resolution_date"), fontHeader, 1F, 1F, 0F, 1F));
    tableResolution.addCell(
            prepareCell(DateUtil.format(idioma, change.getResolutionDate()), fontCell, 0F, 1F, 0F, 1F));

    tableResolution.addCell(
            prepareHeaderCell(idioma.getString("change.resolution_reason"), fontHeader, 1F, 1F, 0F, 1F));
    tableResolution.addCell(prepareCell(change.getResolutionReason(), fontCell, 0F, 1F, 1F, 1F));

    document.add(tableResolution);

    document.close();

    try {

        PdfReader reader = new PdfReader(outputStream.toByteArray());
        PdfStamper stamper = new PdfStamper(reader, outputStream);

        int numPag = reader.getNumberOfPages();

        for (int i = 1; i <= reader.getNumberOfPages(); i++) {
            setHeaderFooter(i, numPag, headerImg, footerImg, reader, stamper, idioma);
        }

        stamper.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    file = outputStream.toByteArray();

    return file;
}

From source file:essencialles.modelos.relatorio.tipos.MaisVendidos.java

@Override
public void run() {
    try {//ww  w  . ja va2 s  .co  m
        //criao do PDF
        Document doc = new Document(PageSize.A4, 72, 72, 72, 72);

        OutputStream saida = new FileOutputStream(this.caminho);
        PdfWriter.getInstance(doc, saida);
        doc.open();
        try {
            //logomarca
            Image img = Image.getInstance("src/views/img/logomarca.png");
            img.setAlignment(Element.ALIGN_CENTER);
            doc.add(img);
        } catch (BadElementException | IOException ex) {
            throw new RuntimeException(ex);
        }
        //paragrafo
        Paragraph paragrafo = new Paragraph("Relatrio de Produtos Mais Vendidos");
        paragrafo.setSpacingAfter(50);
        paragrafo.setSpacingBefore(15);
        paragrafo.setFont(new Font(Font.FontFamily.COURIER, Font.BOLD));
        paragrafo.setAlignment(Element.ALIGN_CENTER);
        doc.add(paragrafo);

        /*tabela
         PdfPTable tabela = new PdfPTable(9);
         tabela.setHorizontalAlignment(Element.ALIGN_CENTER);
         PdfPCell header = new PdfPCell(new Paragraph("Todos os Produtos"));
         header.setColspan(9);
         tabela.addCell(header);
         tabela.addCell("Codigo");
         tabela.addCell("Nome");
         tabela.addCell("Marca");
         tabela.addCell("Preo");
         tabela.addCell("Custo");
         tabela.addCell("Cor");
         tabela.addCell("Descrio");
         tabela.addCell("Peso");
         tabela.addCell("Disponibilidade");
         tabela.addCell("Validade");
         adicionar linhas da tabela.
         for (Produto p : produtos) {
         String cod = p.getCod_produto() + "";
         String nome = p.getNome();
         String marca = p.getMarca();
         String preco = p.getPreco() + "";
         String custo = p.getCusto() + "";
         String cor = p.getCor();
         String descricao = p.getDescricao();
         String peso = p.getPeso();
         String disponibilidade = p.getDisponibilidade();
         String validade = p.getValidade() + "";
                
         }*/
        try {
            saida.flush();

        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        doc.close();

        try {
            saida.close();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

    } catch (FileNotFoundException | DocumentException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:essencialles.modelos.relatorio.tipos.ProdutosTodos.java

@Override
public void run() {

    try {/*from   w  ww .ja va 2s  .  c  o m*/
        //criao do PDF

        Document doc = new Document(PageSize.A4, 72, 72, 72, 72);

        OutputStream saida = new FileOutputStream(this.caminho);
        PdfWriter.getInstance(doc, saida);
        doc.open();
        try {
            //logomarca

            Image img = Image.getInstance("src/views/img/logomarca.png");
            img.setAlignment(Element.ALIGN_CENTER);
            doc.add(img);
        } catch (BadElementException | IOException ex) {
            throw new RuntimeException(ex);
        }
        //paragrafo
        Paragraph paragrafo = new Paragraph("Relatrio de Produtos");
        paragrafo.setSpacingAfter(50);
        paragrafo.setSpacingBefore(15);
        paragrafo.setFont(new Font(Font.FontFamily.COURIER, Font.BOLD));
        paragrafo.setAlignment(Element.ALIGN_CENTER);
        doc.add(paragrafo);

        /*tabela
         PdfPTable tabela = new PdfPTable(9);
         tabela.setHorizontalAlignment(Element.ALIGN_CENTER);
         PdfPCell header = new PdfPCell(new Paragraph("Todos os Produtos"));
         header.setColspan(9);
         tabela.addCell(header);
         tabela.addCell("Codigo");
         tabela.addCell("Nome");
         tabela.addCell("Marca");
         tabela.addCell("Preo");
         tabela.addCell("Custo");
         tabela.addCell("Cor");
         tabela.addCell("Descrio");
         tabela.addCell("Peso");
         tabela.addCell("Disponibilidade");
         tabela.addCell("Validade");
         adicionar linhas da tabela.
         for (ProdutoModelo p : produtos) {
         String cod = p.getCod_produto() + "";
         String nome = p.getNome();
         String marca = p.getMarca();
         String preco = p.getPreco() + "";
         String custo = p.getCusto() + "";
         String cor = p.getCor();
         String descricao = p.getDescricao();
         String peso = p.getPeso();
         String disponibilidade = p.getDisponibilidade();
         String validade = p.getValidade() + "";
                
         }*/
        try {
            saida.flush();

        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        doc.close();

        try {
            saida.close();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

    } catch (FileNotFoundException | DocumentException ex) {
        throw new RuntimeException(ex);
    }

}

From source file:Export.ExporOnlyViagemPdf.java

private Phrase funcaoTitulo(int i) {
    String txt;//  ww w.  j  a  v  a 2  s.  c o m
    Font fontcabecatable = new Font(Font.FontFamily.COURIER, 8, Font.BOLD);
    switch (i) {
    case 0:
        txt = "S/N";
        break;
    case 1:
        txt = "DATA";
        break;
    case 2:
        txt = "APOLICE";
        break;
    case 3:
        txt = "DATA INICIO";
        break;
    case 4:
        txt = "DATA FIM";
        break;
    case 5:
        txt = "NO. DIAS";
        break;
    case 6:
        txt = "NOME";
        break;
    case 7:
        txt = "RECEIPT NO.";
        break;
    case 8:
        txt = "EA PREM";
        break;
    case 9:
        txt = "NICON COMISSO";
        break;
    case 10:
        txt = "5% IMPOSTO";
        break;
    case 11:
        txt = "0.60% SELO";
        break;
    //           case 12:txt="NET OUT OF TAX";break;
    default:
        txt = "TOTAL"/*"NET OUT OF TAX"*/;
        break;
    }

    Phrase rt = new Phrase(txt, fontcabecatable);
    return rt;
}

From source file:Export.SeguroMaritimo.java

public String criarDoc(String numApolice, String numCliente, MaritimoBean mb, Contrato c, String user,
        String moeda, String arquivo) {
    try {// w ww .jav a  2  s  .  c  o  m
        SimpleDateFormat sdf = 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(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableNull = new PdfPTable(1);
        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo));
        cellNull.setBorder(0);
        pTableNull.addCell(cellNull);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN));
        pCellPolice.setBorder(0);
        pCellPolice.setBorder(0);

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

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres1.addCell(pCellPolice);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPTable pTableSeguro = new PdfPTable(1);
        PdfPTable pTableCliente = new PdfPTable(1);

        PdfPTable pTableTitulo = new PdfPTable(1);
        Phrase pTitulo = new Phrase("Formulario de SEguro Maritimo".toUpperCase());
        pTitulo.getFont().setStyle(Font.BOLD);
        pTitulo.getFont().setFamily(Font.FontFamily.COURIER.name());
        PdfPCell cellTitulo = new PdfPCell(pTitulo);
        cellTitulo.setBorder(0);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        ClienteI ci = new ClienteI(numCliente);
        PdfPCell cellTituloTsbleSegurado = new PdfPCell(
                new Phrase("1 - Informaes Cliente".toUpperCase(), fontCorpoNG));
        cellTituloTsbleSegurado.setBorder(0);

        Paragraph pCl = new Paragraph();
        pCl.add(new Phrase("   " + ci.getNOMEL_(), fontCorpo));
        pCl.add(new Phrase(ci.getNOME_(), fontCorpoN));
        PdfPCell cellNome = new PdfPCell(new Phrase(pCl));
        cellNome.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase("   " + ci.getENDERECOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getENDERECO_(), fontCorpoN));
        PdfPCell cellEndereco = new PdfPCell(pCl);
        cellEndereco.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase("   " + ci.getNUNCLIENTEL_(), fontCorpo));
        pCl.add(new Phrase(ci.getNUNCLIENTE_(), fontCorpoN));
        PdfPCell cellNCliente = new PdfPCell(pCl);
        cellNCliente.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase("   " + ci.getPROFISSAOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN));
        PdfPCell cellProfissao = new PdfPCell(pCl);
        cellProfissao.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase("   " + ci.getLOCALTRABALHOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getLOCALTRABALHO_(), fontCorpoN));
        PdfPCell cellLocalTrabalho = new PdfPCell(pCl);
        cellLocalTrabalho.setBorder(0);

        pTableCliente.addCell(cellTituloTsbleSegurado);
        pTableCliente.addCell(cellNome);
        pTableCliente.addCell(cellEndereco);
        pTableCliente.addCell(cellNCliente);
        pTableCliente.addCell(cellProfissao);
        pTableCliente.addCell(cellLocalTrabalho);

        PdfPCell cellTiltuloSegro = new PdfPCell(
                new Phrase("3 - Montante Segurado/Limete de Responsabilidade".toUpperCase(), fontCorpoNG));
        cellTiltuloSegro.setBorder(0);
        PdfPCell cellApolice = new PdfPCell(
                new Phrase("   N Aplice: ".toUpperCase() + numApolice, fontCorpo));
        cellApolice.setBorder(0);
        PdfPCell cellPeriodo = new PdfPCell(new Phrase("   Periodo Do Seguro: ".toUpperCase()
                + ((c.getDataInicio() != null) ? sdf.format(c.getDataInicio()) : "") + "  "
                + ((c.getDataFim() != null) ? sdf.format(c.getDataFim()) : ""), fontCorpo));
        cellPeriodo.setBorder(0);
        PdfPCell cellDataNota = new PdfPCell(new Phrase(
                "   Ambas as datas incluidas, para os periodos adicionados que possam ser mutuamente acordadas"
                        .toUpperCase(),
                fontCorpo));
        cellDataNota.setBorder(0);
        PdfPCell cellCorpoMotor = new PdfPCell(new Phrase(
                "   Para Corpo e o motor (Excluindo risco de guerra): ".toUpperCase() + c.getPrimeiroPremio(),
                fontCorpo));
        cellCorpoMotor.setBorder(0);
        PdfPCell cellParaTerceiro = new PdfPCell(
                new Phrase("   Para terceiros/responsabilidade civil: ", fontCorpo));
        cellParaTerceiro.setBorder(0);
        PdfPCell cellAcidentePessoal = new PdfPCell(
                new Phrase("   Para acidente pessoal ao condutor: ", fontCorpo));
        cellAcidentePessoal.setBorder(0);
        PdfPCell cellTotalPremioAnual = new PdfPCell(
                new Phrase("   Valor Premio Anual: ".toUpperCase() + c.getPremioAnual(), fontCorpo));
        cellTotalPremioAnual.setBorder(0);

        pTableSeguro.addCell(cellTiltuloSegro);
        pTableSeguro.addCell(cellApolice);
        pTableSeguro.addCell(cellPeriodo);
        pTableSeguro.addCell(cellDataNota);
        pTableSeguro.addCell(cellCorpoMotor);
        pTableSeguro.addCell(cellParaTerceiro);
        pTableSeguro.addCell(cellAcidentePessoal);
        pTableSeguro.addCell(cellTotalPremioAnual);

        PdfPTable pTableDadosTitulo = new PdfPTable(1);
        PdfPCell cellDadosTitulo = new PdfPCell(new Phrase());
        cellDadosTitulo.setBorder(0);
        Paragraph pInfoTitulo = new Paragraph("2 - Informaes do(s) Navio(s)".toUpperCase(), fontCorpoN);
        Paragraph pInfoShip = new Paragraph(
                "   1. Navio/Embarcao: ".toUpperCase() + mb.getMaritimo().getNomeNavio(), fontCorpo);
        Paragraph pInfo1 = new Paragraph("      A)MARCA/MODELO (CASSI: ) " + mb.getMaritimo().getMarcaModelo()
                + "/" + mb.getMaritimo().getMarcaMotor(), fontCorpo);
        Paragraph pInfo2 = new Paragraph("   2. TIPO DE CONSTRUO DO NAVIO (i.e Material usado) "
                + mb.getMaritimo().getTipoConstrucao(), fontCorpo);
        Paragraph pInfo3 = new Paragraph("   3. TIPO DE NAVIO: " + mb.getMaritimo().getTipoNavio(), fontCorpo);
        Paragraph pInfo4 = new Paragraph(
                "   4. IDADE DO NAVIO (ano de construo): " + mb.getMaritimo().getIdadeNavio(), fontCorpo);
        Paragraph pInfo5 = new Paragraph(
                "   5. CONDIO ACTUAL DO NAVIO: " + mb.getMaritimo().getCondicaoAtual(), fontCorpo);
        Paragraph pInfo6 = new Paragraph("   6. RELATRIO DE MANUTEMO DOS PROPRIET?RIOS DO NAVIO: ",
                fontCorpo);
        Paragraph pInfo7 = new Paragraph(
                "   7. CLASSE DE ESTATUTO DE RENOVAO: " + mb.getMaritimo().getClasseRenovacao(), fontCorpo);
        Paragraph pInfo8 = new Paragraph("   8. BANDEIRA DO NAVIO: " + mb.getMaritimo().getBandeiraNavio(),
                fontCorpo);
        Paragraph pInfo9 = new Paragraph(
                "   9. USO A QUE SE DISTINA O NAVIO OU COMRCIO: " + mb.getMaritimo().getUsoNavio(),
                fontCorpo);
        Paragraph pInfo10 = new Paragraph("   10. QUANTIDADE/PESO DO " + mb.getMaritimo().getNomeNavio() + " : "
                + mb.getMaritimo().getPeso() + " (LIQUIDO E BRUTO):VER NO RELATRIO", fontCorpo);
        Paragraph pInfo11 = new Paragraph("   11. POTNCIA DO MOTOR", fontCorpo);
        Paragraph pInfo12 = new Paragraph(
                "   12. TIPO DE COMBUST?VEL DO MOTOR DE PROPULSAO: " + mb.getMaritimo().getTipoCombustivel(),
                fontCorpo);
        Paragraph pInfo13 = new Paragraph("   13. NMERO DO MOTOR: " + mb.getMaritimo().getNumMotor(),
                fontCorpo);
        Paragraph pInfo14 = new Paragraph("   14. MARCA DO MOTOR: " + mb.getMaritimo().getMarcaMotor(),
                fontCorpo);
        Paragraph pInfo15 = new Paragraph(
                "   15. NMERO M?XIMO DE TRIPULANTES: " + mb.getMaritimo().getNumMaximoTripulante(),
                fontCorpo);
        Paragraph pInfo16 = new Paragraph("   16. DISPOSITIVOS DE SALVAMENTO SUFICIENTE PARA UM M?XIMO: ",
                fontCorpo);
        Paragraph pInfo17 = new Paragraph("   17. APOIOS PARA NAVEGAO INSTALADOS: "
                + mb.getMaritimo().getEspecificacaoApoioNavegacao(), fontCorpo);
        Paragraph pInfo18 = new Paragraph(
                "   18. EXPERINCIA ANTERIOR DE RECLAMAO: " + mb.getMaritimo().getExperienciaRecalmacao(),
                fontCorpo);
        Paragraph pInfo19 = new Paragraph("   19. MBITO DA COBERTURA: ", fontCorpo);
        Paragraph pInfo20 = new Paragraph(
                "   20. LIMITAO TERRITORIAL/?REA DE OERAO: " + mb.getMaritimo().getAreaOperacao(),
                fontCorpo);
        Paragraph pInfo21 = new Paragraph("          DATA: " + sdf.format(new Date()), fontCorpo);
        cellDadosTitulo.addElement(pInfoTitulo);
        cellDadosTitulo.addElement(pInfoShip);
        cellDadosTitulo.addElement(pInfo1);
        cellDadosTitulo.addElement(pInfo2);
        cellDadosTitulo.addElement(pInfo3);
        cellDadosTitulo.addElement(pInfo4);
        cellDadosTitulo.addElement(pInfo5);
        cellDadosTitulo.addElement(pInfo6);
        cellDadosTitulo.addElement(pInfo7);
        cellDadosTitulo.addElement(pInfo8);
        cellDadosTitulo.addElement(pInfo9);
        cellDadosTitulo.addElement(pInfo10);
        cellDadosTitulo.addElement(pInfo11);
        cellDadosTitulo.addElement(pInfo12);
        cellDadosTitulo.addElement(pInfo13);
        cellDadosTitulo.addElement(pInfo14);
        cellDadosTitulo.addElement(pInfo15);
        cellDadosTitulo.addElement(pInfo16);
        cellDadosTitulo.addElement(pInfo17);
        cellDadosTitulo.addElement(pInfo18);
        cellDadosTitulo.addElement(pInfo19);
        cellDadosTitulo.addElement(pInfo20);
        cellDadosTitulo.addElement(pInfo21);
        pTableDadosTitulo.addCell(cellDadosTitulo);

        PdfPTable pTableAssinaturaTitulo = new PdfPTable(1);
        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });
        PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas".toUpperCase(), fontCorpoN));
        cellAssinatora.setBorder(0);
        cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha1 = new PdfPCell(
                new Phrase("____________________________________________".toUpperCase(), fontCorpo));
        celllinha1.setBorder(0);
        celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha2 = new PdfPCell(
                new Phrase("____________________________________________".toUpperCase(), fontCorpo));
        celllinha2.setBorder(0);
        celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell celllinha11 = new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP));
        celllinha11.setBorder(0);
        celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP));
        celllinha21.setBorder(0);
        celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER);

        pTableAssinaturaTitulo.addCell(cellAssinatora);
        pTableAssinatura.addCell(celllinha1);
        pTableAssinatura.addCell(celllinha2);
        pTableAssinatura.addCell(celllinha11);
        pTableAssinatura.addCell(celllinha21);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 35f, 5f);

        //            File ff= new File("Documentos\\"+user+"\\Seguro Maritimo\\");
        //            ff.mkdirs();
        //            ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Maritimo "+sdf1.format(new Date())+".pdf");
        File ff = new File(arquivo + "/" + user + "/Seguro Maritimo/");

        ff.mkdirs();
        String Ddata = sdf1.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Maritimo " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro Maritimo/" + "Formulario Seguro Maritimo " + Ddata
                + ".pdf";

        OutputStream outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        if (MarcaDAgua.isSimulation) {
            MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical();
            writer.setPageEvent(v);
        }

        if (MarcaDAgua.isCanceled) {
            MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical();
            writer.setPageEvent(v);
        }

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableTitulo);
        documento.add(pTableNull);
        documento.add(pTableCliente);
        documento.add(pTableNull);
        documento.add(pTableDadosTitulo);
        documento.add(pTableNull);
        documento.add(pTableSeguro);
        documento.add(pTableNull);
        documento.add(pTableAssinaturaTitulo);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableAssinatura);
        documento.close();

        //           PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); 
        //           //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); 
        //             
        //            printPdf.print();
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:eyeofthetiger.utils.PDFDossardGenerator.java

private Phrase createCleanPhrase(String txt1, float fontSize1, boolean bold1) {
    Phrase phrase = new Phrase(txt1);
    phrase.getFont().setSize(fontSize1);
    if (bold1) {//  w ww  .  j a v  a2 s.  c  o  m
        phrase.getFont().setStyle(Font.BOLD);
        phrase.setLeading(fontSize1);
    }

    return phrase;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Builds the page header - Title and Empty cell (for border)
 *
 * @return PdfPTable the itext table to add to the document
 *//*from w w w. j a v a 2s. c o m*/
public PdfPTable createHeaderTable() {

    PdfPTable table = new PdfPTable(2);
    table.setSpacingAfter(10);
    table.setWidthPercentage(100);

    Paragraph title = new Paragraph("Medical Record", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));
    PdfPCell cell = new PdfPCell(title);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    //Paragraph encounterId = new Paragraph("Encounter ID: " + patientEncounter.getId(), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
    cell = new PdfPCell(table.getDefaultCell());
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    return table;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Builds the Header Cell used for every section of the document
 *
 * @param title the title for the cell// w  ww.  j  a  v a  2s .  c  om
 * @param colspan the number of columns in the table it will be added to
 * @return a formatted PdfPCell ready to insert into a PdfPTable
 */
private PdfPCell getDefaultHeaderCell(String title, int colspan) {

    PdfPCell cell = new PdfPCell();
    Paragraph titleParagraph = new Paragraph(title,
            new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK));
    cell.addElement(titleParagraph);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setColspan(colspan);
    cell.setBorderColorBottom(BaseColor.DARK_GRAY);
    cell.setBorderWidthBottom(1);
    cell.setPaddingBottom(5);

    return cell;
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Most values are in the format//from   ww w.  j  a  va  2s.com
 *  title: value
 *
 *  This returns the font used for the title portion
 *
 * @return the Font used for Titles on the pdf
 */
private Font getTitleFont() {

    return new Font(Font.FontFamily.HELVETICA, 11, Font.BOLD, BaseColor.BLACK);
}

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void parseAndAddBodyTextLineToParagraph(Paragraph paragraph, String line, Font font) {
    // TODO add support for additional styles
    // TODO add better error checking and reporting
    Font currentFont = new Font(font);
    StringBuilder sb = new StringBuilder();
    for (char c : line.toCharArray()) {
        if (c == '*') {
            if (sb.length() > 0) {
                paragraph.add(new Phrase(sb.toString(), currentFont));
                sb = new StringBuilder();
            }//  w w  w. j a v  a  2  s.  co  m
            if (currentFont.isBold()) {
                currentFont = deriveWithStyle(currentFont, currentFont.getStyle() & ~Font.BOLD);
            } else {
                currentFont = deriveWithStyle(currentFont, currentFont.getStyle() | Font.BOLD);
            }
        } else if (c == '_') {
            if (sb.length() > 0) {
                paragraph.add(new Phrase(sb.toString(), currentFont));
                sb = new StringBuilder();
            }
            if (currentFont.isItalic()) {
                currentFont = deriveWithStyle(currentFont, currentFont.getStyle() & ~Font.ITALIC);
            } else {
                currentFont = deriveWithStyle(currentFont, currentFont.getStyle() | Font.ITALIC);
            }
        } else {
            sb.append(c);
        }
    }
    paragraph.add(new Phrase(sb.toString(), currentFont));
}