Java PDPageContentStream没有drawLine()方法
所以我刚开始在我的一个项目中使用ApachePDFBox(0.7.3)来编写PDF。我想在整个页面上画一条线,根据我所看到的示例,我应该能够通过从PDPageContentStream调用drawLine()方法来做到这一点。然而,在Eclipse中,我只看到两个drawImage方法和一个drawString方法。有人知道我该怎么做才能解决这个问题吗?drawLine方法是被弃用了还是怎么了?在我看来: 因此,您的PDFBox副本已经过时,或者您的eclipse没有显示现有的方法 我在这里使用EclipseKepler,看到了正确的方法Java PDPageContentStream没有drawLine()方法,java,eclipse,pdfbox,Java,Eclipse,Pdfbox,所以我刚开始在我的一个项目中使用ApachePDFBox(0.7.3)来编写PDF。我想在整个页面上画一条线,根据我所看到的示例,我应该能够通过从PDPageContentStream调用drawLine()方法来做到这一点。然而,在Eclipse中,我只看到两个drawImage方法和一个drawString方法。有人知道我该怎么做才能解决这个问题吗?drawLine方法是被弃用了还是怎么了?在我看来: 因此,您的PDFBox副本已经过时,或者您的eclipse没有显示现有的方法 我在这里使用
它位于源代码中的
addLine
和addPolygon
之间,远离drawImage
或drawString
。如果您在大纲中搜索,您可能应该在那里激活“按名称排序”。有点离题,但请更新到PDFBox的最新版本。这是我在Maven中看到的最新版本……我忽略了您提到的版本(0.7.3)。这确实是古老的。可能同时该工件的组已经改变了。@mkl是的,我刚刚检查过。将0.7.3列为最新版本,而这是正确的组。
/**
* Draw a line on the page using the current non stroking color and the current line width.
*
* @param xStart The start x coordinate.
* @param yStart The start y coordinate.
* @param xEnd The end x coordinate.
* @param yEnd The end y coordinate.
* @throws IOException If there is an error while drawing on the screen.
*/
public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException
{
if (inTextMode)
{
throw new IOException("Error: drawLine is not allowed within a text block.");
}
addLine(xStart, yStart, xEnd, yEnd);
// stroke
stroke();
}