How to change the line thickness in iText?

I am drawing pdf images using the iText Java framework. I need to draw lines of the specified width. There is a method setLineWidth(float width)in the class PdfContentBytethat should change it. However, no matter what value I pass as my parameter, the lines drawn are always redundant.

In javadoc from setLineWidththere is the following line:

The line width determines the thickness of the line used to move along the path, and is measured in units of user space.

I do not know what a "space unit" is. Everything else in iText seems to be measured at a point (about 1/72 of an inch). I cannot find a link to what "space units" are and how to change them.

the code:

to.setLineWidth(thickness);
to.moveTo(x, y);
to.lineTo(x + 100, y + 100);

The variable tocontains an instance PdfContentByte.

+5
source share
1 answer

solved. After the line was called, there was no call to the hit method. That is why he used a different line width set immediately before calling the stoke method. The correct code is as follows:

to.setLineWidth(thickness);
to.moveTo(x, y);
to.lineTo(x + 100, y + 100);
to.stroke();
+9
source

All Articles