iText PDF矩形填充颜色 [英] iText PDF Rectangle fill with color
本文介绍了iText PDF矩形填充颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用颜色填充矩形.我使用了这些代码,但是没有用.
I want to fill rectangle with color. I used these code but not working.
PdfContentByte canvas = writer.getDirectContent();
canvas.rectangle(50, 600, 500, 40);
canvas.setColorFill(BaseColor.GRAY);
//canvas.setRGBColorFill(20, 50, 30);
//canvas.setCMYKColorFill(0, 0, 0, 75);
canvas.setColorStroke(BaseColor.LIGHT_GRAY);
canvas.stroke();
任何人都知道如何填充它吗?
Anyone has idea how to fill it ?
推荐答案
您必须在setColorFill()之后调用canvas.fill()
You have to call canvas.fill() after setColorFill()
PdfContentByte canvas = writer.getDirectContent();
canvas.rectangle(50, 600, 500, 40);
canvas.setColorFill(BaseColor.GRAY);
canvas.fill();
这篇关于iText PDF矩形填充颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文