Solved

Read File Title (from the Properties)

Posted on 2003-11-11
16
14,885 Views
Last Modified: 2013-11-23
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?
0
Comment
Question by:Éric Moreau
  • 7
  • 5
  • 2
  • +2
16 Comments
 
LVL 70

Author Comment

by:Éric Moreau
ID: 9722064
I just found dsofile.exe (http://support.microsoft.com/?kbid=224351).

Is it the only way?
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9722145
for a pdf, i aint got much clue...

but for an office doc, i guess u cud open it using its corres. object model and edit its properties.

Just do a record macro for a word doc and try....dont think it shud be an ache to get office docs doing this.

as far as a pdf is concerncerd, if u got the stuff to do it from word, i guess u can use the word obj model to do the same.
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 9722158
>>i guess u can use the word obj model to do the same

Word cannot open a PDF file!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 5

Expert Comment

by:g0rath
ID: 9722223
0
 
LVL 5

Expert Comment

by:g0rath
ID: 9722226
oops no that won't work forgot about the PDF thing....and I even wrote the link wrong.
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 9722235
0
 
LVL 5

Expert Comment

by:g0rath
ID: 9722258
Dim objFSO As New FileSystemObject
    Dim objFileDetails As File
   
    Set objFileDetails = objFSO.GetFile("C:\config.sys")

    This only gives file properties, date created, attributes, etc...that is what is referenced in the above link
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 9722274
FSO cannot read these extended properties. The best so far is the latest URL I have posted.
0
 
LVL 5

Accepted Solution

by:
g0rath earned 250 total points
ID: 9722339
Here is a guy that was able to read the properties from a jpeg image....but it's written in C#

http://www.devhood.com/tools/tool_details.aspx?tool_id=419

private void btnSave_Click(object sender, System.EventArgs e)
            {      
                  // Set the temporary property to the first of properties that the JPG already has
                  System.Drawing.Imaging.PropertyItem propTemp = propAllProperties[0];

                  byte[] Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtTitle.Text);
                  propTemp.Id = 40091;                              // Title
                  propTemp.Len = Value.Length;
                  propTemp.Value = Value;
                  imgImage.SetPropertyItem(propTemp);

                  Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtComments.Text);
                  propTemp.Id = 40092;                              // Comments
                  propTemp.Len = Value.Length;
                  propTemp.Value = Value;
                  imgImage.SetPropertyItem(propTemp);

                  Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtAuthor.Text);
                  propTemp.Id = 40093;                              // Author
                  propTemp.Len = Value.Length;
                  propTemp.Value = Value;
                  imgImage.SetPropertyItem(propTemp);

                  Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtKeywords.Text);
                  propTemp.Id = 40094;                              // Keywords
                  propTemp.Len = Value.Length;
                  propTemp.Value = Value;
                  imgImage.SetPropertyItem(propTemp);

                  Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtSubject.Text);
                  propTemp.Id = 40095;                              // Subject
                  propTemp.Len = Value.Length;
                  propTemp.Value = Value;
                  imgImage.SetPropertyItem(propTemp);

                  try
                  {
                        if(saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                              imgImage.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                  }
                  catch(Exception ee)
                  {
                  }
            }
      }
}

It may be that is has been added to the .Net Framework which means it may work via this method using VB .Net
0
 
LVL 5

Expert Comment

by:g0rath
ID: 9722413
hehe...ok this is really bad....I've never actually used that dso program until now.

I installed it, ran the demo and selected a non word file. And it works just fine....the example is there and you are correct with your first post. Use the dsofile.exe
0
 
LVL 5

Expert Comment

by:g0rath
ID: 9722480
' Add Reference to:
' DS: OLE Document Properties 1.4 Object Library

Dim oDocProp As DSOleFile.DocumentProperties
Dim oFilePropReader As DSOleFile.PropertyReader
Dim sFile as String

sFile = "C:\Config.sys"
Set oFilePropReader = New DSOleFile.PropertyReader
Set oDocProp = oFilePropReader.GetDocumentProperties(sFile)

msgbox oDocProp.Title & " " & oDocProp.Author

oDocProp.Title = "New Title"
oDocProp.Author = "New Author"

Set oDocProp = Nothing
Set oFilePropReader = Nothing
0
 
LVL 14

Expert Comment

by:aelatik
ID: 9723700
There is a very good free OCX which will get every property a file has. Just give it a try....

http://axsoft.hypermart.net/products/fileinfo.htm
0
 
LVL 70

Author Comment

by:Éric Moreau
ID: 9723894
It doesn't give you what I want (Extended properties) !
0
 
LVL 5

Expert Comment

by:g0rath
ID: 9724059
There are examples of how to create custom tags using that DSOle object as well

oDocProp.CustomProperties.Add "Key", "Value"

0
 

Expert Comment

by:Lost_In_JavaScript_Land
ID: 10081158
Just a note, but if you want to read the PDF properties, just load Acrobat on your machine, and in your VB code, use the "Acrobat" object.  Just add the "Acrobat" object to your project references.

As I don't know how to use the api that well, I have no examples for you.  I know there are some on this site, so just look around for them.  Hope this helps!
0
 

Expert Comment

by:Lost_In_JavaScript_Land
ID: 10081176
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
FMX and jaudiotracker playing memory stream 29 85
Added a column screws up code 5 63
Advice in Xamarin 21 96
Tidtcpserver listening on multiports? 1 35
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 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