Solved

Read File Title (from the Properties) - In Windows

Posted on 2003-11-11
6
4,367 Views
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.
0
Comment
Question by:Éric Moreau
[X]
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
6 Comments
 
LVL 2

Expert Comment

by:SuperKarateMonkey
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?
0
 
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.
0
 
LVL 2

Expert Comment

by:SuperKarateMonkey
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.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 2

Expert Comment

by:SuperKarateMonkey
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:

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
 
LVL 2

Accepted Solution

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

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
 

Expert Comment

by:softexperience
ID: 9981941
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

734 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