E aí pessoal…tudo certo?
O negócio é o seguinte:
Tenho um sistema aqui que gera um pdf com uma tabela. Mas como esta tabela é muito grande, está gerando a tabela em três páginas. Uma parte da tabela em cada página. Pensei em gerar o pdf na horizontal, tipo paisagem…Como eu poderia estar fazendo isso?
private Document preencheMatriz(Document document, Integer size) throws DocumentException{
Table t = new Table(9,size);
t.setWidth(100f);
t.setAlignment(Element.ALIGN_JUSTIFIED);
/* float[] tams = {1.2f,1f,1.4f,0.8f,1f,1f,0.6f,1f,1f};
t.setWidths(tams);*/
t = preencheCabecalho(t, 1);
//PREENCHE CONTEUDO
t = preencheConteudo(t, 1, size);
document.add(t);
document.newPage();
Table t2 = new Table(8,size);
t2.setWidth(100f);
t2.setAlignment(Element.ALIGN_JUSTIFIED);
/*float[] tams2 = {1.4f,0.7f,0.9f,1f,0.9f,1f,0.8f,1.3f,1f,1f};
t2.setWidths(tams2);*/
t2 = preencheCabecalho(t2, 2);
//PREENCHE CONTEUDO
t2 = preencheConteudo(t2, 2, size);
document.add(t2);
document.newPage();
Table t3 = new Table(8,size);
t3.setWidth(100f);
t3.setAlignment(Element.ALIGN_JUSTIFIED);
/*float[] tams2 = {1.4f,0.7f,0.9f,1f,0.9f,1f,0.8f,1.3f,1f,1f};
t3.setWidths(tams2);*/
t3 = preencheCabecalho(t3, 3);
//PREENCHE CONTEUDO
t3 = preencheConteudo(t3, 3, size);
document.add(t3);
return document;
}
private Table preencheCabecalho(Table t, int i) throws BadElementException{
if (i == 1){
//CABECALHO DA TABELA 1
Cell c1 = new Cell(new Paragraph("Regional", new RtfFont("Arial", 12, RtfFont.BOLD)));
c1.setHeader(true);
t.addCell(c1);
c1 = new Cell(new Paragraph("Região", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Projeto", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Lote", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Talhão", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Dens QQ", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Área QQ", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Dens C1", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
c1 = new Cell(new Paragraph("Área C1", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c1);
t.endHeaders();
//FIM CABECALHO TABELA
}
if (i == 2){
//CABECALHO DA TABELA 2
Cell c2 = new Cell(new Paragraph("Dens C2", new RtfFont("Arial", 12, RtfFont.BOLD)));
c2.setHeader(true);
t.addCell(c2);
c2 = new Cell(new Paragraph("Área C2", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
c2 = new Cell(new Paragraph("Dens C3", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
c2 = new Cell(new Paragraph("Área C3", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
c2 = new Cell(new Paragraph("Dens C4", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
c2 = new Cell(new Paragraph("Área C4", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
c2 = new Cell(new Paragraph("Dens C5", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
c2 = new Cell(new Paragraph("Área C5", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c2);
t.endHeaders();
//FIM CABECALHO TABELA
}
if (i == 3){
//CABECALHO DA TABELA 3
Cell c3 = new Cell(new Paragraph("Dens C6", new RtfFont("Arial", 12, RtfFont.BOLD)));
c3.setHeader(true);
t.addCell(c3);
c3 = new Cell(new Paragraph("Área C6", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
c3 = new Cell(new Paragraph("Dens C7", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
c3 = new Cell(new Paragraph("Área C7", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
c3 = new Cell(new Paragraph("DT", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
c3 = new Cell(new Paragraph("AT", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
c3 = new Cell(new Paragraph("LM", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
c3 = new Cell(new Paragraph("CV", new RtfFont("Arial", 12, RtfFont.BOLD)));
t.addCell(c3);
t.endHeaders();
//FIM CABECALHO TABELA
}
return t;
}
Perceba que o código está separando 3 páginas…queria montar a tabela toda em uma página só.
Se alguém tiver uma idéia, por favor me ajude…
OBRIGADO!