Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get line thickness less than 1 with PDFBox

Tags:

java

pdf

pdfbox

I have been trying to draw a thin horizontal line with PDFBox, but it appears that there is a limit for how thin I can draw the line. If I use a value less than one for the line thickness it looks the same as when I provide one for the value. Is this a limitation with PDFBox, or do I need to do something different?

// This looks the same as providing 1 for setLineWidth()
contentStream.setLineWidth(0.5f);
contentStream.setStrokingColor(Color.BLACK);
contentStream.moveTo(40f, 30f);
contentStream.lineTo(570f, 30f);
contentStream.closeAndStroke();
like image 733
chriaass Avatar asked Dec 30 '25 01:12

chriaass


1 Answers

A simple stroke call worked for me.

contentStream.setLineWidth(0.5f);
contentStream.moveTo(40f, 30f);
contentStream.lineTo(570f, 30f);
contentStream.stroke();

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!