[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Read File Title (from the Properties)

Posted on 2003-11-11
16
Medium Priority
?
14,915 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
[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
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses

650 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