Read File Title (from the Properties) - In Windows

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.
LVL 71
Éric MoreauSenior .Net ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
Éric MoreauSenior .Net ConsultantAuthor Commented:
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.
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.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 "
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.