iText 7:没有边框也没有背景(透明)的图像字段(按钮)
iText 7 : image field (button) without border nor background (transparent)
我正在按照 this example 设置带有图像(PNG 文件)的按钮图标的值。
它工作正常,只是我找不到如何设置没有边框或背景的图像。我试着玩 setStrokeColor
和 setFillColor
但没有成功。
在那个特定的例子中,可以简单地删除用于添加背景和边框的代码:
canvas.
saveState().
setStrokeColor(modelButton.getBorderColor()).
setLineWidth(1).
rectangle(0, 0, occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getHeight()).
stroke().
setFillColor(modelButton.buttonBackgroundColor).
rectangle(0.5f, 0.5f, occupiedArea.getBBox().getWidth() - 1, occupiedArea.getBBox().getHeight() - 1).
fill().
restoreState();
请评论该行。我还将使用过的 jpg 图像更改为 png 图像,这就是我得到的结果:
我正在按照 this example 设置带有图像(PNG 文件)的按钮图标的值。
它工作正常,只是我找不到如何设置没有边框或背景的图像。我试着玩 setStrokeColor
和 setFillColor
但没有成功。
在那个特定的例子中,可以简单地删除用于添加背景和边框的代码:
canvas.
saveState().
setStrokeColor(modelButton.getBorderColor()).
setLineWidth(1).
rectangle(0, 0, occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getHeight()).
stroke().
setFillColor(modelButton.buttonBackgroundColor).
rectangle(0.5f, 0.5f, occupiedArea.getBBox().getWidth() - 1, occupiedArea.getBBox().getHeight() - 1).
fill().
restoreState();
请评论该行。我还将使用过的 jpg 图像更改为 png 图像,这就是我得到的结果: