Colors pdfbox表格标题着色工作不正常

Colors pdfbox表格标题着色工作不正常,colors,pdfbox,Colors,Pdfbox,我正在使用pdfbox并尝试给表格的标题上色;我使用教程“”正确绘制了表格 代码如下所示 //draw the rows float nexty = y ; for (int i = 0; i <= rows; i++) { contentStream.drawLine(margin, nexty, margin+tableWidth, nexty); nexty-= rowHeight; } //draw the

我正在使用pdfbox并尝试给表格的标题上色;我使用教程“”正确绘制了表格

代码如下所示

    //draw the rows
    float nexty = y ;
    for (int i = 0; i <= rows; i++) {
        contentStream.drawLine(margin, nexty, margin+tableWidth, nexty);
        nexty-= rowHeight;
    }

    //draw the columns
    float nextx = margin;
    for (int i = 0; i <= cols; i++) {
        contentStream.drawLine(nextx, y, nextx, y-tableHeight);
        nextx += (colWidths != null) ? colWidths[i] : colWidth;
    }

我试着把它放进去,但它没有按需要工作。我只需要给桌面上色。我怎样才能做到这一点。请帮帮我。

你能解释一下“但它没有按需要工作”是什么意思吗?@Tilmahauser我得到了解决方案,我用图片填充了标题,所以问题解决了,谢谢你的帮助朋友
contentStream.setNonStrokingColor( Color.RED );
contentStream.fillRect( 10, 10, 100, 100 );