Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Read File Title (from the Properties)

Posted on 2003-11-11
16
Medium Priority
?
14,924 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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