You can't use document.add() and PdfContentByte. Maybe you can get away with PdfWriter.getVerticalPosition().
----- Original Message ----- From: "Aloizio Pereira da Silva" <[EMAIL PROTECTED]> To: "Paulo Soares" <[EMAIL PROTECTED]> Cc: <[email protected]> Sent: Tuesday, March 15, 2005 7:45 PM Subject: Re: [iText-questions] iText + shift Object > I am not doing all wrong. I have already used PdfPTable and the problem > was the same. The table grew in the x,y position and the another component > remained in the same position. It did not shift. > > ***************************************************** > * Federal University of Minas Gerais * > * Department of Computer Science * > * Master Degree in Computer Science * > * * > * Aloizio Silva * > * http://www.dcc.ufmg.br/~aloizio * > * * > * Mobile Computer and Network Optimization * > ***************************************************** > > On Tue, 15 Mar 2005, Paulo Soares wrote: > > > You are doing it all wrong. You must place everything at absolute positions > > using PdfPTable. > > > > ----- Original Message ----- > > From: "Aloizio Pereira da Silva" <[EMAIL PROTECTED]> > > To: "Paulo Soares" <[EMAIL PROTECTED]> > > Cc: <[email protected]> > > Sent: Tuesday, March 15, 2005 6:16 PM > > Subject: RE: [iText-questions] iText + shift Object > > > > > > > public void gerarPDFItext() > > > { > > > // step 1: creation of a document-object > > > Document document = new Document(PageSize.A4, 50, 50, 50, 50); > > > try > > > { > > > // step 2: > > > // we create a writer that listens to the document > > > // and directs a PDF-stream to a file > > > Object valorRequerido = null; > > > Font small_font = new Font(Font.HELVETICA,8); > > > //PdfPTable aTable = null; > > > Table aTable = null; > > > PdfWriter writer = PdfWriter.getInstance(document, new > > > FileOutputStream("XandY.pdf")); > > > //DocWriter writer = RtfWriter.getInstance(document, new > > > FileOutputStream("XandY.rtf")); > > > > > > document.addAuthor("Aloizio P. Silva"); > > > document.addSubject("Gerao de Relatrios Dinmico SIL-RI."); > > > // we define a header and a footer > > > HeaderFooter header = new > > > HeaderFooter(new Phrase("Gerao de Relatrios Dinmico SIL-RI "+ > > > " Synergia DCC-UFMG"), false); > > > HeaderFooter footer = > > > new HeaderFooter(new Phrase("SIL-RI 2005"), new Phrase(".")); > > > footer.setAlignment(Element.ALIGN_CENTER); > > > document.setHeader(header); > > > document.setFooter(footer); > > > // step 3: we open the document > > > document.open(); > > > // step 4: > > > PdfContentByte cb = writer.getDirectContent(); > > > // we create a PdfTemplate > > > //PdfTemplate template = cb.createTemplate(25, 25); > > > > > > BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, > > > BaseFont.CP1252, BaseFont.NOT_EMBEDDED); > > > cb.beginText(); > > > cb.setFontAndSize(bf, 11); > > > Component[] componentes = areaCorrente.getComponents(); > > > int linha = 0; > > > for(int i = 0; i < componentes.length; i++) > > > { > > > ComponenteRelatorio oComponente = > > > (ComponenteRelatorio)componentes[i]; > > > > > > float pontoX = (float)(oComponente.getX()* 1.49) + 75; > > > System.out.println("pontoX: "+pontoX); > > > > > > float pontoY = 842 - (float)(oComponente.getY()* 2.105) - > > > 50; > > > System.out.println("pontoY: "+oComponente.getText()+ > > > pontoY); > > > > > > if(oComponente.obterValor() instanceof Collection) > > > { > > > Collection valores = (Collection) > > > oComponente.obterValor(); > > > Iterator j = valores.iterator(); > > > while (j.hasNext()) > > > { > > > Object obj = (Object) j.next(); > > > java.lang.reflect.Field[] f = obj.getClass(). > > > getDeclaredFields(); > > > int numColunas = f.length; > > > aTable = new Table(numColunas); > > > document.newPage(); > > > //aTable = new PdfPTable(numColunas); > > > aTable.setAutoFillEmptyCells(true); > > > for (int k = 0; k < numColunas; k++) > > > { > > > f[k].setAccessible(true); > > > String nomeColuna = f[k].getName(); > > > aTable.addCell(new Phrase(nomeColuna,small_font),new > > > Point(linha,k)); > > > //aTable.addCell(new Phrase(nomeColuna,small_font)); > > > } > > > linha++; > > > for (int x = 0; x < numColunas; x++) > > > { > > > valorRequerido = f[x].get(obj); > > > aTable.addCell(new > > > Phrase(valorRequerido.toString(),small_font), new Point(linha,x)); > > > //aTable.addCell(new > > > Phrase(valorRequerido.toString(),small_font)); > > > } > > > } > > > document.add(aTable); > > > document.newPage(); > > > } > > > else > > > { > > > cb.showTextAligned(PdfContentByte.ALIGN_CENTER, > > > > > > oComponente.getText(),pontoX,pontoY,0); > > > } > > > //aTable.setTotalWidth(500f); > > > //aTable.writeSelectedRows(0, -1,pontoX , pontoY, cb); > > > } > > > cb.endText(); > > > } catch (DocumentException de) { > > > System.err.println(de.getMessage()); > > > } catch (IOException ioe) { > > > System.err.println(ioe.getMessage()); > > > } > > > catch (IllegalAccessException ex) > > > { > > > ex.printStackTrace(); > > > } > > > catch (IllegalArgumentException ex) > > > { > > > ex.printStackTrace(); > > > } > > > catch (SecurityException ex) > > > { > > > ex.printStackTrace(); > > > } > > > // step 5: we close the document > > > document.close(); > > > File pdfFile = new File("XandY.pdf"); > > > VisualizarArquivoPDF(pdfFile); > > > } > > > > > > ***************************************************** > > > * Federal University of Minas Gerais * > > > * Department of Computer Science * > > > * Master Degree in Computer Science * > > > * * > > > * Aloizio Silva * > > > * http://www.dcc.ufmg.br/~aloizio * > > > * * > > > * Mobile Computer and Network Optimization * > > > ***************************************************** > > > > > > On Tue, 15 Mar 2005, Paulo Soares wrote: > > > > > > > Showing some code would help. > > > > > > > > > -----Original Message----- > > > > > From: [EMAIL PROTECTED] > > > > > [mailto:[EMAIL PROTECTED] On > > > > > Behalf Of Aloizio Pereira da Silva > > > > > Sent: Tuesday, March 15, 2005 5:08 PM > > > > > To: [email protected] > > > > > Subject: [iText-questions] iText + shift Object > > > > > > > > > > > > > > > I am working with iText to generate PDF files. The PDF file > > > > > is generated > > > > > with some object in x,y coordinates. but suppose that a have > > > > > a table in > > > > > (1,3) e I have a label in (2,3). The table grows until (4,3). > > > > > How I can > > > > > shift the label to (6,3) point? The table size is dynamic and > > > > > any object > > > > > below of it should be shifted to down automatically. > > > > > > > > > > My problem is that the label does not shift. It remains in > > > > > the same place. > > > > > > > > > > Could someone help me? > > > > > > > > > > ***************************************************** > > > > > * Federal University of Minas Gerais * > > > > > * Department of Computer Science * > > > > > * Master Degree in Computer Science * > > > > > * * > > > > > * Aloizio Silva * > > > > > * http://www.dcc.ufmg.br/~aloizio * > > > > > * * > > > > > * Mobile Computer and Network Optimization * > > > > > ***************************************************** > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > SF email is sponsored by - The IT Product Guide > > > > > Read honest & candid reviews on hundreds of IT Products from > > > > > real users. > > > > > Discover which products truly live up to the hype. Start reading now. > > > > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > > > > _______________________________________________ > > > > > iText-questions mailing list > > > > > [EMAIL PROTECTED] > > > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > _______________________________________________ > > iText-questions mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
