Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4374
  • Last Modified:

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.
0
Éric Moreau
Asked:
Éric Moreau
  • 4
1 Solution
 
SuperKarateMonkeyCommented:
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?
0
 
É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.
0
 
SuperKarateMonkeyCommented:
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SuperKarateMonkeyCommented:
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:

http://peccatte.karefil.com/Software/SumInfos/SumInfosEN.htm

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.
0
 
SuperKarateMonkeyCommented:
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:

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


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.
0
 
softexperienceCommented:
You may also test our MetaDataMiner Catalogue Pro software at www.metadataminer.com 

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 OpenOffice.org, 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 "
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now