开发者

How to change line thickness in iText?

开发者 https://www.devze.com 2022-12-28 18:35 出处:网络
I\'m drawing images to pdf using Java framework iText. I need to draw lines of specified width. There is a method setLineWidth(float width) in class PdfContentByte that should change it. However no ma

I'm drawing images to pdf using Java framework iText. I need to draw lines of specified width. There is a method setLineWidth(float width) in class PdfContentByte that should change it. However no matter what value I pass as its parameter the lines drawn are always extra thin.

There is following line in javadoc of setLineWidth:

The line width specifies the thickness of the line used to stroke a path and is measured in user space units.

I don't know what is "space unit". Everything else in iText seems to be measured in point(around 1/72 inch). I cant find any reference to what are those "space units" and how to change them.

code:

to.setLineWidth(thickness);
to.moveTo(x, y);
to.lineTo(x + 100, y + 100开发者_高级运维);

Variable to contains instance of PdfContentByte.


Solved. There was no stroke method call after lineTo call. That's why it used another line width set just before stoke method was called. Correct code look like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号