Solved

Read File Title (from the Properties)

Posted on 2003-11-11
16
14,867 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 69

Author Comment

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

Is it the only way?
0
 
LVL 7

Expert Comment

by:_agj_
Comment Utility
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 69

Author Comment

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

Word cannot open a PDF file!
0
 
LVL 5

Expert Comment

by:g0rath
Comment Utility
0
 
LVL 5

Expert Comment

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

Author Comment

by:Éric Moreau
Comment Utility
0
 
LVL 5

Expert Comment

by:g0rath
Comment Utility
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 69

Author Comment

by:Éric Moreau
Comment Utility
FSO cannot read these extended properties. The best so far is the latest URL I have posted.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 5

Accepted Solution

by:
g0rath earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
' 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
Comment Utility
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 69

Author Comment

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

Expert Comment

by:g0rath
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now