PdfWriter.getInstance(doc, os); //associa a stream de saída ao
doc.open(); //abre o documento
Font fonte2 = new Font(FontFamily.HELVETICA, 24,Font.BOLD);
Font fonte = new Font(FontFamily.HELVETICA, 16,Font.BOLD);
Paragraph title = new Paragraph("Relatório iCards",fonte2); //adiciona o texto ao PDF
title.setAlignment(Element.ALIGN_CENTER);
title.setSpacingAfter(5);
Paragraph linha = new Paragraph("__________________________________________________",fonte);
doc.add(linha);
doc.add(title);
GerenciarDB banco = new GerenciarDB();
if (tipo==0) { //Usuario
String[][] mtx = banco.getExtratoUsuario(ID);
int i;
PdfPTable table = new PdfPTable(3);
Paragraph head = new Paragraph("Nome: "+banco.getUsername(ID) ,fonte);
head.setSpacingAfter(20);
doc.add(head);
for (i=(mtx[0].length)-1;i>=0;i--){
table.addCell(mtx[0][i]);
table.addCell(mtx[1][i]);
table.addCell(mtx[2][i]);
}
doc.add(table);
Paragraph fim = new Paragraph("Saldo total: R$ "+banco.getSaldoCartaoDB(ID) ,fonte);
doc.add(fim);
} else if (tipo==1) { //Estabelecimento
String[][] mtx = banco.getExtratoEst(ID);
int j;
PdfPTable table = new PdfPTable(2);
Paragraph head = new Paragraph("Nome: "+banco.getEstabelecimentoDB(ID) ,fonte);
head.setSpacingAfter(20);
doc.add(head);
for (j=(mtx[0].length)-1;j>=0;j--){
table.addCell(mtx[0][j]);
table.addCell(mtx[2][j]);
}
doc.add(table);
Paragraph fim = new Paragraph("Receita total: R$ "+banco.getVendaTotalEstabelecimentoDB(ID) ,fonte);
doc.add(fim);
} else {
System.out.println("Relatório não gerado");
}
doc.add(linha);