Re: [iText-questions] Problem adding ColumnText onto existing Document
On 1/4/11 11:58 AM, 1T3XT BVBA wrote: >> I'm fishing here :( > OK, my first guess was wrong, but now I see something else that is fishy: > you're nesting text blocks! > You have a BT (beginText()) and an ET (endText()). > In between, you add another BT and ET by using ColumnText. > You shouldn't do that! > > Replace ALL your beginText(), setFontAndSize(), showTextAligned(), > endText() sequences, > by one single ColumnText.showTextAligned() and your problem will be solved. I just wanted to followup and say yes, this fixed it! What I didn't realize was the ColumnText was implicitely doing a beginText() and endText(). I changed all my showTextAligned with static calls to ColumnText.showTextAligned, and left most of hte 'block' section (because I need wrapped text for long names), and things are working perfectly. Thank you very much for your help! Here is the final / complete method, which still has the 'dotted line' around the block area, but that's just for testing, we'll remove that in the production print routine :) http://pastebin.stonekeep.com/11529 -d -- Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions 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
Re: [iText-questions] Problem adding ColumnText onto existing Document
On 1/4/11 4:01 AM, 1T3XT BVBA wrote: > Op 4/01/2011 6:18, Dave Shevett schreef: >> 1) I create PdfContentByte 'cb' on a Document > This is not consistent with the way I interpret your requirement. > I assumed that you were talking about an EXISTING FORM. > Now I see that you create PdfContentByte on a Document object. > This is strange for two reasons: > - Document is only used when you create a PDF from scratch; I am creating a PDF from scratch - the image is the resulting badge, which is sent to the printer. > - if you create a PDF from scratch, you get a PdfContentByte from a > PdfWriter object, not from a Document object. I do this - the full code of the print routine is now here: http://pastebin.stonekeep.com/11528 >> 2) Using lines like this, I place 'badge rows' (br) where i want them: > I don't understand why you are using this approach. > Why aren't you using a real interactive form? This is an automated print routine for convention badges. It is being run in the background as a "format and print" routine coming from database data. > Why are you using cb.showTextAligned(), it's easier to use > ct.showTextAligned(). Can ct.showTextAligned do absolute positioning? >> If this code executes, all OTHER fields on the document disappear, and I >> end up with just a few characters of the field, with the X through it, >> and nothing else on the document. >> >> What am I doing wrong? > Hard to tell: you only provide part of the code, NOT the code that matters. > Please write a small example that we can run in standalone mode. > Also show us the original PDF: is it a form? > You are using PdfStamper, aren't you? If not: please read the documentation. I'm not using pdfstamper because I'm creating the entire document programmatically from scratch. Thanks again! -d -- Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions 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
[iText-questions] Problem adding ColumnText onto existing Document
Hi folks - i have a set of code that uses iText to place fields on a form (in fact, it's a badge for a convention). The fields are laying out in absolute positions on the document, but I want to add a block that wraps text within the block (for a long badge name, for example). The entire codeblock is posted here: http://pastebin.stonekeep.com/11527 The boiled down version is this: 1) I create PdfContentByte 'cb' on a Document 2) Using lines like this, I place 'badge rows' (br) where i want them: cb.showTextAligned(PdfContentByte.ALIGN_LEFT,printElement,br.getPosx(),br.getPosy(),0); I have a cb.beginText(); and a cb.endText() around the entire logic. This all works great until I try and place a 'block' item, which uses this code: logger.debug("Printing field " + fname + " using block layouts."); // This first block simpley draws an 'X' across the field area I want to use. This renders fine... cb.setLineDash(6, 0); cb.setLineWidth(1); cb.moveTo(br.getPosx() - (br.getWidth() / 2),br.getPosy() - (br.getHeight() / 2)); cb.lineTo(br.getPosx() + (br.getWidth() / 2),br.getPosy() + (br.getHeight() / 2)); cb.moveTo(br.getPosx() + (br.getWidth() / 2),br.getPosy() - (br.getHeight() / 2)); cb.lineTo(br.getPosx() - (br.getWidth() / 2),br.getPosy() + (br.getHeight() / 2)); cb.stroke(); Font btFont = new Font(bf,br.getFontSize(),Font.NORMAL); Phrase blockText = new Phrase(15,printElement,btFont); ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(br.getPosx()-(br.getWidth() / 2), br.getPosy()-(br.getHeight() / 2), br.getPosx()+(br.getWidth() / 2), br.getPosy()+(br.getHeight() / 2), 19, Element.ALIGN_CENTER); ct.addText(blockText); ct.go(); If this code executes, all OTHER fields on the document disappear, and I end up with just a few characters of the field, with the X through it, and nothing else on the document. What am I doing wrong? Thanks... -dave -- Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions 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