如何在 PDFBOX 中绘制填充多边形?

How to draw a filled polygon in PDFBOX?

我想画一个填充的多边形。我查看了文档和方法:

fillPolygon(float[] x, float[] y)
Deprecated. 
Use moveTo(float, float) and lineTo(float, float) methods instead.

我找不到在 pdfbox 中填充多边形的替代方法。

源自 PDFBox 源代码:

public void fillPolygon(PDPageContentStream cs, float[] x, float[] y) throws IOException
{
    if (x.length != y.length)
    {
        throw new IllegalArgumentException("Error: some points are missing coordinate");
    }
    for (int i = 0; i < x.length; i++)
    {
        if (i == 0)
        {
            cs.moveTo(x[i], y[i]);
        }
        else
        {
            cs.lineTo(x[i], y[i]);
        }
    }
    cs.closePath();
    cs.fill();
}