user3648066
user3648066

Reputation: 31

PDFBox change color of a line

I work with pdfbox 1.8.5 and I try to draw a colored Line using PDPageContentStream.drawLine().

I tried it with PDPageContentStream.setNonStrokingColor( 255, 0, 0 ); but it doesn't work. I also didn´t find any examples or HowTos concerning Line Color.

Does anyone know, how I can change the Line Color?

Upvotes: 3

Views: 7627

Answers (2)

JonWritesCode
JonWritesCode

Reputation: 1

For PDFBox 2.x you'll need to use contentStream.stroke() in place of contentStream.drawLine().

Example:

contentStream.moveTo(xStart, yStart);
contentStream.lineTo(xEnd, yEnd);
contentStream.stroke();

You can also set the stroke color using the setStrokingColor method.

Upvotes: 0

Chintan Khetiya
Chintan Khetiya

Reputation: 16142

Try this method. It's working for me.

contentStream.setStrokingColor(229, 13, 209);

Upvotes: 3

Related Questions