Paragraph has leading. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Przemek Klein > Sent: Friday, March 11, 2005 11:38 AM > To: [email protected] > Subject: [iText-questions] Re: wrong element placement? > > Thank You, but can You tell me WHY? I mean what is the rule; > do I have to enclose anything in Paragraph? Both Paragraph > and Chunk classes implement Element interface, and > Document.add requires instance of Element so both of them should work. > > Przemek > > On Fri, 11 Mar 2005 11:29:32 -0000 > "Paulo Soares" <[EMAIL PROTECTED]> wrote: > > > Use pdfDoc.add(new Paragraph(theChunk)) instead of > pdfDoc.add(theChunk). > > > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On > > > Behalf Of Przemek Klein > > > Sent: Friday, March 11, 2005 10:57 AM > > > To: [email protected] > > > Subject: [iText-questions] wrong element placement? > > > > > > Hi All. > > > > > > My PDF document consists of: > > > 1. page header > > > 2. table with 100 rows > > > 3. text (chunk) > > > > > > Every element is added using Document.add(Element) method. > > > In generated document text appears over last table row > > > instead of under the table. > > > > > > Below is a code I use do generate PDF. > > > > > > Thanks in advance, > > > Przemek > > > > > > > > > > > > /* > > > * Created on 2005-03-10 > > > */ > > > > > > import java.awt.Color; > > > import java.awt.geom.AffineTransform; > > > import java.io.FileOutputStream; > > > import java.io.IOException; > > > > > > import com.lowagie.text.Chunk; > > > import com.lowagie.text.Document; > > > import com.lowagie.text.DocumentException; > > > import com.lowagie.text.Font; > > > import com.lowagie.text.FontFactory; > > > import com.lowagie.text.PageSize; > > > import com.lowagie.text.Phrase; > > > import com.lowagie.text.Rectangle; > > > import com.lowagie.text.pdf.BarcodeEAN; > > > import com.lowagie.text.pdf.PdfContentByte; > > > import com.lowagie.text.pdf.PdfPCell; > > > import com.lowagie.text.pdf.PdfPTable; > > > import com.lowagie.text.pdf.PdfPageEventHelper; > > > import com.lowagie.text.pdf.PdfWriter; > > > > > > /** > > > * Writing a PdfPTable at an absolute position. > > > */ > > > public final class ItextTest extends PdfPageEventHelper{ > > > > > > private ItextTest() { > > > } > > > > > > public static void main(String[] args) throws > > > DocumentException, IOException { > > > > > > Document pdfDoc = new Document(PageSize.A4, 10, > 10, 70, 10); > > > > > > FileOutputStream fos = new FileOutputStream("sample.pdf"); > > > PdfWriter writer = PdfWriter.getInstance(pdfDoc, fos); > > > writer.setPageEvent(new ItextTest()); > > > pdfDoc.open(); > > > > > > PdfPTable t1 = new PdfPTable(2); > > > for (int i = 0; i < 100; i++) { > > > PdfPCell c1 = new PdfPCell(new Phrase(i + ".")); > > > c1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); > > > PdfPCell c2 = new PdfPCell(new Phrase("")); > > > t1.addCell(c1); > > > t1.addCell(c2); > > > } > > > pdfDoc.add(t1); > > > > > > Chunk theChunk = new Chunk("niby pogrubiony", > > > FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); > > > theChunk.setUnderline(1, 0); > > > pdfDoc.add(theChunk); > > > pdfDoc.close(); > > > > > > System.out.println("Done."); > > > } > > > > > > public void onStartPage(PdfWriter writer, Document document) { > > > Rectangle page = document.getPageSize(); > > > PdfPTable t = new PdfPTable(1); > > > PdfPCell defaultCell=t.getDefaultCell(); > > > defaultCell.disableBorderSide(PdfPCell.LEFT); > > > defaultCell.disableBorderSide(PdfPCell.RIGHT); > > > defaultCell.disableBorderSide(PdfPCell.TOP); > > > > > > t.setTotalWidth(page.width() - document.leftMargin() > > > - document.rightMargin()); > > > t.addCell("xyz"); > > > t.writeSelectedRows(0, -1, document.leftMargin(), > > > page.height() - document.topMargin() + t.getTotalHeight()+10, > > > writer.getDirectContent()); > > > > > > } > > > > > > } > > > > > > > > > > > > ------------------------------------------------------- > > > 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_ide95&alloc_id396&op=click > > > > ------------------------------------------------------- > 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_ide95&alloc_id396&op=ick > _______________________________________________ > 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_ide95&alloc_id396&op=click _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
