【问题标题】:PDPageContentStream has no drawLine() methodPDPageContentStream 没有 drawLine() 方法
【发布时间】:2013-12-04 15:45:42
【问题描述】:

所以我刚开始在我的一个项目中使用 Apache PDFBox (0.7.3) 来写入 PDF。我想在整个页面上画一条线,根据the docs 和我看到的许多示例,我应该可以通过从我的 PDPageContentStream 调用 drawLine() 方法来做到这一点。但是,在 Eclipse 中,我只看到两个 drawImage 方法和一个 drawString 方法。有谁知道我应该怎么做才能解决这个问题? drawLine 方法是否已弃用?

【问题讨论】:

标签: java eclipse pdfbox


【解决方案1】:

PDPageContentStream 我看到了:

/**
 * 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();
}

因此,要么您的 PDFBox 副本已过时,要么您的 Eclipse 未显示现有方法。

我这里用的是eclipse Kepler,看看方法还行。

它位于源中addLineaddPolygon之间,远离drawImagedrawString。如果您在大纲中搜索,您可能应该在此处激活按名称排序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-26
    • 2015-12-08
    相关资源
    最近更新 更多