I am having vertical alignment issues when generating PDF documents. The data which is dynamic in format must fit on N sheets of 8.5X11. Each 33 lines of data must fit on the upper or lower 1/2 of the page with a perforation in the middle of the page. Will tables/cells help me achieve the proper vertical alignment I desire? I was considering a 1 column table and each 1/2 page of data could be a cell. I was hoping I could use absolute position on each cell ( 1/2 page).
Document document = new Document(PageSize.A4, 0, 0, 0, 0); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Font dataFont = new Font(Font.COURIER, 12); Font headerFont = new Font(Font.COURIER, 7); try { PdfWriter pdfWriter = PdfWriter.getInstance(document, baos); document.open(); PdfContentByte cb = pdfWriter.getDirectContent(); List<BPEVRPage> pages = STXMLGenerator.getRegDocument((STRegTransaction) getRegTransaction()); int formCount = 0; bpevrPage: for (BPEVRPage page:pages) { for (Form form:page.getFormsList()) { while (form.getLinesList().size() <33) { Line line = new Line(); LineSection lineSection = new LineSection(); lineSection.setLineSectionType(LineSection.DATA); lineSection.setLineSectionData(" "); line.addLineSection(lineSection); form.addLine(line); } if (formCount>=2 && formCount%2==0){ document.newPage(); logger.fine("ADDING NEW PAGE"); } for (Line line:form.getLinesList()) { Paragraph para = new Paragraph(); para.setLeading(0, 0.85f); para.setIndentationLeft(12f); para.setIndentationRight(12f); for (LineSection section:line.getLineSections()) { logger.fine("formCount "+ formCount+" line section data 1 header 2 "+section.getLineSectionType() + " " + section.getLineSectionData()); if (section.getLineSectionType()==LineSection.DATA) { if (STDocumentTypeFactory.CA_REGDOC_NODMVCOPY.equals(docType) && section.getLineSectionData().contains(DMV_FILE_COPY_TOKEN)) { break bpevrPage; } Phrase phrase = new Phrase(section.getLineSectionData(), dataFont); para.add(phrase); } else if (section.getLineSectionType()==LineSection.HEADER) { Phrase phrase = new Phrase(section.getLineSectionData(), headerFont); para.add(phrase); } else if (section.getLineSectionType()==LineSection.CUSTOMER_BARCODE) { // CODE 39 Paragraph paraCustomer = new Paragraph(); paraCustomer.setSpacingBefore(18); //set spacing prior bar code 1/4 inch paraCustomer.setSpacingAfter(0); paraCustomer.setIndentationLeft((float) 166); Barcode39 code39Customer = new Barcode39(); code39Customer.setBarHeight((float) 36); code39Customer.setSize((float) 4.75); code39Customer.setCode(section.getLineSectionData()); code39Customer.setAltText(""); // Image image = code39Customer.createImageWithBarcode(cb, null, null); // if (formCount%2==0) { // image.setAbsolutePosition(144f, 468f); //5.5 inches from bottom // } else { // image.setAbsolutePosition(144f, 720f); //10 inches from bottom // } // paraCustomer.add(image); paraCustomer.add(code39Customer.createImageWithBarcode(cb, null, null)); document.add(paraCustomer); } else if (section.getLineSectionType()==LineSection.DMV_BARCODE) { // CODE 39 Paragraph paraDMV = new Paragraph(); paraDMV.setSpacingAfter(0); paraDMV.setIndentationLeft((float) 144); Barcode39 code39DMV = new Barcode39(); code39DMV.setBarHeight((float) 36); code39DMV.setSize((float) 3.75); code39DMV.setCode(section.getLineSectionData()); code39DMV.setTextAlignment(Element.ALIGN_LEFT); // Image image = code39DMV.createImageWithBarcode(cb, null, null); // if (formCount%2==0) { // image.setAbsolutePosition(144f, 468f); //5.5 inches from bottom // } else { // image.setAbsolutePosition(144f, 720f); //10 inches from bottom // } // paraDMV.add(image); paraDMV.add(code39DMV.createImageWithBarcode(cb, null, null)); document.add(paraDMV); } }//line section document.add(para); }//line formCount++; }//form }//page document.close(); } catch (DocumentException e) { e.printStackTrace(); // } catch (FileNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); } return baos.toByteArray(); } -- View this message in context: http://itext.2136553.n4.nabble.com/Tables-for-vertical-alignment-tp4660877.html Sent from the iText mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php