首页 > 解决方案 > 使用 Maven 导入 PDF

问题描述

我正在使用 Eclipse 和 java,并且正在查看两个不同的项目(工作区 1 和工作区 2)。我正在使用 PDF 图像,试图将某些东西从 WS1 移植到 WS2。正在执行的代码是

PDDocument pdfDocument;
... // Set to a valid PDDocument
page = pdfDocument.getPage(0);

在 WS1 这工作正常。在 WS2 中,pdfDocument 没有 getPage() 方法。

我检查了 pom 文件,两者都有以下内容:

    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>1.8.10</version>
    </dependency>

我查看了 PDDocument 的完整路径,两者都是“org.apache.pdfbox.pdmodel.PDDocument”。

由于我使用的是 eclipse,因此我可以右键单击并打开一个定义,我在 PDDocument 的两个工作区中都这样做了:

WS1

/**
 * This is the in-memory representation of the PDF document.
 * The #close() method must be called once the document is no longer needed.
 * 
 * @author Ben Litchfield
 */
public class PDDocument implements Closeable
{
    private static final Log LOG = 
LogFactory.getLog(PDDocument.class);

WS2:

/**
 * This is the in-memory representation of the PDF document.  You need to call
 * close() on this object when you are done using it!!
 * <p>
 * This class implements the {@link Pageable} interface, but since PDFBox
 * version 1.3.0 you should be using the {@link PDPageable} adapter instead
 * (see <a href="https://issues.apache.org/jira/browse/PDFBOX-788">PDFBOX-788</a>).
 *
 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
 * @version $Revision: 1.47 $
 */
public class PDDocument implements Pageable, Closeable
{

/**
 * Log instance.
 */

如您所见,即使它们的名称相同,这些文件也是不同的。我对 maven 和 pom 文件还是有点陌生​​。我无法真正理解这些有何不同,或者我应该怎么做才能在 WS2 中获得正确的。我做了Maven->更新。

有人会问我要完成什么。我正在尝试获取 PDF 文件中所有图像的数组或列表或集合,以便查看文档中是否包含特定图像。这在 WS1 中运行良好。

有什么建议该怎么做吗?我想我可以给 Ben Litchfield 发电子邮件;-)

标签: mavenpdf

解决方案


推荐阅读