Hi,

I am using the PdfGraphics2D to print a rather complex UI to a PDF using
iText. I got a problem where rectangles changed their thickness
intermittently. After hours of debugging I found the reason for the change:
Before that I printed a underline string using this code:

AttributedString as = new AttributedString (textToPrint);
as.addAttribute (TextAttribute.FONT, font);
if (isUnderlined)
{
    as.addAttribute (TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
}
pdfGraphics.drawString (as.getIterator (), left, (float) top);

This lead me to debugging the PdfGraphics2D class where I found the
following codeblock:

476             if(underline)
477             {
478                 // These two are supposed to be taken from the .AFM file
479                 //int UnderlinePosition = -100;
480                 int UnderlineThickness = 50;
481                 //
482                 double d = asPoints((double)UnderlineThickness,
(int)fontSize);
483                 setStroke(new BasicStroke((float)d));
484                 y = (float)((double)(y) +
asPoints((double)(UnderlineThickness), (int)fontSize));
485                 Line2D line = new Line2D.Double((double)x, (double)y,
(double)(width+x), (double)y);
486                 draw(line);
487             }

The problem is the setting of the stroke in line 483 without preserving the
current stroke. The fix should be to set the original stroke back after the
draw in line 486 ( make a call to setStroke(oldStroke); in line 487).

Let me know what you think.


Christoph Wagner


PS. And many thanks for the work on this great piece of open source software



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to