> > -----Original Message----- > > From: Grzegorz Kucner [SMTP:[EMAIL PROTECTED] > > Sent: Friday, March 21, 2003 17:21 > > To: [EMAIL PROTECTED] > > Subject: [iText-questions] How to fit PdfPTable in a page ? > > > > ...... > > > > How to force PdfPTable to fit it in a single page? Is there there other > > why > > than using templates to shrink the table and fit into one page? > > > You can shrink a PdfPTable by applying a transformation. This only > works for precisely positioned tables. >
Hello again, I tried to handle it, but I still have some problems, when the table is added to document using document.add method everything looks fine table is in right position, but when I try to fit the table into single page the only this what I get is blank page. To fit my PdfPTable into single page I use following code: //.... here I have all thigs needed to prepare main document and table which I try to fit into a page //variables //main document - document //table to fit into a page - tableZ //main writer - writer //main PdfContentByte - cb float left = document.left(); float right = document.right(); float bottom = document.bottom(); float top = document.top(); ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); Document docPierwszaStrona = new Document(new com.lowagie.text.Rectangle(right - left, tableZ.getTotalHeight())); PdfWriter writer2 = PdfWriter.getInstance(docPierwszaStrona, baos2); docPierwszaStrona.open(); PdfContentByte cb2 = writer2.getDirectContent(); docPierwszaStrona.newPage(); tableZ.writeSelectedRows(0, -1, 100, 100, cb2); // I tried to used this method instead of tableZ.writeSelectedRows, but this still produce only a blank page // docPierwszaStrona.add(tableZ); docPierwszaStrona.close(); PdfReader reader = new PdfReader(baos2.toByteArray()); PdfImportedPage templatePierwszaStrona = writer.getImportedPage(reader, 1); //shrink the table if (tableZ.getTotalHeight() > top - bottom) { float skala = top - bottom / tableZ.getTotalHeight(); // cb.addTemplate(templatePierwszaStrona, skala, 0, 0, skala, left, top); cb.addTemplate(templatePierwszaStrona, left, top); } //just print table else { cb.addTemplate(templatePierwszaStrona, left, top); } Why the only output I get is a blank page? best regards, Grzegorz Kucner ------------------------------------------------------- This SF.net email is sponsored by: eBay Get office equipment for less on eBay! http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions