Solved

Read File Title (from the Properties)

Posted on 2003-11-11
16
14,879 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add a task in Outlook from access 11 39
Dev express lookupcombo 3 27
Not able to call Delphi XE10 dll function from Delphi 6.0 4 26
Automatic Email Reminder 4 37
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

770 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