Read File Title (from the Properties) - In Windows

Posted on 2003-11-11
Last Modified: 2012-05-04
How can I read the Title and the other properties (all the properties under the Summary tab of the file properties)  of a PDF file? All this is running in Windows 2000.
Question by:Éric Moreau
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4

Expert Comment

ID: 9723232
Can't be done in java, I'm afraid.  it's a purely platform-dependent trick of Windows, and as a result, Sun has no interest in supporting it, as it wouldn't be platform independent.

Why do you need it?  Is it already in the file and you need to only read it, or were you planning on setting it yourself?
LVL 70

Author Comment

by:Éric Moreau
ID: 9723930
We need a dynamic of retrieving these info from the files properties to display somewhere. The lowest maintenance would have been to use these properties.

Expert Comment

ID: 9723963
Well, in that case it can't be done, at least in java directly.  The only possible option is going to be to try to hack it by using a windows command line, and calling it from the java.  I'm looking around through the windows documentation to see if this is possible, and I'll get back on this if I find anything.
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Expert Comment

ID: 9724527
Alright.  Good news and bad news:

Bad news:  The only 'officially' sanctioned way to access the Summary Information properties of a file is to use the C++ functions exposed by the windows API.  Also, these properties are only available in NTFS file systems.  If you have anything in FAT32 you're going to lose those properties when they get copied over to them.

Good news:  There are unofficial kludges available.  For example, there's a command line application that can be used to read these properties located at:

You can then just call it from the command line using the command:

Runtime.getRuntime().exec(" etc..." );

Here's the tricky bit, though:  I don't think it's possible to capture the output of the program, so you're going to have to cobble together a .bat file which runs the program, and then dumps the results into a file.  From there you can read the file using java to get the appropriate properties.

This is really not the best way to handle this problem, but it's about as good as it's going to get if you want to stick to java.  Fact is, Sun really has no interest in tackling these sort of issues because they are windows-specific.  They'd rather deal with cross-platform features and performance enhancements, and I agree with that approach.  If you have no interest in any other platform but Windows w/ NTFS, (2000 and XP,) and you want to get into bed with Microsoft over an issue like this, you might need to look into Visual Studio.

Accepted Solution

SuperKarateMonkey earned 125 total points
ID: 9724953
There's another way to handle grabbing the output of an executable, aside from dumping it into a file within a windows .bat file.  You could get it's output from an InputStream object.  The code would look like this:

      Process proc = Runtime.getRuntime().exec( "SomeExecutable.exe" );
      BufferedInputStream in = new BufferedInputStream( proc.getInputStream() );
      int i;
      while( ( i = ) != -1 )
            System.out.print( (char)i );
catch( IOException e )
      System.err.println( "Error:" + e.getMessage() );

Now, all this code does is dump the output to the System.out, but you could instead read it into a String to parse it, or any of a dozen different things.  You should beware, however, that the Runtime.createProcess() method creates a native process that runs asynchronously from the application, so you need to programatically buffer that inputstream IMMEDIATELY.  Don't do anything else, lest you lose output.  That's why you create a BufferedInputStream, by the way:  It will create a buffer for the InputStream to dump it's output into, so that you don't need to worry about whether you're catching all the output, or if you miss something.

Expert Comment

ID: 9981941
You may also test our MetaDataMiner Catalogue Pro software at 

Listing folders and documents summary information, extraction of file properties and metadata, creation of HTML file catalogs including hypertext links and building XML reports.
"Software for extended listings of folders contents in interactive mode and in command line. File cataloging utility that enables quick creation of HTML pages listing files and associated metadata, managing and updating document properties associated with such files as: Microsoft Office, retrieve information from, StarOffice, Visio documents, PDF documents , export metadata from photos JPEG, Tiff images (IPTC fields).

Metadata Miner Catalogue PRO also enables Adobe XMP file information (eXtensible Metadata Platform) metadata extraction from documents produced by recent Adobe applications and XSL transformation on metadata extracted listings converting to Dublin Core RDF, CSV, SVG and other custom presentations for common uses or in a Content Management System Architecture

Allows companies to quickly gather summary information from MS Office, Adobe documents and other source documents, and easily move that meta data into XML or post it on shared drives as an HTML documentation catalog index with hypertext links to access files.

Helps in mass update of standard and custom file properties in a folder and sub-folders to easily change a set of documents and include metadata in Word and other Office files. This Professional version lets you call it from command-line to extract metadata for batch processing and optionally run a XSL transformation delivered with the program or your own XSL "

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question