我想使用 java netbeans 从 pdf 中的按钮获取图像图标,并将其放在某个面板中。然而,我在这里撞到了一块砖。我使用 PDFBox 作为我的 PDF 导出器,但我似乎不太理解。我已经成功地从表单字段中读取,但是只要我尝试在 PDFBox 中找到它,就没有按钮提取器。我应该怎么做?是否可以使用这种方法,或者是否有其他方法。提前致谢。
编辑:我已经发现使用示例实用程序中的图像提取图像使用此代码:
File myFile = new File(filename);
try {
//PDDocument pdDoc = PDDocument.loadNonSeq( myFile, null );
PDDocument pdDoc = null;
pdDoc = PDDocument.load( myFile );
PDDocumentCatalog pdCatalog = pdDoc.getDocumentCatalog();
PDAcroForm pdAcroForm = pdCatalog.getAcroForm();
// dipakai untuk membaca isi file
List pages = pdDoc.getDocumentCatalog().getAllPages();
Iterator iter = pages.iterator();
while( iter.hasNext() )
{
PDPage page = (PDPage)iter.next();
PDResources resources = page.getResources();
Map images = resources.getImages();
if( images != null )
{ …Run Code Online (Sandbox Code Playgroud)