Author: tilman
Date: Fri Jan 16 12:16:54 2026
New Revision: 1931355
Log:
PDFBOX-5660: use more accurate names
Modified:
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java
Modified:
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java
==============================================================================
---
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java
Fri Jan 16 12:16:49 2026 (r1931354)
+++
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractEmbeddedFiles.java
Fri Jan 16 12:16:54 2026 (r1931355)
@@ -62,20 +62,20 @@ public final class ExtractEmbeddedFiles
try
{
File pdfFile = new File(args[0]);
- String filePath = pdfFile.getParent() +
System.getProperty("file.separator");
+ String directoryPath = pdfFile.getParent() +
System.getProperty("file.separator");
document = PDDocument.load(pdfFile );
PDDocumentNameDictionary namesDictionary =
new PDDocumentNameDictionary(
document.getDocumentCatalog() );
PDEmbeddedFilesNameTreeNode efTree =
namesDictionary.getEmbeddedFiles();
if (efTree != null)
{
- extractFilesFromEFTree(efTree, filePath);
+ extractFilesFromEFTree(efTree, directoryPath);
}
// extract files from page annotations
for (PDPage page : document.getPages())
{
- extractFilesFromPage(page, filePath);
+ extractFilesFromPage(page, directoryPath);
}
}
finally
@@ -88,7 +88,7 @@ public final class ExtractEmbeddedFiles
}
- private static void extractFilesFromPage(PDPage page, String filePath)
throws IOException
+ private static void extractFilesFromPage(PDPage page, String
directoryPath) throws IOException
{
for (PDAnnotation annotation : page.getAnnotations())
{
@@ -99,18 +99,18 @@ public final class ExtractEmbeddedFiles
PDEmbeddedFile embeddedFile = getEmbeddedFile(fileSpec);
if (embeddedFile != null)
{
- extractFile(filePath, fileSpec.getFilename(),
embeddedFile);
+ extractFile(fileSpec.getFilename(), embeddedFile,
directoryPath);
}
}
}
}
- private static void
extractFilesFromEFTree(PDNameTreeNode<PDComplexFileSpecification> efTree,
String filePath) throws IOException
+ private static void
extractFilesFromEFTree(PDNameTreeNode<PDComplexFileSpecification> efTree,
String directoryPath) throws IOException
{
Map<String, PDComplexFileSpecification> names = efTree.getNames();
if (names != null)
{
- extractFiles(names, filePath);
+ extractFiles(names, directoryPath);
}
else
{
@@ -121,29 +121,29 @@ public final class ExtractEmbeddedFiles
}
for (PDNameTreeNode<PDComplexFileSpecification> node : kids)
{
- extractFilesFromEFTree(node, filePath);
+ extractFilesFromEFTree(node, directoryPath);
}
}
}
- private static void extractFiles(Map<String, PDComplexFileSpecification>
names, String filePath)
+ private static void extractFiles(Map<String, PDComplexFileSpecification>
names, String directoryPath)
throws IOException
{
for (Entry<String, PDComplexFileSpecification> entry :
names.entrySet())
{
- PDComplexFileSpecification fileSpec = entry.getValue();
- PDEmbeddedFile embeddedFile = getEmbeddedFile(fileSpec);
+ PDComplexFileSpecification complexFileSpec = entry.getValue();
+ PDEmbeddedFile embeddedFile = getEmbeddedFile(complexFileSpec);
if (embeddedFile != null)
{
- extractFile(filePath, fileSpec.getFilename(), embeddedFile);
+ extractFile(complexFileSpec.getFilename(), embeddedFile,
directoryPath);
}
}
}
- private static void extractFile(String filePath, String filename,
PDEmbeddedFile embeddedFile)
+ private static void extractFile(String filename, PDEmbeddedFile
embeddedFile, String directoryPath)
throws IOException
{
- String embeddedFilename = filePath + filename;
+ String embeddedFilename = directoryPath + filename;
File file = new File(embeddedFilename);
File parentDir = file.getParentFile();
if (!parentDir.exists())