You must close a path before starting the text. This is wrong:
moveTo lineTo beginText ... endText circle stroke This is right: beginText ... endText moveTo lineTo circle stroke This is also right: moveTo lineTo stroke beginText ... endText circle stroke ----- Original Message ----- From: "Serge LE HUITOUZE" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Tuesday, July 26, 2005 2:57 PM Subject: [iText-questions] pdfContentByte: endText vs. circle Hello there, I'm trying to produce graphical representations of some data together with accompanying text that is represented as mere paragraphs. My graphical representations involves axis and (String) labels on these axis. My inspiration for drawing labels was file "align2.java" in Paulo's examples, more precisely the code snippet below: BaseFont bf = BaseFont.createFont("Helvetica", "Cp1252", false); cb.beginText(); cb.setFontAndSize(bf, 12); String text = "Some text"; cb.showTextAligned(PdfContentByte.ALIGN_CENTER, text + " Center", 250, 700, 0); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, text + " Right", 250, 650, 0); cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text + " Left", 250, 600, 0); cb.endText(); The problem I run into is that an unreadable pdf is generated when I continue using the "cb" variable (e.g. calling "cb.circle()") AFTER I've called "cb.endText()". I get an error message when trying to load the pdf: "unexpected operation inside a path" (in french, "opération erronée à l'intérieur d'un chemin"). To be sure what was going on, I configured my data representation so as to print axis labels before or after drawing the circle, depending on the oddity of the parameter (very simplified source file is the attached "problem.java": the parameter-dependent behavior here is only the position of a circle). A correct pdf is attached as "noproblem.pdf" (parameters 12 and 34 at lines 75-76), an incorrect one is attached as "problem.pdf" (parameters 12 and 33). One may just say "Draw your darn circles before your labels!" ;-) But that would make my code *really* messy, since I have many different reasons to write texts/lines/circles into my PdfContentByte and delaying writing text to the very end would be a nightmare. So the question is: What can I do with a PdfContentByte after a call to "endText()"? Another question is: Is it reasonable to drop the call to "endText()" altogether ? --Serge <<problem.java>> <<noproblem.pdf>> <<problem.pdf>> ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
