@@ -62,26 +62,26 @@ public static void main( String[] args ) throws IOException
6262 }
6363
6464 File pdfFile = new File (args [0 ]);
65- String filePath = pdfFile .getParent () + FileSystems .getDefault ().getSeparator ();
65+ String directoryPath = pdfFile .getParent () + FileSystems .getDefault ().getSeparator ();
6666 try (PDDocument document = Loader .loadPDF (pdfFile ))
6767 {
6868 PDDocumentNameDictionary namesDictionary =
6969 new PDDocumentNameDictionary (document .getDocumentCatalog ());
7070 PDEmbeddedFilesNameTreeNode efTree = namesDictionary .getEmbeddedFiles ();
7171 if (efTree != null )
7272 {
73- extractFilesFromEFTree (efTree , filePath );
73+ extractFilesFromEFTree (efTree , directoryPath );
7474 }
7575
7676 // extract files from page annotations
7777 for (PDPage page : document .getPages ())
7878 {
79- extractFilesFromPage (page , filePath );
79+ extractFilesFromPage (page , directoryPath );
8080 }
8181 }
8282 }
8383
84- private static void extractFilesFromPage (PDPage page , String filePath ) throws IOException
84+ private static void extractFilesFromPage (PDPage page , String directoryPath ) throws IOException
8585 {
8686 for (PDAnnotation annotation : page .getAnnotations ())
8787 {
@@ -95,19 +95,19 @@ private static void extractFilesFromPage(PDPage page, String filePath) throws IO
9595 PDEmbeddedFile embeddedFile = getEmbeddedFile (complexFileSpec );
9696 if (embeddedFile != null )
9797 {
98- extractFile (filePath , complexFileSpec .getFilename (), embeddedFile );
98+ extractFile (complexFileSpec .getFilename (), embeddedFile , directoryPath );
9999 }
100100 }
101101 }
102102 }
103103 }
104104
105- private static void extractFilesFromEFTree (PDNameTreeNode <PDComplexFileSpecification > efTree , String filePath ) throws IOException
105+ private static void extractFilesFromEFTree (PDNameTreeNode <PDComplexFileSpecification > efTree , String directoryPath ) throws IOException
106106 {
107107 Map <String , PDComplexFileSpecification > names = efTree .getNames ();
108108 if (names != null )
109109 {
110- extractFiles (names , filePath );
110+ extractFiles (names , directoryPath );
111111 }
112112 else
113113 {
@@ -118,29 +118,29 @@ private static void extractFilesFromEFTree(PDNameTreeNode<PDComplexFileSpecifica
118118 }
119119 for (PDNameTreeNode <PDComplexFileSpecification > node : kids )
120120 {
121- extractFilesFromEFTree (node , filePath );
121+ extractFilesFromEFTree (node , directoryPath );
122122 }
123123 }
124124 }
125125
126- private static void extractFiles (Map <String , PDComplexFileSpecification > names , String filePath )
126+ private static void extractFiles (Map <String , PDComplexFileSpecification > names , String directoryPath )
127127 throws IOException
128128 {
129129 for (Entry <String , PDComplexFileSpecification > entry : names .entrySet ())
130130 {
131- PDComplexFileSpecification fileSpec = entry .getValue ();
132- PDEmbeddedFile embeddedFile = getEmbeddedFile (fileSpec );
131+ PDComplexFileSpecification complexFileSpec = entry .getValue ();
132+ PDEmbeddedFile embeddedFile = getEmbeddedFile (complexFileSpec );
133133 if (embeddedFile != null )
134134 {
135- extractFile (filePath , fileSpec .getFilename (), embeddedFile );
135+ extractFile (complexFileSpec .getFilename (), embeddedFile , directoryPath );
136136 }
137137 }
138138 }
139139
140- private static void extractFile (String filePath , String filename , PDEmbeddedFile embeddedFile )
140+ private static void extractFile (String filename , PDEmbeddedFile embeddedFile , String directoryPath )
141141 throws IOException
142142 {
143- String embeddedFilename = filePath + filename ;
143+ String embeddedFilename = directoryPath + filename ;
144144 File file = new File (embeddedFilename );
145145 File parentDir = file .getParentFile ();
146146 if (!parentDir .exists ())
0 commit comments