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>>
problem.java
Description: problem.java
noproblem.pdf
Description: noproblem.pdf
problem.pdf
Description: problem.pdf
