简体   繁体   中英

Change line Separator color using iText7

I want to change the line Separator using iText7 but did not know how to use line.setColor(Color.RED); from the example here.

SolidLine line = new SolidLine(1f);
line.setColor(Color.RED);
LineSeparator ls = new LineSeparator(line);

You can try the following code using which one should be able to set any color on SolidLine.

PdfDocument pdf = new PdfDocument(new
PdfWriter("src/main/resources/test/output.pdf"));
Document document = new Document(pdf);
SolidLine line = new SolidLine(1f);
line.setColor(ColorConstants.BLUE);
LineSeparator ls = new LineSeparator(line);
ls.setWidth(UnitValue.createPercentValue(50));
ls.setMarginTop(5);
document.add(ls);
document.add(new Paragraph(" test document pdf..."));
document.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM