Package br.com.caelum.stella.boleto.example

Source Code of br.com.caelum.stella.boleto.example.BoletoExample

package br.com.caelum.stella.boleto.example;

import br.com.caelum.stella.boleto.Banco;
import br.com.caelum.stella.boleto.Boleto;
import br.com.caelum.stella.boleto.Datas;
import br.com.caelum.stella.boleto.Emissor;
import br.com.caelum.stella.boleto.Sacado;
import br.com.caelum.stella.boleto.bancos.BancoDoBrasil;
import br.com.caelum.stella.boleto.transformer.BoletoGenerator;

public class BoletoExample {
  public static void main(String[] args) {
    Datas datas = Datas.newDatas().withDocumento(1, 5, 2008)
        .withProcessamento(1, 5, 2008).withVencimento(2, 5, 2008);

    Emissor emissor = Emissor.newEmissor().withCedente("Fulano de Tal")
        .withAgencia("2345").withDvAgencia("6").withContaCorrente(
            "12345").withNumConvenio("1234567").withDvContaCorrete(
            "1").withCarteira("22").withNossoNumero("0009050987");

    Sacado sacado = Sacado.newSacado().withNome("Fulano da Silva").withCpf(
        "111.222.333-12").withEndereco("Av dos testes, 111 apto 333")
        .withBairro("Bairro Teste").withCep("01234-111").withCidade(
            "São Paulo").withUf("SP");

    Banco banco = new BancoDoBrasil();

    Boleto boleto = Boleto.newBoleto().withBanco(banco).withDatas(datas)
        .withDescricoes("descricao 1", "descricao 2", "descricao 3",
            "descricao 4", "descricao 5").withEmissor(emissor)
        .withSacado(sacado).withValorBoleto("200.00").withNoDocumento(
            "1234").withInstrucoes("instrucao 1", "instrucao 2",
            "instrucao 3", "instrucao 4", "instrucao 5")
        .withLocaisDePagamento("local 1", "local 2").withNoDocumento(
            "4343");

    BoletoGenerator gerador = new BoletoGenerator(boleto);

    // Para gerar um boleto em PDF
    gerador.toPDF("teste.pdf");

    // Para gerar um boleto em PNG
    gerador.toPNG("teste.png");

    // Para gerar um array de bytes a partir de um PDF
    byte[] bPDF = gerador.toPDF();

    // Para gerar um array de bytes a partir de um PNG
    byte[] bPNG = gerador.toPNG();
  }
}
TOP

Related Classes of br.com.caelum.stella.boleto.example.BoletoExample

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.